在cmake中找不到带有find_package的Lua头文件 [英] Unable to find Lua headers with find_package in cmake

查看:85
本文介绍了在cmake中找不到带有find_package的Lua头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用CMake为使用Lua的我的项目生成生成make文件.当我运行make时,出现此错误:

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

在CMakeLists.txt文件中,我有以下几行,我认为可以,但显然它们还不够:

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似乎是空的(尽管message命令不输出任何内容,但试图运行它),所以我怀疑它根本找不到它.我需要指定在哪里寻找Lua吗?我的印象是,find_package的全部要点是它将在一组预定义的位置中查找,因此我不需要指定它的具体位置.

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.

(这是在Ubuntu机器上,我确实安装了Lua软件包.)

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

推荐答案

从cmake 2.8探索 FindLua51.cmake 我发现它设置了 LUA_INCLUDE_DIR 变量而不是Lua51_INCLUDE_DIRS .所以cmake代码应该是

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})

这篇关于在cmake中找不到带有find_package的Lua头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆