I'm working on a larger project and we are thinking on how to organize the large build. I think it should/could be done with cmake but currently I don't know how all of our requirements can be met.
Here's what our project organization looks like:
With cmake in mind, I'm thinking of a directory structure like this
- Root directory
- Build Module 1
- Build Module 1 Static Lib
- Build Module 1 Unit Test
- Build Module 1 Public Interface
- Build Module 2
- ...
- Build Module n
First question here: Where to start placing the CMakeLists.txt files? I'd start at Build Module level and not on root. This way, a developer can create his custom one if he wants to build only the modules 3, 4 and 5.
Second one: how to handle deployment / finding packages. Ideally, the find mechanism for the dependencies would allow the creation of builds that built from source as well as builds that fetch just the dependent binaries from source. I hope this can be done somehow using find_package and xxxConfig.cmake / FindXXX.cmake. Can someone tell me how? How do I create these files? How do you create the appropriate deployment using cmake?
Third question: has someone some information on how we could integrate nuget into this process? Can this be done as cpack generator? Is there already one? Can cpack be a replacement for nuget (meaning that it can fetch binaries from some remote location and install them in the build process)?
Thank you. Tobias
1) You could create a top-level CMakeLists.txt file and have cache options for building each module:
http://quickgit.kde.org/?p=extra-cmake-modules.git&a=blob&h=6cbafa2d&hb=5f60617c&f=modules%2FECMOptionalAddSubdirectory.cmake
Developers can use those options to build 3, 4, 5. Alternatively, document how to add the add_subdirectory() calls they need. If modules should also build standalone (as it seems), the way to do that is:
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
# Top-level build. Find dependencies.
find_package(Module1).
else()
# Built as a subdir together with depenendencies.
# Dependencies are already in scope.
endif()
2) I wrote this documentation for CMake 3.0, but most of it applies to 2.8:
http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html
You can probably add config files to your source containing something like
add_subdirectory(${CMAKE_CURRENT_LIST_DIR})
to get 'source packages' using find_package and manipulating your CMAKE_PREFIX_PATH.
3) There is no existing nuget cpack generator shipped with cmake. You may want to look into ExternalProject:
http://www.cmake.org/cmake/help/v3.0/module/ExternalProject.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With