[CMake] Modern superbuild template including support for module dependencies
Taylor Braun-Jones
taylor at braun-jones.org
Mon Aug 17 10:43:46 EDT 2015
Hi all,
I'm looking for a template or example project that shows the how to
setup a cmake-based project in the cleanest and simplest way (i.e.
using all the latest features of 3.3 release) and with support for the
following build features:
- Superbuild mode that can be turned on or off (on by default)
- Simple system for defining modules (libraries that get built either
as static or dynamic libraries) and their dependencies.
- install target that works with good default behaviors so that the
CMakeLists.txt for modules and applications need minimal extra
configuration. Should work in both superbuild mode (the project and
all external projects get installed to the same
CMAKE_INSTALL_PREFIX/DESTDIR when invoked at the top superbuild level)
and in non-superbuild mode
I've seen many examples of projects like this but my impression is
that they have been around since long before the latest CMake releases
and therefore weren't designed to take advantage of all the latest
CMake features. My current attempt to setup a cmake-based build with
these features is based on the MITK cmake build system[1] since it's
something I was already familiar with. I have something that mostly
works, but the number of lines of cmake code to make it all happen
with simple interfaces like mitk_create_module, mitk_create_executable
seems more than should be necessary which is going to make switching
to CMake harder for me to "sell" to my team.
I found this very simplistic CMake project example[2] but the
resulting CMakeLists.txt to build an executable in that project looks
like this:
find_package (Threads REQUIRED)
set (Boost_USE_STATIC_LIBS ON)
# set (Boost_NO_SYSTEM_PATHS ON)
find_package (Boost 1.55.0 REQUIRED COMPONENTS date_time filesystem system)
include_directories (${Boost_INCLUDE_DIRS})
add_executable (blah
main.cpp)
target_link_libraries (blah
${Boost_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
Whereas I'm looking for something that would allow me to write
something like this:
xxx_add_executable(blah
PACKAGE_DEPENDS Boost
DEPENDS mymodule
main.cpp)
(or some other similarly simple interface)
Thanks in advance,
Taylor
[1] https://github.com/MITK/MITK
[2] https://github.com/Sarcasm/cmake-superbuild
More information about the CMake
mailing list