如何与CMAKE ExternalProject_Add构建外部项目

发布于 2025-02-13 16:48:40 字数 1189 浏览 1 评论 0原文

我有一个要集成到现有的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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九八野马 2025-02-20 16:48:40

如果您不下载代码,则需要将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 the ExternalProject_Add documentation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文