用CMake编译其他外部库(不带CMakeLists.txt) [英] Compile other external libraries (without CMakeLists.txt) with CMake

查看:200
本文介绍了用CMake编译其他外部库(不带CMakeLists.txt)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

short - 当二进制文件/库只有一个makefile时,是否可以用CMake构建一个外部二进制文件/库?

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?

你有你自己的项目,一束CMakeLists.txt在你的src-tree和这个外部库与其源文件。你的源依赖于这个库,一些二进制/库想要链接它。如果它只有一个makefile或Visual Studio项目文件,没有给定的CMakeLists.txt如何编译这个外部库?
有机会调用configure / make出CMake吗?或者在Windows下运行VS的批处理编译?

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...

推荐答案

听起来你想要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.

这篇关于用CMake编译其他外部库(不带CMakeLists.txt)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆