Skip to content
Snippets Groups Projects
Commit 1d252cf4 authored by Dominic Kempf's avatar Dominic Kempf
Browse files

[CMake] Move the enable_all_packages feature to a separate module

The module DuneMacros.cmake is very crowded. Macros that are important
to end users and whose documentation should be clearly visible is
better placed in a separate file IMO. The new file is included from
DuneMacros.
parent 163e1f92
No related branches found
No related tags found
No related merge requests found
# This module provides the macros necessary for a simplified CMake build system
#
# The dune build system relies on the user to choose and add the compile and link flags
# necessary to build an executable. While this offers full control to the user, it
# is an error-prone procedure.
#
# Alternatively, users may use this modules macros to simply add the compile flags for all
# found external modules to all executables in a module. Likewise, all found libraries are
# linked to all targets.
#
# This module provides the following macros:
#
# dune_enable_all_packages()
#
# Adds all flags and all libraries to all executables that are added in the directory
# from where this macro is called and from all its subdirectories (recursively).
# Typically, a user would add the call to this macro to his top level CMakeLists.txt
macro(dune_enable_all_packages)
get_property(all_incs GLOBAL PROPERTY ALL_PKG_INCS)
include_directories(${all_incs})
get_property(all_libs GLOBAL PROPERTY ALL_PKG_LIBS)
link_libraries(${DUNE_LIBS} ${all_libs})
get_property(all_defs GLOBAL PROPERTY ALL_PKG_DEFS)
foreach(def ${all_defs})
add_definitions("-D${def}")
endforeach(def in ${all_defs})
endmacro(dune_enable_all_packages)
......@@ -79,6 +79,7 @@
enable_language(C) # Enable C to skip CXX bindings for some tests.
include(FeatureSummary)
include(DuneEnableAllPackages)
# Converts a module name given by _module into an uppercase string
# _upper where all dashes (-) are replaced by underscores (_)
......@@ -1155,15 +1156,3 @@ macro(add_dune_all_flags targets)
target_link_libraries(${target} ${DUNE_LIBS} ${libs})
endforeach()
endmacro(add_dune_all_flags targets)
# set includes, libraries and compile definitions for the entire project recursively
macro(dune_enable_all_packages)
get_property(all_incs GLOBAL PROPERTY ALL_PKG_INCS)
include_directories(${all_incs})
get_property(all_libs GLOBAL PROPERTY ALL_PKG_LIBS)
link_libraries(${DUNE_LIBS} ${all_libs})
get_property(all_defs GLOBAL PROPERTY ALL_PKG_DEFS)
foreach(def ${all_defs})
add_definitions("-D${def}")
endforeach(def in ${all_defs})
endmacro(dune_enable_all_packages)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment