[cmake-developers] Modules/FindLua51.cmake: lua5.1 include path seems wrong

o.kurz at gmx.de o.kurz at gmx.de
Sun Jun 8 09:00:12 EDT 2014


Hello,

I observed a problem trying to build a CMake based project using lua5.1 on a
system where both lua5.1 and lua5.2 are present (Linux Arch).
It seems, "Modules/FindLua51.cmake" causes the header for lua5.2 to be
found but the lib for version 5.1 causing obvious problems when trying to
link.
Using "strace" I observed that cmake searches in each path prefix first in
the subdirectory "include", then starting from the base directory.
As
Modules/FindLua51.cmake specifies
{{{
find_path(LUA_INCLUDE_DIR lua.h
  HINTS
    ENV LUA_DIR
  PATH_SUFFIXES include/lua51 include/lua5.1 include/lua-5.1 include/lua include
}}}
Then cmake actually looks for lua.h in this folder order:
<prefix>/include/include/lua51/
<prefix>/include/include/lua5.1/
<prefix>/include/include/lua-5.1/
<prefix>/include/include/lua/
<prefix>/include/include/
<prefix>/include/
... next prefix ...

which looks wrong to me.

"strace" tells:
{{{
access("/usr/include/include/lua51/lua.h", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/include/include/lua5.1/lua.h", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/include/include/lua-5.1/lua.h", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/include/include/lua/lua.h", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/include/include/lua.h", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/include/lua.h", R_OK)      = 0
}}}
So a file is found but this is actually the one from lua5.2. cmake should have searched in
/usr/include/lua5.1/lua.h
in my case.

I deleted the additional "include/" in FindLua51.cmake and it worked.

A patch is attached.

I would be very happy for receiving feedback.

Regards,
Oliver Kurz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-FindLua51-Correct-include-search-path.patch
Type: text/x-patch
Size: 771 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20140608/d4dae660/attachment.bin>


More information about the cmake-developers mailing list