]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Simplify CHECK_COMPILER_SETUP macro
authorMatthias Maier <tamiko@43-1.org>
Wed, 13 Jul 2016 14:41:16 +0000 (09:41 -0500)
committerMatthias Maier <tamiko@43-1.org>
Thu, 14 Jul 2016 00:46:25 +0000 (19:46 -0500)
cmake/macros/macro_check_compiler_setup.cmake
cmake/setup_compiler_flags.cmake
cmake/setup_finalize.cmake

index 69f813613aad13e9d93c358d262534a9b9dd90a3..85e3b984f2255ec1dac6019f25f1cb959d74ec79 100644 (file)
 
 #
 # Usage:
-#   CHECK_COMPILER_SETUP(
-#     _compiler_flags_variable _linker_flags_variable _var
+#   CHECK_COMPILER_SETUP("compiler flag string" "linker flag string" _var
 #     [libraries]
 #     )
 #
 # This macro tries to compile and link a simple "int main(){ return 0; }
-# with the given set of compiler and flags provided in
-# _compiler_flags_variable and _linker_flags_variable and an optional list
-# of libraries to link against. If the test is succesful the variable
-# ${_var} is set to true, otherwise to false.
+# with the given set of provided compiler and linker flags  and an optional
+# list of libraries to link against. If the test is succesful the variable
+# ${_var} is set to true, otherwise it is set to false.
 #
 
-MACRO(CHECK_COMPILER_SETUP _compiler_flags_variable _linker_flags_variable _var)
+MACRO(CHECK_COMPILER_SETUP _compiler_flags _linker_flags _var)
   #
   # Rerun this test if flags have changed:
   #
-  IF(NOT "${${_compiler_flags_variable}}" STREQUAL "${CACHED_${_var}_${_compiler_flags_variable}}"
-     OR NOT "${${_linker_flags_variable}}" STREQUAL "${CACHED_${_var}_${_linker_flags_variable}}"
+  IF(NOT "${_compiler_flags}" STREQUAL "${CACHED_${_var}_compiler_flags}"
+     OR NOT "${_linker_flags}" STREQUAL "${CACHED_${_var}_linker_flags}"
      OR NOT "${ARGN}" STREQUAL "${CACHED_${_var}_ARGN}")
     UNSET(${_var} CACHE)
   ENDIF()
 
-  SET(CACHED_${_var}_${_compiler_flags_variable} "${${_compiler_flags_variable}}"
+  SET(CACHED_${_var}_compiler_flags "${_compiler_flags}"
     CACHE INTERNAL "" FORCE
     )
-  SET(CACHED_${_var}_${_linker_flags_variable} "${${_linker_flags_variable}}"
+  SET(CACHED_${_var}_linker_flags "${_linker_flags}"
     CACHE INTERNAL "" FORCE
     )
   SET(CACHED_${_var}_ARGN "${ARGN}" CACHE INTERNAL "" FORCE)
 
-  SET(CMAKE_REQUIRED_FLAGS ${${_compiler_flags_variable}})
-  SET(CMAKE_REQUIRED_LIBRARIES ${${_linker_flags_variable}} ${ARGN})
+  SET(CMAKE_REQUIRED_FLAGS ${_compiler_flags})
+  SET(CMAKE_REQUIRED_LIBRARIES ${_linker_flags} ${ARGN})
+
   CHECK_CXX_SOURCE_COMPILES("int main(){ return 0; }" ${_var})
   RESET_CMAKE_REQUIRED()
 
index 12c5a10c0e70649e75c78a79ae60a0bec2f550e4..dd0459cb7a0c9b2d120ff9c346c4491ec83d2bf5 100644 (file)
 #
 
 FOREACH(build ${DEAL_II_BUILD_TYPES})
-  SET(_cxx_flags_${build} "${DEAL_II_CXX_FLAGS_SAVED} ${DEAL_II_CXX_FLAGS_${build}_SAVED}")
-  SET(_linker_flags_${build} "${DEAL_II_CXX_FLAGS_SAVED} ${DEAL_II_CXX_FLAGS_${build}_SAVED}")
-
-  CHECK_COMPILER_SETUP(_cxx_flags_${build} _linker_flags_${build}
+  CHECK_COMPILER_SETUP(
+    "${DEAL_II_CXX_FLAGS_SAVED} ${DEAL_II_CXX_FLAGS_${build}_SAVED}"
+    "${DEAL_II_LINKER_FLAGS_SAVED} ${DEAL_II_LINKER_FLAGS_${build}_SAVED}"
     DEAL_II_HAVE_USABLE_USER_FLAGS_${build}
     ${DEAL_II_LIBRARIES} ${DEAL_II_LIBRARIES_${build}}
     )
@@ -83,8 +82,8 @@ FOREACH(build ${DEAL_II_BUILD_TYPES})
   IF(NOT DEAL_II_HAVE_USABLE_USER_FLAGS_${build})
     MESSAGE(FATAL_ERROR "
   Configuration error: Cannot compile with the user supplied flags:
-    CXX flags (${build}): ${_cxx_flags_${build}}
-    LD flags  (${build}): ${_linker_flags_${build}}
+    CXX flags (${build}): ${DEAL_II_CXX_FLAGS_SAVED} ${DEAL_II_CXX_FLAGS_${build}_SAVED}
+    LD flags  (${build}): ${DEAL_II_LINKER_FLAGS_SAVED} ${DEAL_II_LINKER_FLAGS_${build}_SAVED}
     LIBRARIES (${build}): ${DEAL_II_LIBRARIES};${DEAL_II_LIBRARIES_${build}}
   Please check the CMake variables
     DEAL_II_CXX_FLAGS, DEAL_II_CXX_FLAGS_${build},
index 2b7d97703c2fd5e64037d7553c3543db633e18b9..4363738e8d328b60ce31debb15157ee1313a70fb 100644 (file)
@@ -84,10 +84,9 @@ ENDFOREACH()
 #
 
 FOREACH(build ${DEAL_II_BUILD_TYPES})
-  SET(_cxx_flags_${build} "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}")
-  SET(_linker_flags_${build} "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}")
-
-  CHECK_COMPILER_SETUP(_cxx_flags_${build} _linker_flags_${build}
+  CHECK_COMPILER_SETUP(
+    "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}"
+    "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}"
     DEAL_II_HAVE_USABLE_FLAGS_${build}
     ${DEAL_II_LIBRARIES} ${DEAL_II_LIBRARIES_${build}}
     )
@@ -96,8 +95,8 @@ FOREACH(build ${DEAL_II_BUILD_TYPES})
     MESSAGE(FATAL_ERROR "
   Configuration error: Cannot compile a test program with the final set of
   compiler and linker flags:
-    CXX flags (${build}): ${_cxx_flags_${build}}
-    LD flags  (${build}): ${_linker_flags_${build}}
+    CXX flags (${build}): ${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}
+    LD flags  (${build}): ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}
     LIBRARIES (${build}): ${DEAL_II_LIBRARIES};${DEAL_II_LIBRARIES_${build}}
   \n\n"
       )

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.