]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: fix ENABLE_IF_LINKS
authorMatthias Maier <tamiko@43-1.org>
Thu, 17 Dec 2020 01:23:19 +0000 (19:23 -0600)
committerMatthias Maier <tamiko@43-1.org>
Thu, 17 Dec 2020 02:13:58 +0000 (20:13 -0600)
cmake/macros/macro_enable_if_links.cmake

index 1e024ca8432ed2ce581bce57098f9aa347825c69..bfcbe31a968d57d7f260d35e016ae73564088ac8 100644 (file)
 
 MACRO(ENABLE_IF_LINKS _variable _flag)
   STRING(STRIP "${_flag}" _flag_stripped)
+
   IF(NOT "${_flag_stripped}" STREQUAL "")
     STRING(REGEX REPLACE "^-" "" _flag_name "${_flag_stripped}")
-    STRING(REPLACE "," "" _flag_name "${_flag_name}")
-    STRING(REPLACE "-" "_" _flag_name "${_flag_name}")
-    STRING(REPLACE "+" "_" _flag_name "${_flag_name}")
+    STRING(REGEX REPLACE "\[-+,\]" "_" _flag_name "${_flag_name}")
+
     SET(_backup ${CMAKE_REQUIRED_LIBRARIES})
     LIST(APPEND CMAKE_REQUIRED_LIBRARIES "${_flag_stripped}")
-    CHECK_CXX_COMPILER_FLAG(
-      ""
-      DEAL_II_HAVE_FLAG_${_flag_name}
-      )
+    CHECK_CXX_SOURCE_COMPILES("int main(){}" DEAL_II_HAVE_LINKER_FLAG_${_flag_name})
     SET(CMAKE_REQUIRED_LIBRARIES ${_backup})
 
-    IF(DEAL_II_HAVE_FLAG_${_flag_name})
+    IF(DEAL_II_HAVE_LINKER_FLAG_${_flag_name})
       SET(${_variable} "${${_variable}} ${_flag_stripped}")
       STRING(STRIP "${${_variable}}" ${_variable})
     ENDIF()

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.