[CMake] Modern superbuild template including support for

Andrey Pokrovskiy wonder.mice at gmail.com
Thu Aug 20 15:29:56 EDT 2015


Such approach doesn't work with IDE. For example, when I open main
CMakeLists.txt in Qt Creator I only see two *.cmake files. Superbuilds
use ExternalProject_Add() which kills a lot CMake benefits when used
for CMake project from CMake project.

On Thu, Aug 20, 2015 at 9:28 AM, Knox, Kent <Kent.Knox at amd.com> wrote:
>> 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:
>
> I waited a few days to see if anybody else would volunteer their project,
> but I'm happy to ask for critique of the superbuild approach I set up
> recently.  This is for an opencl sparse matrix library:
> https://github.com/clMathLibraries/clSPARSE
> Build instructions:
> https://github.com/clMathLibraries/clSPARSE/wiki/Build
>
> I think I only require features up to 2.8.12.
> I have 2 dependencies that I configure/build with the superbuild:
> boost & googlemock.  The main clsparse library is also set up as an
> external dependency, so that it could be used independently.
>
> The root CMakeLists.txt file defines the superbuild, the cmake/External*.cmake
> files house the ExternalProject_Add() commands, and the library/CMakeLists.txt
> defines the library build.
>
> Would welcome comments/critiques from anybody with time.
>
> Kent
> ----------------------------------------------------------------------
> Message: 6
> Date: Mon, 17 Aug 2015 10:43:46 -0400
> From: Taylor Braun-Jones <taylor at braun-jones.org>
> To: cmake <cmake at cmake.org>
> Subject: [CMake] Modern superbuild template including support for
>         module  dependencies
> Message-ID:
>         <CAKfKJYsaaXnhrGpXA7UXN7ncYkwPir3XhHL51hNGkWZZ9YU+4Q at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> 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
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list