且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2022-03-01 21:23:25

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

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

2009年10月版的来源。使用外部项目,你可以调用任何make命令在主机系统上可用,我们使用他们提供的配置命令在Windows,Mac和Linux上构建Qt。

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.