使用 CMake 编译其他外部库(不含 CMakeLists.txt)

发布于 2024-09-14 14:31:50 字数 310 浏览 2 评论 0原文

简而言之——当二进制文件/库仅给出一个 makefile 时,是否可以使用 CMake 从项目中构建外部二进制文件/库?

所以你有自己的项目,src 树中的一堆 CMakeLists.txt 以及这个外部库及其源文件。您的源依赖于这个库,并且一些二进制文件/库想要链接到它。如果这个外部库只有一个 makefile 或 Visual Studio 项目文件并且没有给定的 CMakeLists.txt,那么如何编译该外部库? 是否有机会从 CMake 中调用configure/make?或者在Windows下用VS运行批量编译?还是其他什么?

感谢您对这一问题的帮助...

short -- Is it possible to build a external binary/library out of a project with CMake, when the binary/library only has a makefile given?

So you have your own project, a bunch of CMakeLists.txt in your src-tree and this external library with its source-files. Your sources depend on this library and some binaries/libraries want to link against it. How would one compile this external library if it has only a makefile or Visual Studio project file and no given CMakeLists.txt?
Is there a chance to call configure/make out of CMake? Or run an batch-compile with VS under Windows? Or anything else?

Thanks for your help with this one...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

↙温凉少女 2024-09-21 14:31:50

听起来你想要 CMake 的外部项目。在开发 Titan 构建系统时,我广泛地使用了它,它提供了一种管理多个源外构建的方法。您可以包含ExternalProject,然后类似以下

ExternalProject_Add(Qt
   DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}
   URL ${qt_file}
   UPDATE_COMMAND ""
   SOURCE_DIR ${qt_source}
   BUILD_IN_SOURCE 1
   CONFIGURE_COMMAND ${qt_configure}
   BUILD_COMMAND ${qt_build}
   INSTALL_COMMAND "${qt_install}"
   )

内容将构建项目: 2009 年 10 月号来源。使用外部项目,您可以调用主机系统上可用的任何 make 命令,我们在 Windows、Mac 和 Linux 上使用其提供的配置命令构建 Qt。

It sounds like you want CMake's external project. I have worked with it quite extensively when developing the Titan build system, and it provides a way of managing multiple out of source builds. You can include ExternalProject, and then something like the following would build the project:

ExternalProject_Add(Qt
   DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}
   URL ${qt_file}
   UPDATE_COMMAND ""
   SOURCE_DIR ${qt_source}
   BUILD_IN_SOURCE 1
   CONFIGURE_COMMAND ${qt_configure}
   BUILD_COMMAND ${qt_build}
   INSTALL_COMMAND "${qt_install}"
   )

There is an article about external projects in the October 2009 issue of the source too. Using external project you can call any make commands available on the host system, we build Qt using their supplied configure command on Windows, Mac and Linux.

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