]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Bugfix: Also set CXX_FLAGS in DEAL_II_SETUP_TARGET 692/head
authorMatthias Maier <tamiko@43-1.org>
Thu, 26 Mar 2015 19:17:19 +0000 (20:17 +0100)
committerMatthias Maier <tamiko@43-1.org>
Thu, 26 Mar 2015 19:47:54 +0000 (20:47 +0100)
cmake/macros/macro_deal_ii_initialize_cached_variables.cmake
cmake/macros/macro_deal_ii_setup_target.cmake

index 9292456904fff07a49a55f8907e070090b0452e2..293727523f9bda5949d26d148fa090978af5cae1 100644 (file)
@@ -86,15 +86,15 @@ MACRO(DEAL_II_INITIALIZE_CACHED_VARIABLES)
   SET(CMAKE_CXX_COMPILER ${DEAL_II_CXX_COMPILER} CACHE STRING
     "CXX Compiler.")
 
-  SET(CMAKE_CXX_FLAGS ${DEAL_II_CXX_FLAGS} CACHE STRING
+  SET(CMAKE_CXX_FLAGS "" CACHE STRING
     "Flags used by the compiler during all build types."
     )
 
-  SET(CMAKE_CXX_FLAGS_DEBUG ${DEAL_II_CXX_FLAGS_DEBUG} CACHE STRING
+  SET(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING
     "Flags used by the compiler during debug builds."
     )
 
-  SET(CMAKE_CXX_FLAGS_RELEASE ${DEAL_II_CXX_FLAGS_RELEASE} CACHE STRING
+  SET(CMAKE_CXX_FLAGS_RELEASE "" CACHE STRING
     "Flags used by the compiler during release builds."
     )
 
index 65b8dab69d59a6c5c722340c813745dfcf855a3e..1016c2456c3ac4375e15d06b3dc40c16a5221c29 100644 (file)
 #       DEAL_II_SETUP_TARGET(target)
 #       DEAL_II_SETUP_TARGET(target DEBUG|RELEASE)
 #
-# This appends necessary include directories, linker flags, compile
-# definitions and the deal.II library link interface to the given target.
+# This appends necessary include directories, linker flags, compile flags
+# and compile definitions and the deal.II library link interface to the
+# given target. In particular:
+#
+# INCLUDE_DIRECTORIES is appended with
+#   "${DEAL_II_INCLUDE_DIRS}"
+#
+# COMPILE_FLAGS is appended with
+#   "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_<build type>}"
+#
+# LINK_FLAGS is appended with
+#   "${DEAL_II_LINKER_FLAGS ${DEAL_II_LINKER_FLAGS_<build type>}"
+#
+# COMPILE_DEFINITIONS is appended with
+#   "${DEAL_II_USER_DEFINITIONS};${DEAL_II_USER_DEFINITIONS_<build type>}"
 #
 # If no "DEBUG" or "RELEASE" keyword is specified after the target, the
 # current CMAKE_BUILD_TYPE determines which compiler and linker flags as
@@ -52,71 +65,50 @@ MACRO(DEAL_II_SETUP_TARGET _target)
   # Necessary for setting INCLUDE_DIRECTORIES via SET_PROPERTY
   CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
 
-  #
-  # Append include directories, and build-type independent linker flags and
-  # compile definitions
-  #
-  SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
-    INCLUDE_DIRECTORIES "${DEAL_II_INCLUDE_DIRS}"
-    )
-  SET_PROPERTY(TARGET ${_target} APPEND_STRING PROPERTY
-    LINK_FLAGS " ${DEAL_II_LINKER_FLAGS}"
-    )
-  SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
-    COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS}"
-    )
-
-  #
-  # Append build type dependent flags and definitions.
   #
   # Every build type that (case insensitively) matches "debug" is
   # considered a debug build:
   #
-  SET(_on_debug_build FALSE)
+  SET(_build "RELEASE")
   STRING(TOLOWER "${CMAKE_BUILD_TYPE}" _cmake_build_type)
   IF("${_cmake_build_type}" MATCHES "debug")
-    SET(_on_debug_build TRUE)
+    SET(_build "DEBUG")
   ENDIF()
 
   #
   # Override _on_debug_build if ${ARGN} is set:
   #
-  IF("${ARGN}" MATCHES "^DEBUG$")
-    SET(_on_debug_build TRUE)
-  ELSEIF ("${ARGN}" MATCHES "^RELEASE$")
-    SET(_on_debug_build FALSE)
+  IF("${ARGN}" MATCHES "^(DEBUG|RELEASE)$")
+    SET(_build "${ARGN}")
   ENDIF()
 
   #
   # We can only append DEBUG link flags and compile definitions if deal.II
   # was built with the Debug or DebugRelease build type. So test for this:
   #
-  IF(_on_debug_build AND DEAL_II_BUILD_TYPE MATCHES "Debug")
-    SET_PROPERTY(TARGET ${_target} APPEND_STRING PROPERTY
-      LINK_FLAGS " ${DEAL_II_LINKER_FLAGS_DEBUG}"
-      )
-    SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
-      COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS_DEBUG}"
-      )
-  ELSE()
-    SET_PROPERTY(TARGET ${_target} APPEND_STRING PROPERTY
-      LINK_FLAGS " ${DEAL_II_LINKER_FLAGS_RELEASE}"
-      )
-    SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
-      COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS_RELEASE}"
-      )
+  IF("${_build}" STREQUAL "DEBUG" AND NOT DEAL_II_BUILD_TYPE MATCHES "Debug")
+    SET(_build "RELEASE")
   ENDIF()
 
+  SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
+    INCLUDE_DIRECTORIES "${DEAL_II_INCLUDE_DIRS}"
+    )
+  SET_PROPERTY(TARGET ${_target} APPEND_STRING PROPERTY
+    COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
+    )
+  SET_PROPERTY(TARGET ${_target} APPEND_STRING PROPERTY
+    LINK_FLAGS " ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
+    )
+  SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
+    COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS};${DEAL_II_USER_DEFINITIONS_${_build}}"
+    )
+
   #
   # Set up the link interface:
   #
   GET_PROPERTY(_type TARGET ${_target} PROPERTY TYPE)
   IF(NOT "${_type}" STREQUAL "OBJECT_LIBRARY")
-    IF(_on_debug_build AND DEAL_II_BUILD_TYPE MATCHES "Debug")
-      TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET_DEBUG})
-    ELSE()
-      TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET_RELEASE})
-    ENDIF()
+    TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET_${_build}})
   ENDIF()
 
   #

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.