Skip to content

Commit

Permalink
cmake: Fix googletest rpath
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizux committed Oct 10, 2024
1 parent eccff54 commit 9c542ed
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmake/dependencies/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,8 @@ if(BUILD_googletest)
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.2
GIT_SHALLOW TRUE
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/googletest-v1.15.2.patch"
#PATCH_COMMAND git apply --ignore-whitespace ""
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
Expand Down
18 changes: 18 additions & 0 deletions patches/googletest-v1.15.2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index 580ac1c..c6cc44c 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -190,6 +190,13 @@ function(cxx_library_with_type name type cxx_flags)
COMPILE_DEFINITIONS "GTEST_CREATE_SHARED_LIBRARY=1")
target_compile_definitions(${name} INTERFACE
$<INSTALL_INTERFACE:GTEST_LINKED_AS_SHARED_LIBRARY=1>)
+ if(APPLE)
+ set_target_properties(${name} PROPERTIES
+ INSTALL_RPATH "@loader_path")
+ elseif(UNIX)
+ set_target_properties(${name} PROPERTIES
+ INSTALL_RPATH "$ORIGIN")
+ endif()
endif()
if (DEFINED GTEST_HAS_PTHREAD)
target_link_libraries(${name} PUBLIC Threads::Threads)

0 comments on commit 9c542ed

Please sign in to comment.