From 7162a4943a2c1f2943e3a3479073432fd92cbb97 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Sat, 15 Dec 2018 11:38:56 +0100 Subject: [PATCH] Work around empty CMAKE_*_LIBRARY-*FIX --- cmake/config/CMakeLists.txt | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/cmake/config/CMakeLists.txt b/cmake/config/CMakeLists.txt index e16d77a111..5c851ff67f 100644 --- a/cmake/config/CMakeLists.txt +++ b/cmake/config/CMakeLists.txt @@ -246,6 +246,28 @@ ENDFOREACH() # export PKG_CONFIG_PATH=/path/to/INSTALL_DIR/lib/pkgconfig:$PKG_CONFIG_PATH # +# +# We need to gather some variables for the regex below to work. +# + +SET(_library_prefixes "") +IF (CMAKE_SHARED_LIBRARY_PREFIX) + LIST(APPEND _library_prefixes ${CMAKE_SHARED_LIBRARY_PREFIX}) +ENDIF() +IF (CMAKE_STATIC_LIBRARY_PREFIX) + LIST(APPEND _library_prefixes ${CMAKE_STATIC_LIBRARY_PREFIX}) +ENDIF() +STRING(REPLACE ";" "|" _library_prefixes "${_library_prefixes}") + +SET(_library_suffixes "") +IF (CMAKE_SHARED_LIBRARY_SUFFIX) + LIST(APPEND _library_suffixes ${CMAKE_SHARED_LIBRARY_SUFFIX}) +ENDIF() +IF (CMAKE_STATIC_LIBRARY_SUFFIX) + LIST(APPEND _library_suffixes ${CMAKE_STATIC_LIBRARY_SUFFIX}) +ENDIF() +STRING(REPLACE ";" "|" _library_suffixes "${_library_suffixes}") + # # Build up the link line from our list of libraries: # @@ -283,14 +305,12 @@ FOREACH(_build ${DEAL_II_BUILD_TYPES}) ENDIF() # Recover short name: - STRING(REGEX REPLACE - "^(${CMAKE_STATIC_LIBRARY_PREFIX}|${CMAKE_SHARED_LIBRARY_PREFIX})" - "" _name "${_name}" - ) - STRING(REGEX REPLACE - "(${CMAKE_STATIC_LIBRARY_SUFFIX}|${CMAKE_SHARED_LIBRARY_SUFFIX})$" - "" _name "${_name}" - ) + IF(_library_prefixes) + STRING(REGEX REPLACE "^(${_library_prefixes})" "" _name "${_name}") + ENDIF() + IF(_library_suffixes) + STRING(REGEX REPLACE "(${_library_suffixes})$" "" _name "${_name}") + ENDIF() SET(_library_string "${_library_string}-l${_name}") ENDIF() -- 2.39.5