From 2801289591537121be2a9628ea8dd0eb3ccf3394 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 30 Nov 2022 14:24:49 -0600 Subject: [PATCH] CMake: update deal_ii_setup_target() macro --- cmake/macros/macro_deal_ii_setup_target.cmake | 61 ++++--------------- 1 file changed, 12 insertions(+), 49 deletions(-) diff --git a/cmake/macros/macro_deal_ii_setup_target.cmake b/cmake/macros/macro_deal_ii_setup_target.cmake index f6c0e44e31..9c6343587c 100644 --- a/cmake/macros/macro_deal_ii_setup_target.cmake +++ b/cmake/macros/macro_deal_ii_setup_target.cmake @@ -21,21 +21,9 @@ # deal_ii_setup_target(target) # deal_ii_setup_target(target DEBUG|RELEASE) # -# 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_DEFINITIONS};${DEAL_II_DEFINITIONS_}" +# This appends the deal.II target to the link interface of the specified +# target, which in turn ensures that necessary include directories, linker +# flags, compile flags and compile definitions are set. # # If no "DEBUG" or "RELEASE" keyword is specified after the target, the # current CMAKE_BUILD_TYPE is used instead. A CMAKE_BUILD_TYPE "Debug" is @@ -69,6 +57,7 @@ macro(deal_ii_setup_target _target) # Set build type with the help of the specified keyword, or # CMAKE_BUILD_TYPE: # + if("${ARGN}" MATCHES "^(DEBUG|RELEASE)$") set(_build "${ARGN}") elseif("${ARGN}" STREQUAL "") @@ -93,46 +82,20 @@ macro(deal_ii_setup_target _target) 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: + # We can only append the debug or release interface if deal.II was built + # with the Debug or DebugRelease build type. So test for this: # + if("${_build}" STREQUAL "DEBUG" AND NOT DEAL_II_BUILD_TYPE MATCHES "Debug") set(_build "RELEASE") endif() - if(CMAKE_CXX_COMPILER_ID MATCHES "Intel") - # Intel (at least up to 19.0.5) confuses an external TBB installation with - # our selected one if we use -Isystem includes. Work around this by using - # normal includes. - # See https://github.com/dealii/dealii/issues/8374 for details. - target_include_directories(${_target} PRIVATE ${DEAL_II_INCLUDE_DIRS}) - else() - target_include_directories(${_target} SYSTEM PRIVATE ${DEAL_II_INCLUDE_DIRS}) - endif() - - set_property(TARGET ${_target} APPEND_STRING PROPERTY - LINK_FLAGS " ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" + separate_arguments(_compile_options UNIX_COMMAND + "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}" ) - - set(_flags "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}") - - # Make sure some CUDA warning flags don't get deduplicated - string(REGEX REPLACE "(-Xcudafe --diag_suppress=[^ ]+)" "\"SHELL:\\1\"" _flags ${_flags}) - - separate_arguments(_flags UNIX_COMMAND ${_flags}) - - target_compile_options(${_target} PUBLIC ${_flags}) - - target_compile_definitions(${_target} - PUBLIC ${DEAL_II_DEFINITIONS} ${DEAL_II_DEFINITIONS_${_build}} + target_compile_options(${_target} PRIVATE + $<$:${_compile_options}> ) - # - # Set up the link interface: - # - get_property(_type TARGET ${_target} PROPERTY TYPE) - if(NOT "${_type}" STREQUAL "OBJECT_LIBRARY") - target_link_libraries(${_target} ${DEAL_II_TARGET_${_build}}) - endif() - + target_link_libraries(${_target} ${DEAL_II_TARGET_${_build}}) endmacro() -- 2.39.5