From 2d536724bf981fd9e811826b3de2a442ccb3cb07 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 12 May 2025 07:57:37 +0200 Subject: [PATCH] Add custom search path for stdc++exp On older Linux distributions, the `libstdc++exp.a` is not part of the package system. This requires a local build of this library. Add a configuration option `RESINSIGHT_GCC_STDCPP_EXP_PATH` to be able to link with this custom library. --- ApplicationLibCode/CMakeLists.txt | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index b91696f12b..a250850089 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -308,8 +308,28 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") # https://github.com/OPM/ResInsight/pull/7 list(APPEND EXTERNAL_LINK_LIBRARIES rt) - # stdc++exp is required for std::stacktrace - list(APPEND EXTERNAL_LINK_LIBRARIES stdc++exp) + # std::stacktrace requires stdc++exp. If a custom build of GCC stdc++exp is + # reqiured, define the search path here. + set(RESINSIGHT_GCC_STDCPP_EXP_PATH + "" + CACHE PATH "Path to search for stdc++exp" + ) + + if(RESINSIGHT_GCC_STDCPP_EXP_PATH) + find_library( + STDCPP_EXP_LIBRARY + NAMES stdc++exp + HINTS ${RESINSIGHT_GCC_STDCPP_EXP_PATH} + ) + if(STDCPP_EXP_LIBRARY) + message(STATUS "stdc++exp library found at custom location: ${STDCPP_EXP_LIBRARY}") + list(APPEND EXTERNAL_LINK_LIBRARIES ${STDCPP_EXP_LIBRARY}) + endif() + else() + # stdc++exp is required for std::stacktrace + message(STATUS "stdc++exp library found at default location") + list(APPEND EXTERNAL_LINK_LIBRARIES stdc++exp) + endif() endif() target_link_libraries(