cmake: Add rpath to re2

This commit is contained in:
Mizux Seiha
2024-10-10 10:53:06 +02:00
parent fb359bac5e
commit eccff545c7
2 changed files with 19 additions and 1 deletions

View File

@@ -129,7 +129,7 @@ if(BUILD_re2)
GIT_REPOSITORY "https://github.com/google/re2.git"
GIT_TAG "2024-04-01"
GIT_SHALLOW TRUE
#PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/re2-2024-04-01.patch"
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/re2-2024-04-01.patch"
)
FetchContent_MakeAvailable(re2)
list(POP_BACK CMAKE_MESSAGE_INDENT)

View File

@@ -0,0 +1,18 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bdac5af..cedaf6e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -131,6 +131,13 @@ set(RE2_HEADERS
add_library(re2 ${RE2_SOURCES})
target_compile_features(re2 PUBLIC cxx_std_14)
+if(APPLE)
+ set_target_properties(re2 PROPERTIES
+ INSTALL_RPATH "@loader_path")
+elseif(UNIX)
+ set_target_properties(re2 PROPERTIES
+ INSTALL_RPATH "$ORIGIN")
+endif()
target_include_directories(re2 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
# CMake gives "set_target_properties called with incorrect number of arguments."
# errors if we don't quote ${RE2_HEADERS}, so quote it despite prevailing style.