CMakeExternalProject_Add() - 使用自定义的 CMakeLists.txt 进行构建
我正在将 lua 构建为外部项目,并且我想使用我自己的 CMakeLists.txt 而不是捆绑的 Makefile。这就是我的主 CMakeLists.txt 中的内容:
include(ExternalProject)
set(lua_RELEASE 5.1.4)
ExternalProject_Add(
lua-${lua_RELEASE}
URL http://www.lua.org/ftp/lua-${lua_RELEASE}.tar.gz
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/download/lua-${lua_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/lua/lua-${lua_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/build/lua-${lua_RELEASE}
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
)
为了使 BUILD 步骤正常工作,SOURCE_DIR 中必须有一个 CMakeLists.txt。我目前在 SOURCE_DIR 中有这个 CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(lua)
set(lua_library
lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c
ltable.c ltm.c lundump.c lvm.c lzio.c
lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c
ltablib.c lstrlib.c loadlib.c linit.c
)
foreach(s ${lua_library})
set(lua_LIBRARY ${lua_LIBRARY} src/${s})
endforeach()
add_definitions(-DLUA_ANSI=1)
add_library(lua STATIC ${lua_LIBRARY})
这有效,但我不高兴让 lua 源文件混乱我的版本控制的 CMakeLists.txt。
有没有办法为 SOURCE_DIR 中不在的构建步骤指定自定义 CMakeLists.txt?
I am building lua as an external project and I want to use my own CMakeLists.txt instead of the bundled Makefile. This is what I have in my main CMakeLists.txt:
include(ExternalProject)
set(lua_RELEASE 5.1.4)
ExternalProject_Add(
lua-${lua_RELEASE}
URL http://www.lua.org/ftp/lua-${lua_RELEASE}.tar.gz
DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/download/lua-${lua_RELEASE}
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/lua/lua-${lua_RELEASE}
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/build/lua-${lua_RELEASE}
UPDATE_COMMAND ""
PATCH_COMMAND ""
INSTALL_COMMAND ""
)
For the BUILD step to work there must be a CMakeLists.txt in the SOURCE_DIR. I have this CMakeLists.txt in the SOURCE_DIR at the moment:
cmake_minimum_required(VERSION 2.8)
project(lua)
set(lua_library
lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c
ltable.c ltm.c lundump.c lvm.c lzio.c
lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c
ltablib.c lstrlib.c loadlib.c linit.c
)
foreach(s ${lua_library})
set(lua_LIBRARY ${lua_LIBRARY} src/${s})
endforeach()
add_definitions(-DLUA_ANSI=1)
add_library(lua STATIC ${lua_LIBRARY})
This works but I am not happy about having the lua source files clutter my version controlled CMakeLists.txt.
Is there any way to specify a custom CMakeLists.txt for the build step that is not in SOURCE_DIR?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己想出来了。我现在将其用作
PATCH_COMMAND
:这使我可以在
thirdparty/lua
中拥有自定义 CMakeLists.txt,并将上游包下载到thirdparty/lua /lua-${lua_RELEASE}
。完美的!I figured it out myself. I am now using this as the
PATCH_COMMAND
:This allows me to have my custom CMakeLists.txt in
thirdparty/lua
and the upstream package is downloaded tothirdparty/lua/lua-${lua_RELEASE}
. Perfect!