能够预先编译依赖项的 C++ Buildsystem
我正在为 C++ 游戏项目设置构建环境.我们的主要要求是不仅能够构建我们的游戏代码,还能够构建它的依赖项(Ogre3D、Cegui、boost 等).此外,我们希望能够在 Linux 和 Windows 上构建,因为我们的开发团队由使用不同操作系统的成员组成.
I'm in the middle of setting up an build environment for a c++ game project. Our main requirement is the ability to build not just our game code, but also its dependencies (Ogre3D, Cegui, boost, etc.). Furthermore we would like to be able build on Linux as well as on Windows as our development team consists of members using different operating systems.
Ogre3D 使用 CMake 作为其构建工具.这就是为什么到目前为止我们的项目也基于 CMake.一旦在每个团队成员系统上手动设置了所有依赖项,我们就可以完美编译,因为 CMake 能够找到库.
Ogre3D uses CMake as its build tool. This is why we based our project on CMake too so far. We can compile perfectly fine once all dependencies are set up manually on each team members system as CMake is able to find the libraries.
问题是是否有可行的方法来自动设置依赖项.作为一名 Java 开发人员,我知道 Maven,但 C++ 世界中确实存在哪些工具?
The Question is if there is an feasible way to get the dependencies set up automatically. As a Java developer I know of Maven, but what tools do exist in the world of c++?
更新:感谢您提供的好答案和链接.在接下来的几天里,我将尝试一些工具来看看满足我们的要求,从 CMake 开始.到目前为止,我确实与 autotools 分享过,而且我非常喜欢文档(autobook 非常好读),但我担心 autotools 不适合在 Windows 上原生使用.
Update: Thanks for the nice answers and links. Over the next few days I will be trying out some of the tools to see what meets our requirements, starting with CMake. I've indeed had my share with autotools so far and as much as I like the documentation (the autobook is a very good read), I fear autotools are not meant to be used on Windows natively.
你们中的一些人建议让一些 IDE 处理依赖关系管理.我们由个人组成,他们使用所有可能的技术来编写从纯 Vim 到成熟的 Eclipse CDT 或 Visual Studio 的代码.这是 CMake 允许使用一些灵活性的地方,它能够生成本机项目文件.
Some of you suggested to let some IDE handle the dependency management. We consist of individuals using all possible technologies to code from pure Vim to fully blown Eclipse CDT or Visual Studio. This is where CMake allows use some flexibility with its ability to generate native project files.
推荐答案
在最新的 CMake 2.8 版本中有新的 ExternalProject 模块.这允许下载/签出代码、配置和构建它作为主构建树的一部分.它还应该允许设置依赖项.
In the latest CMake 2.8 version there is the new ExternalProject module. This allows to download/checkout code, configure and build it as part of your main build tree. It should also allow to set dependencies.
在我的工作(医学图像处理组)中,我们使用 CMake 构建我们自己的所有库和应用程序.我们有一个内部工具来跟踪项目之间的所有依赖关系(在 XML 数据库中定义).大多数第三方库(如 Boost、Qt、VTK、ITK 等)为我们支持的每个系统(MSWin32、MSWin64、Linux32 等)构建一次,并在版本控制系统中以 zip 文件的形式提交.然后,CMake 将根据开发人员正在使用的系统提取并配置正确的 zip 文件.
At my work (medical image processing group) we use CMake to build all our own libraries and applications. We have an in-house tool to track all the dependencies between projects (defined in a XML database). Most of the third party libraries (like Boost, Qt, VTK, ITK etc..) are build once for each system we support (MSWin32, MSWin64, Linux32 etc..) and are commited as zip-files in the version control system. CMake will then extract and configure the correct zip file depending on which system the developer is working on.
相关文章