From 468d97e9d502957ace4a5acb5a344a2680b213b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Micha=C3=ABl=20Celerier?= Date: Sat, 18 Nov 2023 16:54:03 +0100 Subject: [PATCH] [cmake] Fix linking of the cmake target to re2 in static linking --- cmake/OssiaConfiguration.cmake | 4 ++-- cmake/ossiaConfig.cmake.in | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/cmake/OssiaConfiguration.cmake b/cmake/OssiaConfiguration.cmake index 329944851c1..a1823b915a4 100644 --- a/cmake/OssiaConfiguration.cmake +++ b/cmake/OssiaConfiguration.cmake @@ -184,12 +184,12 @@ else() if(CMAKE_COMPILER_IS_GNUCXX) set(OSSIA_LINK_OPTIONS ${OSSIA_LINK_OPTIONS} - -fvar-tracking-assignments + $ ) # Note: this may fail with -gsplit-dwarf set(OSSIA_LINK_OPTIONS ${OSSIA_LINK_OPTIONS} - -Wl,-Bsymbolic-functions + $ ) endif() diff --git a/cmake/ossiaConfig.cmake.in b/cmake/ossiaConfig.cmake.in index 4c4137cac61..c4b4ebe366d 100644 --- a/cmake/ossiaConfig.cmake.in +++ b/cmake/ossiaConfig.cmake.in @@ -2,9 +2,15 @@ include(CMakeFindDependencyMacro) get_filename_component(OSSIA_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -list(APPEND CMAKE_MODULE_PATH ${OSSIA_CMAKE_DIR}) +list(APPEND CMAKE_MODULE_PATH "${OSSIA_CMAKE_DIR}") find_dependency(Boost 1.83 REQUIRED) +if(@OSSIA_STATIC@) + if(EXISTS "${OSSIA_CMAKE_DIR}/../re2/re2-exports.cmake") + include("${OSSIA_CMAKE_DIR}/../re2/re2-exports.cmake") + endif() +endif() + list(REMOVE_AT CMAKE_MODULE_PATH -1) if(NOT TARGET ossia::ossia) @@ -30,4 +36,10 @@ target_compile_definitions(ossia::ossia INTERFACE SPDLOG_DEBUG_ON=1 SPDLOG_TRACE_ON=1 ) + +if(@OSSIA_STATIC@) + if(TARGET re2) + target_link_libraries(ossia::ossia INTERFACE re2) + endif() +endif() endif()