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
where arm/build.sh
might look like:
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" ../..
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.
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?
Cmake distributions usually come with a
FindSubversion.cmake
in theModules
folder. You just use it like this:Now you have
SVN_WC_REVISION
defined as a preprocessor macro in your source code. It's available to your "about" dialogue or your .rc files where you can add metadata properties to your DLL. In addition, you have no locally modified files left over after building. It's that simple!Here's some reference material from the distributed FindSubversion.cmake:
I know it's a little late, but I hope this helps you or someone else who stumbles on your question like I did as I was researching the answer (only to find the answer locally on my own machine in the Cmake modules folder).
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).
If I understood your problem correctly ("I will have a lot of files in tree, but want to version only small predefined subset of it"), you can use lazy-way
build
directorysvn add FILE
only needed filesAs result you'll get permanent over time
svn:ignore
and all build-articacts will not appear in repo