如何与CMAKE ExternalProject_Add构建外部项目
我有一个要集成到现有的cmake构建中的库。 Cmake所要做的就是进入该目录,运行“ MAKE”,执行我布置时执行安装步骤(可能只是包含二进制目录的副本),然后继续执行此操作。 Cmake继续踩在我的脚趾上,试图创建目录并猜测路径名。
基本cmakelists.txt中的命令是:
ExternalProject_Add(mylib BINARY_DIR ${CMAKE_SOURCE_DIR}/mylib/sdk BUILD_COMMAND make)
但是,当我尝试构建时,cmake抱怨:
CMake Error at /usr/share/cmake-3.16/Modules/ExternalProject.cmake:2630 (message):
No download info given for 'mylib' and its source directory:
/home/brydon/build/myTarget/existingLib/mylib-prefix/src/mylib
is not an existing non-empty directory. Please specify one of:
* SOURCE_DIR with an existing non-empty directory
* DOWNLOAD_COMMAND
* URL
* GIT_REPOSITORY
* SVN_REPOSITORY
* HG_REPOSITORY
* CVS_REPOSITORY and CVS_MODULE
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/ExternalProject.cmake:3236 (_ep_add_download_command)
CMakeLists.txt:83 (ExternalProject_Add)
为什么它会跳到所有这些目录?我不明白Cmake在这里尝试做什么 - 它要做的就是在目录中运行make
,我非常清楚地将其描述为build dir。
我尝试使用source_dir,但是后来我发现该目录中没有cmakelists.txt的错误,这又不是我想要的。
我如何才能让Cmake非常简单地使用现有的makefile,而仅此而已?
I've got a library I want to integrate into an existing cmake build. All cmake has to do is go into that directory, run "make", perform install steps as I lay out (probably just a copy to an included binary directory), and then keep doing its thing. Cmake continues to step on my toes trying to create directories and guess at pathnames.
The command in the base CMakeLists.txt is:
ExternalProject_Add(mylib BINARY_DIR ${CMAKE_SOURCE_DIR}/mylib/sdk BUILD_COMMAND make)
However, when I try to build, cmake complains about:
CMake Error at /usr/share/cmake-3.16/Modules/ExternalProject.cmake:2630 (message):
No download info given for 'mylib' and its source directory:
/home/brydon/build/myTarget/existingLib/mylib-prefix/src/mylib
is not an existing non-empty directory. Please specify one of:
* SOURCE_DIR with an existing non-empty directory
* DOWNLOAD_COMMAND
* URL
* GIT_REPOSITORY
* SVN_REPOSITORY
* HG_REPOSITORY
* CVS_REPOSITORY and CVS_MODULE
Call Stack (most recent call first):
/usr/share/cmake-3.16/Modules/ExternalProject.cmake:3236 (_ep_add_download_command)
CMakeLists.txt:83 (ExternalProject_Add)
Why is it jumping at all of these directories? I don't understand what CMake is trying to do here - all it needs to do is run make
in the directory that I very clearly spefified as the build dir.
I have tried using SOURCE_DIR but then I get an error that there is no CMakeLists.txt in that directory, which again is not what I want.
How can I get cmake to very simply use an existing makefile, and nothing more?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不下载代码,则需要将
source_dir
设置为包含库的现有目录。如果您不使用cmake,则需要将
configure_command
设置为If you aren't downloading code then
SOURCE_DIR
needs to be set to an existing directory containing your library.If you aren't using cmake then you need to set
CONFIGURE_COMMAND
to an empty string as stated in theExternalProject_Add
documentation.