From: Matthias Maier Date: Fri, 3 Mar 2023 20:24:24 +0000 (-0600) Subject: CMake: Cosmetic: do not add link options to object targets X-Git-Tag: v9.5.0-rc1~446^2~11 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3ecf1fd6e23da82dfe440cb9e84153bba58ff457;p=dealii.git CMake: Cosmetic: do not add link options to object targets --- diff --git a/cmake/macros/macro_deal_ii_setup_target.cmake b/cmake/macros/macro_deal_ii_setup_target.cmake index be7f763f38..f330445317 100644 --- a/cmake/macros/macro_deal_ii_setup_target.cmake +++ b/cmake/macros/macro_deal_ii_setup_target.cmake @@ -97,12 +97,15 @@ macro(deal_ii_setup_target _target) $<$:${_compile_options}> ) - separate_arguments(_link_options UNIX_COMMAND - "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" - ) - target_link_options(${_target} PRIVATE - $<$:${_link_options}> - ) + get_property(_type TARGET ${_target} PROPERTY TYPE) + if(NOT "${_type}" STREQUAL "OBJECT_LIBRARY") + separate_arguments(_link_options UNIX_COMMAND + "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" + ) + target_link_options(${_target} PRIVATE + $<$:${_link_options}> + ) + endif() target_link_libraries(${_target} ${DEAL_II_TARGET_${_build}}) endmacro() diff --git a/cmake/macros/macro_insource_setup_target.cmake b/cmake/macros/macro_insource_setup_target.cmake index 6fa4e8627f..c67e83e747 100644 --- a/cmake/macros/macro_insource_setup_target.cmake +++ b/cmake/macros/macro_insource_setup_target.cmake @@ -38,12 +38,15 @@ function(insource_setup_target _target _build) $<$:${_compile_options}> ) - separate_arguments(_link_options UNIX_COMMAND - "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" - ) - target_link_options(${_target} PRIVATE - $<$:${_link_options}> - ) + get_property(_type TARGET ${_target} PROPERTY TYPE) + if(NOT "${_type}" STREQUAL "OBJECT_LIBRARY") + separate_arguments(_link_options UNIX_COMMAND + "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" + ) + target_link_options(${_target} PRIVATE + $<$:${_link_options}> + ) + endif() target_include_directories(${_target} PRIVATE diff --git a/cmake/macros/macro_populate_target_properties.cmake b/cmake/macros/macro_populate_target_properties.cmake index 0a56dc2944..bbfdc9f12a 100644 --- a/cmake/macros/macro_populate_target_properties.cmake +++ b/cmake/macros/macro_populate_target_properties.cmake @@ -40,7 +40,7 @@ function(populate_target_properties _target _build) if(NOT "${_target}" MATCHES "^(object|bundled|${DEAL_II_NAMESPACE})_") message(FATAL_ERROR "Internal error: The specified target name must begin with object_, " - "bundled_, or ${DEAL_II_NAMESPACE}. Encountered: ${_target}" + "bundled_, or ${DEAL_II_NAMESPACE}_. Encountered: ${_target}" ) endif() @@ -51,11 +51,6 @@ function(populate_target_properties _target _build) set_target_properties(${_target} PROPERTIES LINKER_LANGUAGE "CXX") - target_link_libraries(${_target} ${_visibility} - ${DEAL_II_LIBRARIES} ${DEAL_II_LIBRARIES_${_build}} - ${DEAL_II_TARGETS} ${DEAL_II_TARGETS_${_build}} - ) - # # Include the current source directory of any target as private include # and add the contents of ${DEAL_II_INCLUDE_DIRS} as a public interface. @@ -95,7 +90,8 @@ function(populate_target_properties _target _build) ) # - # Add copmile and link options with private scope + # Add compile and link options with private scope, and add the link + # interface: # separate_arguments(_compile_options UNIX_COMMAND @@ -105,9 +101,16 @@ function(populate_target_properties _target _build) $<$:${_compile_options}> ) - separate_arguments(_link_options UNIX_COMMAND - "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" - ) - target_link_options(${_target} PRIVATE ${_link_options}) + get_property(_type TARGET ${_target} PROPERTY TYPE) + if(NOT "${_type}" STREQUAL "OBJECT_LIBRARY") + separate_arguments(_link_options UNIX_COMMAND + "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}" + ) + target_link_options(${_target} PRIVATE ${_link_options}) + endif() + target_link_libraries(${_target} ${_visibility} + ${DEAL_II_LIBRARIES} ${DEAL_II_LIBRARIES_${_build}} + ${DEAL_II_TARGETS} ${DEAL_II_TARGETS_${_build}} + ) endfunction()