From 8798c75ed3328ae7eb5d52a75bc199bc5675b98b Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Thu, 2 Mar 2023 08:54:40 -0600 Subject: [PATCH] CMake: Workaround: do not use object targets on Windows 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 | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index e2b766ec09..4f0ecbe6e8 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -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 "$") + 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 -- 2.39.5