From: Matthias Maier Date: Thu, 26 Mar 2015 19:17:19 +0000 (+0100) Subject: CMake: Bugfix: Also set CXX_FLAGS in DEAL_II_SETUP_TARGET X-Git-Tag: v8.3.0-rc1~353^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8c90621ca84f84d66c507288f1f951f16b837ffe;p=dealii.git CMake: Bugfix: Also set CXX_FLAGS in DEAL_II_SETUP_TARGET --- diff --git a/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake b/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake index 9292456904..293727523f 100644 --- a/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake +++ b/cmake/macros/macro_deal_ii_initialize_cached_variables.cmake @@ -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." ) diff --git a/cmake/macros/macro_deal_ii_setup_target.cmake b/cmake/macros/macro_deal_ii_setup_target.cmake index 65b8dab69d..1016c2456c 100644 --- a/cmake/macros/macro_deal_ii_setup_target.cmake +++ b/cmake/macros/macro_deal_ii_setup_target.cmake @@ -21,8 +21,21 @@ # 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_}" +# +# LINK_FLAGS is appended with +# "${DEAL_II_LINKER_FLAGS ${DEAL_II_LINKER_FLAGS_}" +# +# COMPILE_DEFINITIONS is appended with +# "${DEAL_II_USER_DEFINITIONS};${DEAL_II_USER_DEFINITIONS_}" # # 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() #