]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Workaround: do not use object targets on Windows
authorMatthias Maier <tamiko@43-1.org>
Thu, 2 Mar 2023 14:54:40 +0000 (08:54 -0600)
committerMatthias Maier <tamiko@43-1.org>
Fri, 17 Mar 2023 12:44:53 +0000 (07:44 -0500)
This works around a CMake issue where we cannot export targets that have
a private dependency on object targets because they are erroneously
required to be exported...

source/CMakeLists.txt

index e2b766ec09373da0ee67f6a1027c457f287cf191..4f0ecbe6e8f8bf2710728bc4933303d309853bb1 100644 (file)
@@ -76,7 +76,15 @@ foreach(build ${DEAL_II_BUILD_TYPES})
   # Combine all ${build} OBJECT targets to a ${build} library:
   #
 
-  add_library(${DEAL_II_NAMESPACE}_${build_lowercase} dummy.cc)
+  set(_object_files "")
+  if(CMAKE_SYSTEM_NAME MATCHES "Windows")
+    get_property(_object_targets GLOBAL PROPERTY DEAL_II_OBJECT_TARGETS_${build})
+    foreach(_target ${_object_targets})
+      list(APPEND _object_files "$<TARGET_OBJECTS:${_target}>")
+    endforeach()
+  endif()
+
+  add_library(${DEAL_II_NAMESPACE}_${build_lowercase} dummy.cc ${_object_files})
   add_dependencies(library ${DEAL_II_NAMESPACE}_${build_lowercase})
 
   #
@@ -85,13 +93,15 @@ foreach(build ${DEAL_II_BUILD_TYPES})
   #
   populate_target_properties(${DEAL_II_NAMESPACE}_${build_lowercase} ${build})
 
-  #
-  # Add all object targets as private link targets
-  #
-  get_property(_object_targets GLOBAL PROPERTY DEAL_II_OBJECT_TARGETS_${build})
-  target_link_libraries(${DEAL_II_NAMESPACE}_${build_lowercase}
-    PRIVATE ${_object_targets}
-    )
+  if(NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
+    #
+    # Add all object targets as private link targets
+    #
+    get_property(_object_targets GLOBAL PROPERTY DEAL_II_OBJECT_TARGETS_${build})
+    target_link_libraries(${DEAL_II_NAMESPACE}_${build_lowercase}
+      PRIVATE ${_object_targets}
+      )
+    endif()
 
   set_target_properties(${DEAL_II_NAMESPACE}_${build_lowercase}
     PROPERTIES

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.