]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Test link inteface again
authorDaniel Arndt <arndtd@ornl.gov>
Thu, 20 Apr 2023 20:28:37 +0000 (16:28 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Thu, 20 Apr 2023 20:32:12 +0000 (16:32 -0400)
CMakeLists.txt
cmake/macros/macro_define_interface_target.cmake
cmake/setup_finalize.cmake

index d63ad2b95580970bf12664c1fb5f6b8874b684c8..183c858f9e8de054364fdfe6a6cd2b7c22143094 100644 (file)
@@ -111,8 +111,6 @@ foreach(_file ${_check_files})
   verbose_include(${_file})
 endforeach()
 
-verbose_include(${CMAKE_SOURCE_DIR}/cmake/setup_finalize.cmake)
-
 #
 # Feature configuration:
 #
@@ -122,6 +120,8 @@ foreach(_file ${_configure_files})
   verbose_include(${_file})
 endforeach()
 
+verbose_include(${CMAKE_SOURCE_DIR}/cmake/setup_finalize.cmake)
+
 verbose_include(${CMAKE_SOURCE_DIR}/cmake/setup_cpack.cmake)
 verbose_include(${CMAKE_SOURCE_DIR}/cmake/setup_custom_targets.cmake)
 
index d4b908f667bd639d91463d3842b76f20dbfa0a28..9569c79447f9425b8b6f46c8274eee8f4dca2c02 100644 (file)
@@ -144,10 +144,14 @@ function(define_interface_target _feature)
       # Future FIXME: change to block(PARENT_SCOPE)/endblock() (CMake 3.25)
       list(APPEND DEAL_II_TARGETS_${_build} "${_interface_target}")
       set(DEAL_II_TARGETS_${_build} ${DEAL_II_TARGETS_${_build}} PARENT_SCOPE)
+      list(APPEND DEAL_II_LIBRARIES_${_build} "${_libraries}")
+      set(DEAL_II_LIBRARIES_${build} ${DEAL_II_LIBRARIES_${build}} PARENT_SCOPE)
     else()
       # Future FIXME: change to block(PARENT_SCOPE)/endblock() (CMake 3.25)
       list(APPEND DEAL_II_TARGETS "${_interface_target}")
       set(DEAL_II_TARGETS ${DEAL_II_TARGETS} PARENT_SCOPE)
+      list(APPEND DEAL_II_LIBRARIES "${_libraries}")
+      set(DEAL_II_LIBRARIES ${DEAL_II_LIBRARIES} PARENT_SCOPE)
     endif()
 
   endforeach()
index 6ab2f2890f8c3a7635e566b5a0b8b509800659f0..20600b39525e0051394a30678008d4196e2df596 100644 (file)
@@ -55,12 +55,64 @@ endforeach()
 #
 
 foreach(build ${DEAL_II_BUILD_TYPES})
-  check_compiler_setup(
-    "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}"
-    "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}"
-    DEAL_II_HAVE_USABLE_FLAGS_${build}
-    ${DEAL_II_LIBRARIES} ${DEAL_II_LIBRARIES_${build}}
-    )
+  macro(_check_linker_flags)
+    check_compiler_setup(
+      "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}"
+      "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}"
+      DEAL_II_HAVE_USABLE_FLAGS_${build}
+      ${DEAL_II_LIBRARIES} ${DEAL_II_LIBRARIES_${build}}
+      )
+  endmacro()
+
+  macro(_drop_linker_flag _linker_flag _replacement_flag _variable)
+    message(STATUS
+      "Unable to compile a simple test program. "
+      "Trying to drop \"${_linker_flag}\" from the linker flags."
+      )
+    foreach(_flags
+        DEAL_II_LINKER_FLAGS DEAL_II_LINKER_FLAGS_${build}
+        BASE_LINKER_FLAGS BASE_LINKER_FLAGS_${build}
+        )
+      string(REPLACE "${_linker_flag}" "${_replacement_flag}"
+        ${_flags} "${${_flags}}"
+        )
+    endforeach()
+    set(${_variable} FALSE CACHE INTERNAL "" FORCE)
+    set(${_variable} FALSE)
+  endmacro()
+
+  _check_linker_flags()
+
+  if(NOT DEAL_II_HAVE_USABLE_FLAGS_${build} AND DEAL_II_COMPILER_HAS_FUSE_LD_LLD)
+    set(_replacement "")
+    if(DEAL_II_COMPILER_HAS_FUSE_LD_GOLD)
+      set(_replacement "-fuse-ld=gold")
+    endif()
+    _drop_linker_flag(
+      "-fuse-ld=lld" ${_replacement}
+      DEAL_II_COMPILER_HAS_FUSE_LD_LLD
+      )
+    _check_linker_flags()
+  endif()
+
+  if(NOT DEAL_II_HAVE_USABLE_FLAGS_${build} AND DEAL_II_COMPILER_HAS_FUSE_LD_GOLD)
+    _drop_linker_flag(
+      "-fuse-ld=gold" ""
+      DEAL_II_COMPILER_HAS_FUSE_LD_GOLD
+      )
+    _check_linker_flags()
+  endif()
+
+  if(NOT DEAL_II_HAVE_USABLE_FLAGS_${build})
+    message(FATAL_ERROR "
+  Configuration error: Cannot compile a test program with the final set of
+  compiler and linker flags:
+    CXX flags (${build}): ${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${build}}
+    LD flags  (${build}): ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${build}}
+    LIBRARIES (${build}): ${DEAL_II_LIBRARIES};${DEAL_II_LIBRARIES_${build}}
+  \n\n"
+      )
+  endif()
 endforeach()
 
 #

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.