如何使用CMake和SVN对源外构建目录进行版本控制 [英] How to version control out-of-source build directory using CMake and SVN

查看:173
本文介绍了如何使用CMake和SVN对源外构建目录进行版本控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CMake建议使用源外版本。通常,对于每个构建,我拥有的都是小的构建脚本,因此无需手动执行CMake命令。例如,我的构建目录可能如下所示:

CMake recommends out-of-source builds. Typically what I have are small build scripts for each build so I don't have to manually execute the CMake command. For example my build directory might look like:

build
|--linux
|  |--build.sh
|--arm
   |--build.sh

其中 arm / build.sh 可能看起来像:

cmake \
    -D CMAKE_CXX_COMPILER=${CROSS_COMPILE}g++ \
    -D CMAKE_C_COMPILER=${CROSS_COMPILE}gcc \
    -D CMAKE_CXX_FLAGS="-mcpu=cortex-a9" \
    -D CMAKE_C_FLAGS="-mcpu=cortex-a9" \
    -D CMAKE_BUILD_TYPE="" \
    -G "Unix Makefiles" ../..

我喜欢这种方法如何通知开发人员所支持的平台,总体来说还不错-直到我要版本控制 build.sh 脚本。我的问题是,当我将 build 添加到版本控制时,我会拾取所有CMake构建文件并构建目录。我知道我可以忽略相关的目录和文件,但是请考虑如果我在顶层添加新版本或添加新库会发生什么情况-然后我每次都会为每个版本更新SVN中的ignore属性。

I like how this approach informs the developer as to which platforms are supported and overall it is fine - until I want to version control the build.sh scripts. The problem I have is that when I add build to version control I pick up all the CMake build files and build directories. I know I can "ignore" the relevant directories and files, but consider what happens if I add a new build or add a new library to my top level - I then to update the ignore property in SVN for each build each time.

这感觉不太容易维护,我敢肯定有更好的方法。在构建后保持干净的 SVN状态的同时,没有人有建议为每个构建编写CMake命令的脚本吗?

This doesn't feel very maintainable and I'm sure there's a better way. Does anyone have any suggestions for scripting the CMake commands for each build while maintaining a 'clean' SVN status after a build?

推荐答案

您应该将一个或多个构建脚本放在源代码所在的位置。不管您是进行源代码外构建,源代码都属于可重用的构建脚本(就像makefiles,CMakeLists.txt一样)。

You should put your build script or scripts where the source code is. It doesn't matter if you're doing an out-of-source build, a reusable build script belongs to the source code (just like makefiles, CMakeLists.txt).

这篇关于如何使用CMake和SVN对源外构建目录进行版本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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