cmake

The DUNE cmake setup

DUNE uses cmake to control its build process (creates makefiles).

By default, running the cmake on DUNE disables debugging. To enable this, add the '-DDEBUG=TRUE' flag when invoking cmake.

By default, the toolchain in 'dune/cmake/Toolchain.cmake' is used. An example of setting up an alternative toolchain is available at Ubuntu cross compiling with libraries.

External libraries is configured through the files at 'dune/cmake/Libraries'. These check if the respective library is available, and then adds the needed include directories with headers and linked libraries. In addition, they each set cmake flags like 'DUNE_USING_JPEG' or 'DUNE_SYS_HAS_JPEG'. These flags can then be used cmakefiles of individual tasks to ensure the task is only built if the required library was successfully included.

To reduce compile time and binary size, an option is to only build a selection of the tasks included with DUNE. This can be done by setting the TASK_FILE variable when invoking cmake, and pointing it towards a file containing calls to either dune_add_task or dune_add_tasks. Example call:

cmake -DTASK_FILE=../dune/user/taskFile.cmake ../dune

Example of content to put in the TASK_FILE:

dune_add_tasks(${PROJECT_SOURCE_DIR}/user/src)
dune_add_task(${PROJECT_SOURCE_DIR}/src Transports/Announce/Task.cmake)
  • cmake.txt
  • Last modified: 2022/09/19 11:34
  • by 127.0.0.1