summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorLuis Caro Campos <3535649+jcar87@users.noreply.github.com>2024-04-13 20:13:34 (GMT)
committerBrad King <brad.king@kitware.com>2024-04-15 15:59:39 (GMT)
commit3e865241f3e1f22e63afa8495d8ab25214582a8e (patch)
tree1b636221465541b8a14219a5c274863f42351bfa /Tests/RunCMake
parent9ae75401d5cbf905be2e3e5c5a5dd11795fa518a (diff)
downloadCMake-3e865241f3e1f22e63afa8495d8ab25214582a8e.zip
CMake-3e865241f3e1f22e63afa8495d8ab25214582a8e.tar.gz
CMake-3e865241f3e1f22e63afa8495d8ab25214582a8e.tar.bz2
file(GET_RUNTIME_DEPENDENCIES): propagate parent rpath on macOS
Fixes: #24400
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-parent-rpath-propagation.cmake44
-rw-r--r--Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/main.c8
-rw-r--r--Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/one.c6
-rw-r--r--Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/three.c3
-rw-r--r--Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/two.c6
6 files changed, 68 insertions, 0 deletions
diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake
index a68607e..f7ede51 100644
--- a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake
+++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake
@@ -42,6 +42,7 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
run_install_test(macos-unresolved)
run_install_test(macos-conflict)
run_install_test(macos-notfile)
+ run_install_test(macos-parent-rpath-propagation)
run_install_test(file-filter)
endif()
run_cmake(project)
diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-parent-rpath-propagation.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-parent-rpath-propagation.cmake
new file mode 100644
index 0000000..43df621
--- /dev/null
+++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-parent-rpath-propagation.cmake
@@ -0,0 +1,44 @@
+enable_language(C)
+
+# bin/exe (RPATH = "lib1:lib2:lib3")
+# ^
+# |
+# lib1/libone.dylib (RPATH erased)
+# ^
+# |
+# lib2/libtwo.dylib (RPATH erased)
+# ^
+# |
+# lib3/libthree.dylib (RPATH erased)
+# GET_RUNTIME_DEPENDENCIES(bin/exe) should resolve all three libraries
+
+set(TEST_SOURCE_DIR "macos/parent-rpath-propagation")
+
+add_library(three SHARED "${TEST_SOURCE_DIR}/three.c")
+
+add_library(two SHARED "${TEST_SOURCE_DIR}/two.c")
+target_link_libraries(two PRIVATE three)
+
+add_library(one SHARED "${TEST_SOURCE_DIR}/one.c")
+target_link_libraries(one PRIVATE two)
+
+add_executable(exe "${TEST_SOURCE_DIR}/main.c")
+target_link_libraries(exe PUBLIC one)
+
+set_property(TARGET exe PROPERTY INSTALL_RPATH
+ @loader_path/../lib1
+ @loader_path/../lib2
+ @loader_path/../lib3
+)
+
+install(TARGETS exe DESTINATION bin)
+install(TARGETS one DESTINATION lib1)
+install(TARGETS two DESTINATION lib2)
+install(TARGETS three DESTINATION lib3)
+
+install(CODE [[
+ file(GET_RUNTIME_DEPENDENCIES
+ EXECUTABLES
+ "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:exe>"
+ )
+ ]])
diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/main.c b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/main.c
new file mode 100644
index 0000000..fc02afa
--- /dev/null
+++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/main.c
@@ -0,0 +1,8 @@
+extern void one(void);
+
+int main(void)
+{
+ one();
+
+ return 0;
+}
diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/one.c b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/one.c
new file mode 100644
index 0000000..0c480cc
--- /dev/null
+++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/one.c
@@ -0,0 +1,6 @@
+extern void two(void);
+
+void one(void)
+{
+ two();
+}
diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/three.c b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/three.c
new file mode 100644
index 0000000..0be5f47
--- /dev/null
+++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/three.c
@@ -0,0 +1,3 @@
+void three(void)
+{
+}
diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/two.c b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/two.c
new file mode 100644
index 0000000..370baf7
--- /dev/null
+++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos/parent-rpath-propagation/two.c
@@ -0,0 +1,6 @@
+extern void three(void);
+
+void two(void)
+{
+ three();
+}