]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Some progress in the quest for sane compiler flags...
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 18 Sep 2012 19:37:57 +0000 (19:37 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 18 Sep 2012 19:37:57 +0000 (19:37 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@26481 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/contrib/cmake/setup_cached_compiler_flags.cmake
deal.II/contrib/cmake/setup_finalize.cmake

index d9df7c961b5499427b342c8c56e94b7ac05ce33b..700653081bd4bcfdc744bae141a845ccfea5255f 100644 (file)
 # process CMAKE_{C|CXX}_FLAGS are already set to stupid default values.
 # (And _cannot_ be sanely set from this script afterwards...)
 #
-# To mitigate this problem, we do the following: We set cached
-# CMAKE_{C|CXX}_FLAGS variables with empty strings prior to initializing
-# the compiler, so that no default values are set.
+# To mitigate this problem, we do the following:
 #
-# The compiler-flag setup in setup_compiler_flags.cmake later adds our
-# (target and platform dependend) default choice of flags.
+#   - We initialize the cached CMAKE_{C|CXX}_FLAGS variables with empty
+#     strings prior to initializing the compiler, so that no default values
+#     are set.
 #
-# We add the cached variables _to the end_ of this default choice to allow
-# the user to overwrite our choice of compiler flags.
+#   - We save the cached variables (possibly altered by the user via command
+#     line or ccmake) in <variable>_SAVED and set <variable> to an empty
+#     string.
+#
+#   - This way we can happily set our default flags in
+#     setup_compiler_flags.cmake (if the user lets us, see
+#     DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS)
+#
+#   - At the end of the configuration step we add <variables>_SAVED
+#     _AT THE END_ of the respective <variable> allowing the user to
+#     effectively overwrite our default setting.
 #
 
 
@@ -35,9 +43,11 @@ SET(CMAKE_BUILD_TYPE
 
 IF( NOT CMAKE_BUILD_TYPE MATCHES "Release" AND
     NOT CMAKE_BUILD_TYPE MATCHES "Debug" )
-
+  #
+  # This is cruel, I know. But it is better to only have a known number of
+  # options for CMAKE_BUILD_TYPE...
+  #
   MESSAGE(FATAL_ERROR "CMAKE_BUILD_TYPE does neither match Release, nor Debug.")
-
 ENDIF()
 
 
@@ -55,16 +65,19 @@ SET(deal_ii_used_flags
   )
 
 FOREACH(flags ${deal_ii_used_flags})
+  # "CACHE" ensures that we only set the variable if it is not already set
+  # as a  cached variable, effectively we're setting a default value:
   SET(${flags} "" CACHE STRING
    "The user supplied cache variable will be appended _at the end_ of the auto generated ${flags} variable"
    )
 
- #
# Save the cached variable at this point and clear it.
- # ${flags}_SAVED will be appended to ${flags} in
- # setup_cached_compiler_flags_finalize.cmake (called at the end of the
- # main CMakeLists.txt file).
- #
- SET(${flags}_SAVED "${${flags}}")
- SET(${flags} "")
 #
 # Save the initial (cached) variable at this point and clear it.
 # ${flags}_SAVED will be appended to ${flags} in
 # setup_cached_compiler_flags_finalize.cmake (called at the end of the
 # main CMakeLists.txt file).
 #
 SET(${flags}_SAVED "${${flags}}")
 SET(${flags} "")
 ENDFOREACH()
+
index e77a847a28fd87a27094021e95ed8cbd66d84ad1..5310a4a4039dbf8c09275ed680710f19f6779869 100644 (file)
@@ -1,13 +1,17 @@
 #
-# Append the saved cache variable ${flags}_SAVED at the end of ${flags}
+# Append the saved initial (cached) variables ${flags}_SAVED at the end of
+# ${flags}, see setup_cached_compiler_flags.cmake and the main
+# CMakeLists.txt for details.
 #
 FOREACH(flags ${deal_ii_used_flags})
   SET(${flags} "${${flags}} ${${flags}_SAVED}")
 ENDFOREACH()
 
+
 #
 # And print out a nice configuration summary:
 #
+
 MESSAGE("
 
     *                                        *

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.