From: Matthias Maier Date: Thu, 17 Dec 2020 01:23:19 +0000 (-0600) Subject: CMake: fix ENABLE_IF_LINKS X-Git-Tag: v9.3.0-rc1~749^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=55b95ce11690ec8d5a86aa535e160e8acc3dbf49;p=dealii.git CMake: fix ENABLE_IF_LINKS --- diff --git a/cmake/macros/macro_enable_if_links.cmake b/cmake/macros/macro_enable_if_links.cmake index 1e024ca843..bfcbe31a96 100644 --- a/cmake/macros/macro_enable_if_links.cmake +++ b/cmake/macros/macro_enable_if_links.cmake @@ -24,20 +24,17 @@ 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()