]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Add a comment
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 13 Sep 2012 09:59:30 +0000 (09:59 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 13 Sep 2012 09:59:30 +0000 (09:59 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@26343 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/CMakeLists.txt
deal.II/contrib/cmake/configure/configure_build.cmake

index 805dc8f3461a31be054ec58ceec2c7fa7da8a52a..3271176ba659bec0cc5d7e8b3c36dde3a920a6bd 100644 (file)
@@ -44,8 +44,21 @@ SET(VERSION "8.0.pre")
 # We support the "Debug" and "Release" build types. Default is the
 # "Release" target.
 #
-# TODO: Explanation
+# Debug will enable a lot of debug code paths and Assertions, as well as
+# compiling the library with a suitable set of debug compiler flags.
 #
+# Release will chose a suitable set of optimizing flags.
+#
+# The default CXXFLAGS (and CFLAGS) are stored in the following cached
+# variables (as is common practise for cmake):
+#
+#   CMAKE_CXX_FLAGS         -  used during all builds
+#   CMAKE_CXX_FLAGS_DEBUG   -  additional flags used during debug builds
+#   CMAKE_CXX_FLAGS_RELEASE -  additional flags used during release builds
+#
+#   (same for CMAKE_C_...)
+#
+
 
 #
 # General configuration options:
@@ -135,19 +148,18 @@ SET(CMAKE_MODULE_PATH
   "${CMAKE_SOURCE_DIR}/contrib/cmake/modules/"
   )
 
-# We have to initialize this cached variable before PROJECT is called:
-IF(CMAKE_BUILD_TYPE)
-  SET(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING
-    "Choose the type of build, options are: Debug Release.")
-ELSE()
-  SET(CMAKE_BUILD_TYPE Release CACHE STRING
-    "Choose the type of build, options are: Debug Release.")
-ENDIF()
+#
+# We have to initialize some cached variable before PROJECT is called, so
+# configure the cached, user editable CMAKE_BUILD_TYPES, CMAKE_CXX_FLAGS,
+# etc. variables at this point:
+#
+INCLUDE(configure_build)
 
+#
+# Now, set the project:
+#
 PROJECT(deal.II)
 
-
-
 #
 # Set up deal.II specific variables
 #
@@ -176,12 +188,6 @@ ADD_CUSTOM_TARGET(deal_ii_target_dependencies)
 SET(deal_ii_external_libraries "")
 SET(deal_ii_required_linker_flags "")
 
-#
-# Configuration for CMAKE_BUILD_TYPES (CFLAGS, CXXFLAGS, ..)
-#
-
-INCLUDE(configure_build)
-
 #
 # Platform checks:
 #
index 3d0847795d263e9d14ced182c963680bf2d43b09..67f1047b6ac9cb9aa6da8e98ff2dffb372b014ca 100644 (file)
@@ -1,11 +1,72 @@
 #
-# Setup the build type and compiler flags
+# FAT NOTE:
 #
+# We set up the default compiler configuration, i.e. CMAKE_BUILD_TYPE,
+# CMAKE_C_FLAGS, CMAKE_CXX_FLAGS as CACHED variables, so that the user can
+# actually see and change them.
+#
+# Beware of the fact that compiler flags set later in the configuration via
+# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} <...>" are UNCACHED variables.
+#
+# cmake later concatenates cached and uncached variables together. So for a
+# release build we will end up with (more or less) something like the
+# following:
+#
+# $ <compiler>  <cached CMAKE_CXX_FLAGS> <uncached CMAKE_CXX_FLAGS> \
+#      <cached CMAKE_CXX_FLAGS_RELEASE> <uncached CMAKE_CXX_FLAGS_RELEASE>\
+#      <Definitions> <...>     <...>.c     -o <...>.o
+#
+
+
+#
+# Setup CMAKE_BUILD_TYPE:
+#
+
+SET(CMAKE_BUILD_TYPE
+  "Release"
+  CACHE STRING
+  "Choose the type of build, options are: Debug Release.")
+
+IF( NOT CMAKE_BUILD_TYPE MATCHES "Release" AND
+    NOT CMAKE_BUILD_TYPE MATCHES "Debug" )
+
+  MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE does neither match Release, nor Debug.")
+
+ENDIF()
+
+
+#
+# Setup default compiler flags:
+#
+
+# TODO: Copy the CFLAGS and CXXFLAGS logic from the former build system
+
+SET(CMAKE_C_FLAGS
+  "-Wfatal-errors -D_REENTRANT -fPIC -O2 -march=native"
+  CACHE STRING
+  "Flags used by the compiler during all build types.")
 
+SET(CMAKE_CXX_FLAGS
+  "-Wfatal-errors -D_REENTRANT -fPIC -O2 -march=native"
+  CACHE STRING
+  "Flags used by the compiler during all build types.")
 
 
-#TODO:
+SET(CMAKE_C_FLAGS_RELEASE
+  "-O2"
+  CACHE STRING
+  "Flags used by the compiler during all release builds.")
+SET(CMAKE_CXX_FLAGS_RELEASE
+  "-O2"
+  CACHE STRING
+  "Flags used by the compiler during all release builds.")
 
-SET(CMAKE_CXX_FLAGS "-Wfatal-errors -D_REENTRANT -fPIC -O2 -march=native")
-SET(CMAKE_C_FLAGS "-Wfatal-errors -D_REENTRANT -fPIC -O2 -march=native")
 
+SET(CMAKE_C_FLAGS_DEBUG
+  "-O0 -ggdb -DDEBUG"
+  CACHE STRING
+  "Flags used by the compiler during all debug builds.")
+SET(CMAKE_CXX_FLAGS_DEBUG
+  "-O0 -ggdb -DDEBUG"
+  CACHE STRING
+  "Flags used by the compiler during all debug builds.")

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.