From: maier
- This page provides details about deal.II CMake build system.
+ This page provides details about the CMake build system. Files
+ processed by the top level
@@ -26,12 +28,23 @@
Coding conventions are always a matter of choice. Nevertheless, the
following rules should be considered:
Details on the deal.II CMake build system
+ Build system internals
CMakeLists.txt
script are
+ listed in the TOC in cronological order.
@@ -39,6 +52,7 @@
+ Configuration:
+
+
+ Target definition and installation
+
Coding convention
+
@@ -119,6 +133,7 @@
leading "_". Local variables cannot be assumed to remain valid.
The may get overwritten at any time.
+
./include/deal.II/base/config.h.in<
./cmake/modules/Find*.cmake
+ These are find modules for the configure_*.cmake
files
+ and the CONFIGURE_FEATURE
macro as will explained later.
+ It is crucial that a find module behaves correctly. Therefore, the
+ following rules are mandatory:
FIND_LIBRARY
and
+ FIND_PATH
calls. The results of this calls should be the
+ only cached variables.
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS
should be used for
+ setting FEATURE_FOUND
as this already respects the
+ QUIET
and REQUIRED
keywords.
+ WARNING
, SEND_ERROR
or
+ FATAL_ERROR
must be avoided (the only exception is
+ the REQUIRED
keyword).
+ -
include/deal.II/base/config.h.in
should have a
- prominent comment explaining it and should be grouped by file
- exporting the definition
+ FEATURE_FOUND
+ FEATURE_LIBRARIES
+ FEATURE_INCLUDE_DIRS
+ FEATURE_LINKER_FLAGS
+
+ FEATURE_VERSION
+ FEATURE_VERSION_MAJOR
+ FEATURE_VERSION_MINOR
+ FEATURE_VERSION_SUBMINOR
+
+ There are obviously valid exceptions from this rule, though.
+ _<all lowercase>
" or
+ "global" variables prefixed by FEATURE_
may be
+ altered. Do not set DEAL_II_*
or CMAKE_*
+ variables directly!
+ ./cmake/configure/configure_*.cmake
+ The final step in the configuration phase is the setup of features + (which refer to external or bundled libraries + deal.II can optionally interface with.) + +
+ +
+ At bare minimum configure_<feature>.cmake
+ file for a feature just consists of a call to the
+ CONFIGURE_FEATURE(<FEATURE>)
macro which is
+ implemented in
+ ./cmake/macros/macro_configure_feature.cmake
.
+ In this case the corresponding Find<FEATURE>.cmake
+ module is used to determine whether an external dependency can be
+ resolved or not. Depending on the current state of
+ DEAL_II_WITH_<FEATURE>
(see
+ here) the variables
+
+ + FEATURE_LIBRARIES + FEATURE_INCLUDE_DIRS + FEATURE_LINKER_FLAGS ++ are appended to the set of global variables + and
DEAL_II_WITH_<FEATURE>
is set to
+ TRUE
.
+
+
+ + It is possible to override this default behaviour with the following + variables and macros (all of them are optional and will be replaced + by an appropriate default action if unset): +
<FEATURE>
means all caps,
+ <feature>
means all lowercase
+
+ ./cmake/configure/configure_<feature>.cmake
:
+ + + FEATURE_<FEATURE>_DEPENDS (a variable) + - a variable which contains an optional list of other features + this feature depends on (and which have to be enbled for this feature + to work.) The features must be given with the full option toggle: + DEAL_II_WITH_[...] + + FEATURE_<FEATURE>_FIND_EXTERNAL(var) (a macro) + - which should set var to TRUE if all dependencies for the feature are + fulfilled. In this case all necessary variables for + FEATURE_<FEATURE>_CONFIGURE_EXTERNAL must be set. + Otherwise var should remain unset. + If this macro is undefined, FIND_PACKAGE(<FEATURES>) is + called directly instead. + + FEATURE_<FEATURE>_CONFIGURE_EXTERNAL() (a macro) + - which should setup all necessary configuration for the feature with + external dependencies. If something goes wrong this macro must + issue a FATAL_ERROR. + If this macro is undefined, the information provided in + <FEATURES>_LIBRARIES, <FEATURES>_INCLUDE_DIRS and + <FEATURES>_LINKER_FLAGS is used for the build. + + FEATURE_<FEATURE>_CONFIGURE_BUNDLED() (a macro) + - which should setup all necessary configuration for the feature with + bundled source dependencies. If something goes wrong this macro must + issue a FATAL_ERROR. + + FEATURE_<FEATURE>_ERROR_MESSAGE() (macro) + - which should print a meaningful error message (with FATAL_ERROR) for + the case that no external library was found (and bundled is not + allowed to be used.) If not defined, a suitable default error message + will be printed. ++ +
./bundled/CMakeLists.txt
:
+ + + FEATURE_<FEATURE>_HAVE_BUNDLED (a boolean) + - which should either be set to TRUE if all necessary libraries of the + features comes bundled with deal.II and hence can be supported + without external dependencies, or unset. + + DEAL_II_FORCE_BUNDLED_<FEATURE> (an option) + - If <feature> can be set up by bundled libraries, this + configuration option must be present to force a use of bundled + dependencies ++ +
FEATURE_<FEATURE>_BUNDLED_CONFIGURED
is set to
+ TRUE
the file ./bundled/CMakeLists.txt
+ must compile and install the bundled package appropriately.
./include/deal.II/base/config.h.in
- TODO: This section is a bit outdated, update it! -
-
- For a feature <feature>
the following
- the following toggles, variables and macros can be defined
- defined (Note: <FEATURE>
means all caps,
- <feature>
means all lowercase):
+ In contrast to autoconf there is no intermediate step any more that
+ automatically generates config.h.in. The setup in this file has to be
+ done by hand. Please note:
config.h.in
should only contain a minimum of
+ necessary compile definitions to avoid unnecessary recompilation if
+ configuration changes.
+ config.h.in
should have a
+ prominent comment explaining it and should be grouped by file
+ exporting the definition.
+ cmake/configure/configure_<feature>.cmake
- defining how to configure <feature>
:
- - FEATURE_${feature}_DEPENDS (a variable) - - a variable which contains an optional list of other features - this feature depends on (and which have to be enbled for this feature - to work.) The features must be given with the full option toggle: - DEAL_II_WITH_[...] - - FEATURE_<FEATURE>_FIND_EXTERNAL(var) (a macro) - - which should set var to TRUE if all dependencies for the feature are - fulfilled. In this case all necessary variables for - FEATURE_<FEATURE>_CONFIGURE_EXTERNAL must be set. Otherwise - var should remain unset. - If not defined, FIND_PACKAGE(${feature}) is called. - - FEATURE_<FEATURE>_CONFIGURE_EXTERNAL() (a macro) - - which should setup all necessary configuration for the feature with - external dependencies. If something goes wrong this macro must - issue a FATAL_ERROR. - FEATURE_<FEATURE>_CONFIGURE_BUNDLED() (a macro) - - which should setup all necessary configuration for the feature with - bundled source dependencies. If something goes wrong this macro must - issue a FATAL_ERROR. + +- -- FEATURE_<FEATURE>_ERROR_MESSAGE() (macro, optional) - - which should print a meaningful error message (with FATAL_ERROR) for - the case that no external library was found (and bundled is not - allowed to be used.) If not defined, a suitable default error message - will be printed. -
./source/CMakeLists.txt
bundled/CMakeLists.txt
:
- +- - Setup of compilation and installation if -+ TODO +
- DEAL_II_FORCE_BUNDLED_<FEATURE> (a boolean) - - If <feature> can be set up by bundled libraries, this - configuration option must be present to force use of bundled - dependencies + +- FEATURE_<FEATURE>_HAVE_BUNDLED (a variable) - - which should either be set to TRUE if all necessary libraries of the - features comes bundled with deal.II and hence can be supported - without external dependencies, or unset. -
./cmake/config/CMakeLists.txt
FEATURE_<FEATURE>_BUNDLED_CONFIGURED
is set.
-
+ + TODO
+- deal.II CMake internals: + Build system internals: This page provides implementation and development details about the CMake build system.