From b026976a7f779de8c05d1c910142356d95ab3473 Mon Sep 17 00:00:00 2001 From: maier Date: Mon, 11 Mar 2013 18:16:02 +0000 Subject: [PATCH] CMake: Write cmake-internals.html, first part git-svn-id: https://svn.dealii.org/trunk@28857 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/cmake/TODO.CMAKE | 1 + .../cmake/checks/check_01_cpu_features.cmake | 7 +- deal.II/cmake/setup_compiler_flags.cmake | 27 +- deal.II/cmake/setup_deal_ii.cmake | 6 +- deal.II/doc/development/cmake-internals.html | 395 +++++++++++++----- deal.II/doc/development/cmake.html | 2 +- 6 files changed, 326 insertions(+), 112 deletions(-) diff --git a/deal.II/cmake/TODO.CMAKE b/deal.II/cmake/TODO.CMAKE index e618954267..cb04643b67 100644 --- a/deal.II/cmake/TODO.CMAKE +++ b/deal.II/cmake/TODO.CMAKE @@ -2,6 +2,7 @@ Major: * Mumps may have a transitive link interface to Scotch. Fix this +* Get rid of the last bits of unguarded platform introspection Some last bits and thoughts: diff --git a/deal.II/cmake/checks/check_01_cpu_features.cmake b/deal.II/cmake/checks/check_01_cpu_features.cmake index 805ab22797..0a554300cc 100644 --- a/deal.II/cmake/checks/check_01_cpu_features.cmake +++ b/deal.II/cmake/checks/check_01_cpu_features.cmake @@ -27,9 +27,10 @@ # DEAL_II_HAVE_AVX *) # DEAL_II_COMPILER_VECTORIZATION_LEVEL # -# Note: It is possible to disable the platform introspection tests (e.g. -# for cross compiling or for packaging) by defining the variables (*) in -# the cache prior to configure +# *) +# It is is possible to manually set the above values to their corresponding +# values, when platform introspection is disabled with +# DEAL_II_ALLOW_PLATFORM_INTROSPECTION=OFF, # diff --git a/deal.II/cmake/setup_compiler_flags.cmake b/deal.II/cmake/setup_compiler_flags.cmake index a5e3b7fdf3..85a4eca2c0 100644 --- a/deal.II/cmake/setup_compiler_flags.cmake +++ b/deal.II/cmake/setup_compiler_flags.cmake @@ -32,18 +32,33 @@ # DEAL_II_SHARED_LINKER_FLAGS_DEBUG # DEAL_II_SHARED_LINKER_FLAGS_RELEASE # +# All modifications shall be guarded with the ENABLE_IF_SUPPORTED +# or ENABLE_IF_LINKS macro, e.g. +# +# ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-fpic") +# ENABLE_IF_LINKS(CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed") +# +# Compiler flags for platform dependent optimization (such as +# -march=native) must always be guarded with +# DEAL_II_ALLOW_PLATFORM_INTROSPECTION: +# +# IF(DEAL_II_ALLOW_PLATFORM_INTROSPECTION) +# ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS "-march=native") +# ENDIF() # # Checks for compiler features (such as C++11 support) and compiler # specific bugs that -# - usually set up further configuration (such as definitions) +# - usually set up further configuration (such as preprocessor +# definitions) # - disable a specific flag for a specific compiler version. # -# belong to +# belong the corresponding file: # -# ./check/check_for_compiler_features.cmake -# ./check/check_for_compiler_bugs.cmake -# ./check/check_for_compiler_bugs_*.cmake -# ./check/check_for_cxx_features.cmake +# ./cmake/checks/check_01_compiler_features.cmake +# ./cmake/checks/check_01_cpu_features.cmake +# ./cmake/checks/check_01_cxx_features.cmake +# ./cmake/checks/check_01_system_features.cmake +# ./cmake/checks/check_02_compiler_bugs.cmake # diff --git a/deal.II/cmake/setup_deal_ii.cmake b/deal.II/cmake/setup_deal_ii.cmake index 3a268de61b..46bdf971b9 100644 --- a/deal.II/cmake/setup_deal_ii.cmake +++ b/deal.II/cmake/setup_deal_ii.cmake @@ -16,7 +16,11 @@ # Set up deal.II specific definitions # # This file defines a long list of uncached variables, used throughout the -# configuration to determine paths, locations and names: +# configuration to determine paths, locations and names. +# +# Definitions marked with *) can be overriden by defining them to cache +# prior to the call of this file. This is done with the help of the +# SET_IF_EMPTY macro. # # General information about deal.II: # diff --git a/deal.II/doc/development/cmake-internals.html b/deal.II/doc/development/cmake-internals.html index 48681a9a5e..cfb2cdb2a5 100644 --- a/deal.II/doc/development/cmake-internals.html +++ b/deal.II/doc/development/cmake-internals.html @@ -25,24 +25,308 @@ Table of contents

- -

Developing the deal.II CMake system

+ +

Coding convention

+ Coding conventions are always a matter of choice. Nevertheless, the + following rules should be considered: + + An example: +
+
+    FOREACH(_build ${DEAL_II_BUILD_TYPES})
+      #
+      # Set an appropriate keyword depending on target and build type:
+      #
+      IF(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "DebugRelease")
+        SET(_keyword "general")
+      ELSE()
+        IF(_build MATCHES DEBUG)
+          SET(_keyword "debug")
+        ELSE()
+          SET(_keyword "optimized")
+        ENDIF()
+      ENDIF()
+    ENDFOREACH()
+      
+ +
+
+    LIST(APPEND CONFIG_LIBRARIES
+      ${_keyword}
+      ${CONFIG_LIBRARIES_${_build}}
+      )
+
+    SET_TARGET_PROPERTIES(${DEAL_II_BASE_NAME}${DEAL_II_${build}_SUFFIX}
+      PROPERTIES
+      VERSION ${VERSION}
+      SOVERSION ${VERSION}
+      LINK_FLAGS "${DEAL_II_SHARED_LINKER_FLAGS_${build}}"
+      COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${build}}"
+      COMPILE_FLAGS "${DEAL_II_CXX_FLAGS_${build}}"
+      )
+      
+ CMake operates almost always with variables in global state. To guard + against accidential overwrite of variables the following naming + conventions must be followed at all times: + + + + +

./CMakeLists.txt and ./cmake/setup_*.cmake

+ +

+ The very first configuration steps after some initial setup in + ./CMakeLists.txt takes place in some + ./cmake/setup_*.cmake files: +

+

+ + + +

./cmake/checks/check_*.cmake

+ +

+ The next step in the configuration process is to include all + checks residing under ./cmake/checks. Currently + there are: +

+
+    ./cmake/checks/check_01_compiler_features.cmake
+      - Search for support for compiler dependent features such as stack
+        trace support, demangler support, etc.
+
+    ./cmake/checks/check_01_cpu_features.cmake
+      - Platform introspection for CPU features goes here and must be
+        guarded with DEAL_II_ALLOW_PLATFORM_INTROSPECTION
+
+    ./cmake/checks/check_01_cxx_features.cmake
+      - Check for supported C++ language features such as sufficient C++11
+        support
+
+    ./cmake/checks/check_01_system_features.cmake
+      - Checks for specific platform (Linux/Darwin/CYGWIN/Windows..)
+        features and support
+
+    ./cmake/checks/check_02_compiler_bugs.cmake
+      - Check for compiler bugs
+      
+ +

+ + + + +

./include/deal.II/base/config.h.in<

+ + + + + +

Global variables controlling the build process

- To keep things clean, only the following variables should be - appended in the platform checks and feature configuration (beside - setting a lot of DEAL_II_* definitions...): + The following list describes all global variables controlling the + build process and the visibility associated with it (internal use for + compiling deal.Ii, externally used variables will get exported in + deal.IIConfig.cmake). Lists should be manipulated with + LIST(APPEND ...), flags with ADD_FLAGS(...) + (or if it is necessary to guard them with + ENABLE_IF_SUPPORTED(...).)

- -

Advanced setup

- - A sample configuration file for preloading the CMake cache with -
-
-    $ cmake -C Config.sample <...>
-    
- can be found here. - This sample configuration covers all options mentioned in this - documentation as well as some advanced aspects in feature - configuration. -
diff --git a/deal.II/doc/development/cmake.html b/deal.II/doc/development/cmake.html index 3be691b8ee..f110dded55 100644 --- a/deal.II/doc/development/cmake.html +++ b/deal.II/doc/development/cmake.html @@ -148,7 +148,7 @@ It is possible to use -U together with a globbing expression. E.g. to remove the current feature configuration and - rerun the autodetection on can invoke + rerun the autodetection one can invoke
 
     cmake -U"DEAL_II_WITH_*" .
-- 
2.39.5