]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Cosmetic: do not add link options to object targets
authorMatthias Maier <tamiko@43-1.org>
Fri, 3 Mar 2023 20:24:24 +0000 (14:24 -0600)
committerMatthias Maier <tamiko@43-1.org>
Fri, 17 Mar 2023 12:44:54 +0000 (07:44 -0500)
cmake/macros/macro_deal_ii_setup_target.cmake
cmake/macros/macro_insource_setup_target.cmake
cmake/macros/macro_populate_target_properties.cmake

index be7f763f38773685b0df78cf645548fbd2ee2a5b..f3304453179038217c4ac9964a62b265bedf2b81 100644 (file)
@@ -97,12 +97,15 @@ macro(deal_ii_setup_target _target)
     $<$<COMPILE_LANGUAGE:CXX>:${_compile_options}>
     )
 
-  separate_arguments(_link_options UNIX_COMMAND
-    "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
-    )
-  target_link_options(${_target} PRIVATE
-    $<$<COMPILE_LANGUAGE:CXX>:${_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
+      $<$<COMPILE_LANGUAGE:CXX>:${_link_options}>
+      )
+  endif()
 
   target_link_libraries(${_target} ${DEAL_II_TARGET_${_build}})
 endmacro()
index 6fa4e8627fe8c5be2f463ae534734e00c7fec54e..c67e83e747537c0ddc8dd4257cd1174caba66a83 100644 (file)
@@ -38,12 +38,15 @@ function(insource_setup_target _target _build)
     $<$<COMPILE_LANGUAGE:CXX>:${_compile_options}>
     )
 
-  separate_arguments(_link_options UNIX_COMMAND
-    "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
-    )
-  target_link_options(${_target} PRIVATE
-    $<$<COMPILE_LANGUAGE:CXX>:${_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
+      $<$<COMPILE_LANGUAGE:CXX>:${_link_options}>
+      )
+  endif()
 
   target_include_directories(${_target}
     PRIVATE
index 0a56dc294484974508b1781e6826ed2ba1b76889..bbfdc9f12a557c1499a4239b5b4d5a81e48e40a0 100644 (file)
@@ -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_LANGUAGE:CXX>:${_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()

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.