Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find Lua headers with find_package in cmake

Tags:

cmake

lua

I'm trying to use CMake to build generate the make file for a project of mine that uses Lua. When I run make I get this error:

/path/to/my/project/luaudio/luaudio.c:1:17: fatal error: lua.h: No such file or directory

In the CMakeLists.txt file, I have the following lines, which I thought would do it, but apparently they're not enough:

find_package(Lua51 REQUIRED) 
set(Luaudio_INCLUDE_DIRS ${Luaudio_SOURCE_DIR} ${Lua51_INCLUDE_DIRS} PARENT_SCOPE)
include_directories(${Luaudio_INCLUDE_DIRS})

Lua51_Include_Dirs appears to be empty (attempting to run it though the message command doesn't print anything) so I suspect that it just can't find it. Do I need to specify where to look for Lua? I was under the impression that the whole point of find_package was that it would look in a set a predefined places so that I don't need to specify where it is specifically.

(This is on an Ubuntu machine and I do have the Lua packages installed.)

like image 503
Alex Avatar asked Aug 26 '11 20:08

Alex


People also ask

Where does CMake Find_package search?

CMake ships with its own set of built-in find_package scripts, and their location is in the default CMAKE_MODULE_PATH.

What does Find_package do CMake?

CMake searches for a file called Find<package>. cmake in the CMAKE_MODULE_PATH followed by the CMake installation. If the file is found, it is read and processed by CMake. It is responsible for finding the package, checking the version, and producing any needed messages.


3 Answers

for Ubuntu 14.04 sudo apt-get install lua5.2 sudo apt-get install liblua5.2-dev

like image 108
Honghe.Wu Avatar answered Oct 26 '22 04:10

Honghe.Wu


Exploring FindLua51.cmake from cmake 2.8 I found that it sets LUA_INCLUDE_DIR variable instead of Lua51_INCLUDE_DIRS. So cmake code should be

find_package(Lua51 REQUIRED) 
set(Luaudio_INCLUDE_DIRS ${Luaudio_SOURCE_DIR} ${LUA_INCLUDE_DIR} PARENT_SCOPE)
include_directories(${Luaudio_INCLUDE_DIRS})
like image 45
Andrey Kamaev Avatar answered Oct 26 '22 04:10

Andrey Kamaev


install lua bin:

sudo apt-get install lua5.1

install lua lib:

sudo apt-get install lua5.1-dev
like image 16
hustljian Avatar answered Oct 26 '22 02:10

hustljian