diff options
author | Brad King <brad.king@kitware.com> | 2020-06-16 14:50:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-06-16 15:17:55 (GMT) |
commit | 248d0570c9016392feb841ffce6ac77e194aefe8 (patch) | |
tree | 2a43f5ef582fa6b2af06015b070fb9402214e455 /Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES | |
parent | 3f110a08571e3a506184e6b8a8e9622317435912 (diff) | |
download | CMake-248d0570c9016392feb841ffce6ac77e194aefe8.zip CMake-248d0570c9016392feb841ffce6ac77e194aefe8.tar.gz CMake-248d0570c9016392feb841ffce6ac77e194aefe8.tar.bz2 |
Tests: Factor out RunCMake.file-GET_RUNTIME_DEPENDENCIES test
Move the `file(GET_RUNTIME_DEPENDENCIES)` cases out of `RunCMake.install`.
Diffstat (limited to 'Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES')
58 files changed, 1420 insertions, 0 deletions
diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/CMakeLists.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake new file mode 100644 index 0000000..da5069c --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake @@ -0,0 +1,55 @@ +cmake_minimum_required(VERSION 3.16) +include(RunCMake) + +# Function to build and install a project. +function(run_install_test case) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) + set(RunCMake_TEST_NO_CLEAN 1) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${case}) + run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --config Debug) + # Check "all" components. + set(CMAKE_INSTALL_PREFIX ${RunCMake_TEST_BINARY_DIR}/root-all) + run_cmake_command(${case}-all ${CMAKE_COMMAND} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DBUILD_TYPE=Debug -P cmake_install.cmake) +endfunction() + +if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + if(NOT CMake_INSTALL_NAME_TOOL_BUG) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-unresolved) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-conflict) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-macos-notfile) + endif() + run_cmake(file-GET_RUNTIME_DEPENDENCIES-project) + run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs1) + run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs2) +elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") + run_install_test(file-GET_RUNTIME_DEPENDENCIES-windows) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-windows-unresolved) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-windows-conflict) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-windows-notfile) + run_cmake(file-GET_RUNTIME_DEPENDENCIES-project) + run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs1) + run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs2) +elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") + if(DEFINED ENV{LDFLAGS}) + # Some setups prebake disable-new-dtags into LDFLAGS + string(REPLACE "-Wl,--disable-new-dtags" "" new_ldflags "$ENV{LDFLAGS}") + set(ENV{LDFLAGS} "${new_ldflags}") + endif() + + if(NOT CMAKE_C_COMPILER_ID MATCHES "^XL") + run_install_test(file-GET_RUNTIME_DEPENDENCIES-linux) + endif() + run_install_test(file-GET_RUNTIME_DEPENDENCIES-linux-unresolved) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-linux-conflict) + run_install_test(file-GET_RUNTIME_DEPENDENCIES-linux-notfile) + run_cmake(file-GET_RUNTIME_DEPENDENCIES-project) + run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs1) + run_cmake(file-GET_RUNTIME_DEPENDENCIES-badargs2) +else() + run_cmake(file-GET_RUNTIME_DEPENDENCIES-unsupported) +endif() + +run_install_test(file-GET_RUNTIME_DEPENDENCIES-variable-propagation) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs1-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs1-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs1-stderr.txt new file mode 100644 index 0000000..b66d1fe --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs1-stderr.txt @@ -0,0 +1,18 @@ +^CMake Warning \(dev\) at file-GET_RUNTIME_DEPENDENCIES-badargs1\.cmake:[0-9]+ \(file\): + You have used file\(GET_RUNTIME_DEPENDENCIES\) in project mode\. This is + probably not what you intended to do\. Instead, please consider using it in + an install\(CODE\) or install\(SCRIPT\) command\. For example: + + install\(CODE \[\[ + file\(GET_RUNTIME_DEPENDENCIES + # \.\.\. + \) + ]]\) +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) +This warning is for project developers\. Use -Wno-dev to suppress it\. + +CMake Error at file-GET_RUNTIME_DEPENDENCIES-badargs1\.cmake:[0-9]+ \(file\): + file Unrecognized argument: "invalid" +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs1.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs1.cmake new file mode 100644 index 0000000..f3b8ce4 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs1.cmake @@ -0,0 +1,2 @@ +file(GET_RUNTIME_DEPENDENCIES invalid) +message(FATAL_ERROR "This message should not be displayed") diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs2-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs2-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs2-stderr.txt new file mode 100644 index 0000000..50fa81f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs2-stderr.txt @@ -0,0 +1,23 @@ +^CMake Warning \(dev\) at file-GET_RUNTIME_DEPENDENCIES-badargs2\.cmake:[0-9]+ \(file\): + You have used file\(GET_RUNTIME_DEPENDENCIES\) in project mode\. This is + probably not what you intended to do\. Instead, please consider using it in + an install\(CODE\) or install\(SCRIPT\) command\. For example: + + install\(CODE \[\[ + file\(GET_RUNTIME_DEPENDENCIES + # \.\.\. + \) + ]]\) +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) +This warning is for project developers\. Use -Wno-dev to suppress it\. + +CMake Error at file-GET_RUNTIME_DEPENDENCIES-badargs2\.cmake:[0-9]+ \(file\): + file Keywords missing values: + + RESOLVED_DEPENDENCIES_VAR + UNRESOLVED_DEPENDENCIES_VAR + CONFLICTING_DEPENDENCIES_PREFIX + BUNDLE_EXECUTABLE +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs2.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs2.cmake new file mode 100644 index 0000000..ac6af85 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-badargs2.cmake @@ -0,0 +1,15 @@ +file(GET_RUNTIME_DEPENDENCIES + RESOLVED_DEPENDENCIES_VAR + UNRESOLVED_DEPENDENCIES_VAR + CONFLICTING_DEPENDENCIES_PREFIX + BUNDLE_EXECUTABLE + EXECUTABLES + LIBRARIES + MODULES + DIRECTORIES + PRE_INCLUDE_REGEXES + PRE_EXCLUDE_REGEXES + POST_INCLUDE_REGEXES + POST_EXCLUDE_REGEXES + ) +message(FATAL_ERROR "This message should not be displayed") diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-all-check.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-all-check.cmake new file mode 100644 index 0000000..ab482f2 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-all-check.cmake @@ -0,0 +1,44 @@ +function(check_contents filename contents_regex) + if(EXISTS "${CMAKE_INSTALL_PREFIX}/${filename}") + file(READ "${CMAKE_INSTALL_PREFIX}/${filename}" contents) + if(NOT contents MATCHES "${contents_regex}") + string(APPEND RunCMake_TEST_FAILED "File contents: + ${contents} +do not match what we expected: + ${contents_regex} +in file: + ${CMAKE_INSTALL_PREFIX}/${filename}\n") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) + endif() + else() + string(APPEND RunCMake_TEST_FAILED "File ${CMAKE_INSTALL_PREFIX}/${filename} does not exist") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) + endif() +endfunction() + +set(_check + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/libtest_rpath\.so]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/libtest_runpath\.so]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath/librpath\.so]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_parent/librpath_parent\.so]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search/librpath_search\.so]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath/librunpath\.so]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search/librunpath_search\.so]] + ) +check_contents(deps/deps1.txt "^${_check}$") +check_contents(deps/deps2.txt "^${_check}$") +check_contents(deps/deps3.txt "^${_check}$") +set(_check + [[librpath_unresolved\.so]] + [[librunpath_parent_unresolved\.so]] + [[librunpath_unresolved\.so]] + ) +check_contents(deps/udeps1.txt "^${_check}$") +check_contents(deps/udeps2.txt "^${_check}$") +check_contents(deps/udeps3.txt "^${_check}$") +set(_check + "^libconflict\\.so:[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/conflict/libconflict\\.so;[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/conflict2/libconflict\\.so\n$" + ) +check_contents(deps/cdeps1.txt "${_check}") +check_contents(deps/cdeps2.txt "${_check}") +check_contents(deps/cdeps3.txt "${_check}") diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-all-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-all-stderr.txt new file mode 100644 index 0000000..7ba3033 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-all-stderr.txt @@ -0,0 +1,119 @@ +^CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librpath_search_postexcluded\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search_postexcluded + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\) + +*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librpath_search\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\) + +*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librunpath_search_postexcluded\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search_postexcluded + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\) + +*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librunpath_search\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\) + +*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librpath_search_postexcluded\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search_postexcluded + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\) + +*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librpath_search\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\) + +*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librunpath_search_postexcluded\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search_postexcluded + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\) + +*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librunpath_search\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\) + +*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librpath_search_postexcluded\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search_postexcluded + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\) + +*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librpath_search\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/rpath_search + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\) + +*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librunpath_search_postexcluded\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search_postexcluded + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\) + +*CMake Warning at cmake_install\.cmake:[0-9]+ \(file\): + Dependency librunpath_search\.so found in search directory: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-build/root-all/lib/runpath_search + + See file\(GET_RUNTIME_DEPENDENCIES\) documentation for more information\. +Call Stack \(most recent call first\): + cmake_install\.cmake:[0-9]+ \(exec_get_runtime_dependencies\)$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-stderr.txt new file mode 100644 index 0000000..37f283a --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-all-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Multiple conflicting paths found for librpath\.so: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-build/root-all/lib/rpath1/librpath\.so + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-conflict-build/root-all/lib/rpath2/librpath\.so$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-conflict.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-conflict.cmake new file mode 100644 index 0000000..f719499 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-conflict.cmake @@ -0,0 +1,54 @@ +enable_language(C) + +set(test1_names rpath) +set(test2_names rpath) + +file(WRITE "${CMAKE_BINARY_DIR}/rpath.c" "void rpath(void) {}\n") +add_library(rpath SHARED "${CMAKE_BINARY_DIR}/rpath.c") +install(TARGETS rpath DESTINATION lib/rpath1) +install(TARGETS rpath DESTINATION lib/rpath2) + +file(REMOVE "${CMAKE_BINARY_DIR}/test1.c") +add_library(test1 SHARED "${CMAKE_BINARY_DIR}/test1.c") +foreach(name ${test1_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "extern void ${name}(void);\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "void test1(void)\n{\n") +foreach(name ${test1_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test1.c" " ${name}();\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "}\n") + +target_link_libraries(test1 PRIVATE ${test1_names}) +set_property(TARGET test1 PROPERTY INSTALL_RPATH + "${CMAKE_BINARY_DIR}/root-all/lib/rpath1" + ) + +file(REMOVE "${CMAKE_BINARY_DIR}/test2.c") +add_library(test2 SHARED "${CMAKE_BINARY_DIR}/test2.c") +foreach(name ${test2_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "extern void ${name}(void);\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "void test2(void)\n{\n") +foreach(name ${test2_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test2.c" " ${name}();\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "}\n") + +target_link_libraries(test2 PRIVATE ${test2_names}) +set_property(TARGET test2 PROPERTY INSTALL_RPATH + "${CMAKE_BINARY_DIR}/root-all/lib/rpath2" + ) + +install(TARGETS test1 test2 DESTINATION lib) + +install(CODE [[ + file(GET_RUNTIME_DEPENDENCIES + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test1>" + "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test2>" + PRE_INCLUDE_REGEXES "^librpath\\.so$" + PRE_EXCLUDE_REGEXES ".*" + ) + message(FATAL_ERROR "This message should not be displayed") + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-stderr.txt new file mode 100644 index 0000000..4e56787 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-all-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Failed to run objdump on: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-notfile-build/root-all/bin/\.\./lib/libtest\.so$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-notfile.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-notfile.cmake new file mode 100644 index 0000000..6567438 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-notfile.cmake @@ -0,0 +1,30 @@ +enable_language(C) +cmake_policy(SET CMP0095 NEW) + +file(WRITE "${CMAKE_BINARY_DIR}/test.c" "void test(void) {}\n") +file(WRITE "${CMAKE_BINARY_DIR}/main.c" [[extern void test(void); + +int main(void) +{ + test(); + return 0; +} +]]) + +add_library(test SHARED "${CMAKE_BINARY_DIR}/test.c") +add_executable(exe "${CMAKE_BINARY_DIR}/main.c") +target_link_libraries(exe PRIVATE test) +set_property(TARGET exe PROPERTY INSTALL_RPATH "\${ORIGIN}/../lib") + +install(TARGETS exe DESTINATION bin) + +install(CODE [[ + file(MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test>") + file(GET_RUNTIME_DEPENDENCIES + EXECUTABLES + "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:exe>" + PRE_INCLUDE_REGEXES "^libtest\\.so$" + PRE_EXCLUDE_REGEXES ".*" + ) + message(FATAL_ERROR "This message should not be displayed") + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-stderr.txt new file mode 100644 index 0000000..eaca512 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved-all-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Could not resolve file libunresolved\.so$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved.cmake new file mode 100644 index 0000000..3efa305 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux-unresolved.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +file(WRITE "${CMAKE_BINARY_DIR}/testlib.c" "extern void unresolved(void);\nvoid testlib(void)\n{\n unresolved();\n}\n") +add_library(testlib SHARED "${CMAKE_BINARY_DIR}/testlib.c") +file(WRITE "${CMAKE_BINARY_DIR}/unresolved.c" "void unresolved(void) {}\n") +add_library(unresolved SHARED "${CMAKE_BINARY_DIR}/unresolved.c") +target_link_libraries(testlib PRIVATE unresolved) +install(TARGETS testlib DESTINATION lib) + +install(CODE [[ + file(GET_RUNTIME_DEPENDENCIES + PRE_INCLUDE_REGEXES "^libunresolved\\.so$" + PRE_EXCLUDE_REGEXES ".*" + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:testlib>" + ) + message(FATAL_ERROR "This message should not be displayed") + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux.cmake new file mode 100644 index 0000000..bd0f9f1 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux.cmake @@ -0,0 +1,169 @@ +enable_language(C) +cmake_policy(SET CMP0095 NEW) + +set(test_rpath_names + preexcluded + rpath_postexcluded + rpath + rpath_parent_postexcluded + rpath_parent + rpath_origin_postexcluded + rpath_origin + rpath_search_postexcluded + rpath_search + rpath_unresolved + conflict + ) +set(test_runpath_names + runpath_postexcluded + runpath + runpath_origin_postexcluded + runpath_origin + runpath_parent_unresolved + runpath_search_postexcluded + runpath_search + runpath_unresolved + ) + +file(REMOVE "${CMAKE_BINARY_DIR}/test_rpath.c") +add_library(test_rpath SHARED "${CMAKE_BINARY_DIR}/test_rpath.c") +foreach(name ${test_rpath_names}) + file(WRITE "${CMAKE_BINARY_DIR}/${name}.c" "void ${name}(void) {}\n") + add_library(${name} SHARED "${CMAKE_BINARY_DIR}/${name}.c") + + file(APPEND "${CMAKE_BINARY_DIR}/test_rpath.c" "extern void ${name}(void);\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test_rpath.c" "void test_rpath(void)\n{\n") +foreach(name ${test_rpath_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test_rpath.c" " ${name}();\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test_rpath.c" "}\n") + +install(TARGETS rpath_postexcluded DESTINATION lib/rpath_postexcluded) +install(TARGETS rpath DESTINATION lib/rpath) +install(TARGETS rpath_origin_postexcluded DESTINATION lib/rpath_origin_postexcluded) +install(TARGETS rpath_origin DESTINATION lib/rpath_origin) +install(TARGETS rpath_parent_postexcluded DESTINATION lib/rpath_parent_postexcluded) +install(TARGETS rpath rpath_origin rpath_parent DESTINATION lib/rpath_parent) +install(TARGETS rpath_search_postexcluded DESTINATION lib/rpath_search_postexcluded) +install(TARGETS rpath rpath_origin rpath_parent rpath_search DESTINATION lib/rpath_search) +install(TARGETS conflict DESTINATION lib/conflict) + +target_link_libraries(test_rpath PRIVATE ${test_rpath_names}) +set_property(TARGET test_rpath PROPERTY INSTALL_RPATH + "${CMAKE_BINARY_DIR}/root-all/lib/rpath_postexcluded" + "${CMAKE_BINARY_DIR}/root-all/lib/rpath" + "\$ORIGIN/rpath_origin_postexcluded" + "\${ORIGIN}/rpath_origin" + "${CMAKE_BINARY_DIR}/root-all/lib/conflict" + ) +target_link_options(test_rpath PRIVATE -Wl,--disable-new-dtags) + +file(REMOVE "${CMAKE_BINARY_DIR}/test_runpath.c") +add_library(test_runpath SHARED "${CMAKE_BINARY_DIR}/test_runpath.c") +foreach(name ${test_runpath_names} rpath conflict) + file(WRITE "${CMAKE_BINARY_DIR}/${name}.c" "void ${name}(void) {}\n") + if(NOT name MATCHES "^(rpath|conflict)$") + add_library(${name} SHARED "${CMAKE_BINARY_DIR}/${name}.c") + endif() + + file(APPEND "${CMAKE_BINARY_DIR}/test_runpath.c" "extern void ${name}(void);\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test_runpath.c" "void test_runpath(void)\n{\n") +foreach(name ${test_runpath_names} rpath conflict) + file(APPEND "${CMAKE_BINARY_DIR}/test_runpath.c" " ${name}();\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test_runpath.c" "}\n") + +install(TARGETS runpath_postexcluded DESTINATION lib/runpath_postexcluded) +install(TARGETS runpath DESTINATION lib/runpath) +install(TARGETS runpath_origin_postexcluded DESTINATION lib/runpath_origin_postexcluded) +install(TARGETS runpath_origin DESTINATION lib/runpath_origin) +install(TARGETS runpath_parent_unresolved DESTINATION lib/runpath_parent_unresolved) +install(TARGETS runpath_search_postexcluded DESTINATION lib/runpath_search_postexcluded) +install(TARGETS runpath runpath_origin runpath_search DESTINATION lib/runpath_search) +install(TARGETS conflict DESTINATION lib/conflict2) + +target_link_libraries(test_runpath PRIVATE ${test_runpath_names} rpath conflict) +set_property(TARGET test_runpath PROPERTY INSTALL_RPATH + "${CMAKE_BINARY_DIR}/root-all/lib/runpath/../rpath" # Ensure that files that don't conflict are treated correctly + "${CMAKE_BINARY_DIR}/root-all/lib/runpath_postexcluded" + "${CMAKE_BINARY_DIR}/root-all/lib/runpath" + "\${ORIGIN}/runpath_origin_postexcluded" + "\$ORIGIN/runpath_origin" + "${CMAKE_BINARY_DIR}/root-all/lib/conflict2" + ) +target_link_options(test_runpath PRIVATE -Wl,--enable-new-dtags) + +set_property(TARGET test_rpath ${test_rpath_names} test_runpath ${test_runpath_names} PROPERTY LIBRARY_OUTPUT_DIRECTORY lib) +install(TARGETS test_rpath test_runpath DESTINATION lib) + +add_executable(topexe file-GET_RUNTIME_DEPENDENCIES-linux/topexe.c) +add_library(toplib SHARED file-GET_RUNTIME_DEPENDENCIES-linux/toplib.c) +add_library(topmod MODULE file-GET_RUNTIME_DEPENDENCIES-linux/toplib.c) +target_link_libraries(topexe PRIVATE test_rpath test_runpath) +target_link_libraries(toplib PRIVATE test_rpath test_runpath) +target_link_libraries(topmod PRIVATE test_rpath test_runpath) +set_property(TARGET topexe toplib topmod PROPERTY INSTALL_RPATH + "${CMAKE_BINARY_DIR}/root-all/lib" + "${CMAKE_BINARY_DIR}/root-all/lib/rpath_parent_postexcluded" + "${CMAKE_BINARY_DIR}/root-all/lib/rpath_parent" + "${CMAKE_BINARY_DIR}/root-all/lib/runpath_parent_unresolved" + ) +target_link_options(topexe PRIVATE -Wl,--disable-new-dtags) +target_link_options(toplib PRIVATE -Wl,--disable-new-dtags) +target_link_options(topmod PRIVATE -Wl,--disable-new-dtags) + +install(TARGETS topexe toplib RUNTIME DESTINATION bin LIBRARY DESTINATION lib) +install(TARGETS topmod LIBRARY DESTINATION lib/modules) + +install(CODE [[ + function(exec_get_runtime_dependencies depsfile udepsfile cdepsfile) + file(GET_RUNTIME_DEPENDENCIES + RESOLVED_DEPENDENCIES_VAR deps + UNRESOLVED_DEPENDENCIES_VAR udeps + CONFLICTING_DEPENDENCIES_PREFIX cdeps + PRE_INCLUDE_REGEXES + "^lib(test_rpath|rpath_postexcluded|rpath|rpath_parent_postexcluded|rpath_parent|rpath_origin_postexcluded|rpath_origin|rpath_search_postexcluded|rpath_search|rpath_unresolved|test_runpath|runpath_postexcluded|runpath|runpath_origin_postexcluded|runpath_origin|runpath_parent_unresolved|runpath_search_postexcluded|runpath_search|runpath_unresolved|conflict)\\.so$" + "^libc\\.so" + PRE_EXCLUDE_REGEXES ".*" + POST_INCLUDE_REGEXES "^.*/(libtest_rpath|rpath/librpath|rpath_parent/librpath_parent|rpath_search/librpath_search|libtest_runpath|runpath/librunpath|runpath_origin_postexcluded|runpath_origin|runpath_search/librunpath_search|conflict2?/libconflict)\\.so$" + POST_EXCLUDE_REGEXES ".*" + DIRECTORIES + "${CMAKE_INSTALL_PREFIX}/lib/rpath_search_postexcluded" + "${CMAKE_INSTALL_PREFIX}/lib/rpath_search" + "${CMAKE_INSTALL_PREFIX}/lib/runpath_search_postexcluded" + "${CMAKE_INSTALL_PREFIX}/lib/runpath_search" + ${ARGN} + ) + list(SORT deps) + list(SORT udeps) + list(SORT cdeps_FILENAMES) + file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${depsfile}" "${deps}") + file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${udepsfile}" "${udeps}") + file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "") + foreach(cdep IN LISTS cdeps_FILENAMES) + set(cdep_values ${cdeps_${cdep}}) + list(SORT cdep_values) + file(APPEND "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "${cdep}:${cdep_values}\n") + endforeach() + endfunction() + + exec_get_runtime_dependencies( + deps1.txt udeps1.txt cdeps1.txt + EXECUTABLES + "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:topexe>" + ) + + exec_get_runtime_dependencies( + deps2.txt udeps2.txt cdeps2.txt + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:toplib>" + ) + + exec_get_runtime_dependencies( + deps3.txt udeps3.txt cdeps3.txt + MODULES + "${CMAKE_INSTALL_PREFIX}/lib/modules/$<TARGET_FILE_NAME:topmod>" + ) + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux/topexe.c b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux/topexe.c new file mode 100644 index 0000000..d196afe --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux/topexe.c @@ -0,0 +1,9 @@ +extern void test_rpath(void); +extern void test_runpath(void); + +int main(void) +{ + test_rpath(); + test_runpath(); + return 0; +} diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux/toplib.c b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux/toplib.c new file mode 100644 index 0000000..040e591 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-linux/toplib.c @@ -0,0 +1,8 @@ +extern void test_rpath(void); +extern void test_runpath(void); + +void toplib(void) +{ + test_rpath(); + test_runpath(); +} diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-all-check.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-all-check.cmake new file mode 100644 index 0000000..d2f79ed --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-all-check.cmake @@ -0,0 +1,157 @@ +function(check_contents filename contents_regex) + if(EXISTS "${CMAKE_INSTALL_PREFIX}/${filename}") + file(READ "${CMAKE_INSTALL_PREFIX}/${filename}" contents) + if(NOT contents MATCHES "${contents_regex}") + string(APPEND RunCMake_TEST_FAILED "File contents: + ${contents} +do not match what we expected: + ${contents_regex} +in file: + ${CMAKE_INSTALL_PREFIX}/${filename}\n") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) + endif() + else() + string(APPEND RunCMake_TEST_FAILED "File ${CMAKE_INSTALL_PREFIX}/${filename} does not exist") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) + endif() +endfunction() + +set(_check + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/bin/../lib/executable_path/libexecutable_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/bin/../lib/rpath_executable_path/librpath_executable_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]] + [[/usr/lib/libSystem\.B\.dylib]] + ) +check_contents(deps/deps1.txt "^${_check}$") + +set(_check + [[@executable_path/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]] + [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]] + [[@rpath/librpath_executable_path_bundle\.dylib]] + [[@rpath/librpath_loader_path_unresolved\.dylib]] + [[@rpath/librpath_unresolved\.dylib]] + ) +check_contents(deps/udeps1.txt "^${_check}$") + +set(_check + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]] + [[/usr/lib/libSystem\.B\.dylib]] + ) +check_contents(deps/deps2.txt "^${_check}$") + +set(_check + [[@executable_path/../lib/executable_path/libexecutable_path\.dylib]] + [[@executable_path/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]] + [[@executable_path/../lib/executable_path_postexcluded/libexecutable_path_postexcluded\.dylib]] + [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]] + [[@rpath/librpath_executable_path\.dylib]] + [[@rpath/librpath_executable_path_bundle\.dylib]] + [[@rpath/librpath_executable_path_postexcluded\.dylib]] + [[@rpath/librpath_loader_path_unresolved\.dylib]] + [[@rpath/librpath_unresolved\.dylib]] + ) +check_contents(deps/udeps2.txt "^${_check}$") + +set(_check + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]] + [[/usr/lib/libSystem\.B\.dylib]] + ) +check_contents(deps/deps3.txt "^${_check}$") + +set(_check + [[@executable_path/../lib/executable_path/libexecutable_path\.dylib]] + [[@executable_path/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]] + [[@executable_path/../lib/executable_path_postexcluded/libexecutable_path_postexcluded\.dylib]] + [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]] + [[@rpath/librpath_executable_path\.dylib]] + [[@rpath/librpath_executable_path_bundle\.dylib]] + [[@rpath/librpath_executable_path_postexcluded\.dylib]] + [[@rpath/librpath_loader_path_unresolved\.dylib]] + [[@rpath/librpath_unresolved\.dylib]] + ) +check_contents(deps/udeps3.txt "^${_check}$") + +set(_check + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/bin/../lib/executable_path/libexecutable_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/bin/../lib/rpath_executable_path/librpath_executable_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]] + [[/usr/lib/libSystem\.B\.dylib]] + ) +check_contents(deps/deps4.txt "^${_check}$") + +set(_check + [[@executable_path/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]] + [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]] + [[@rpath/librpath_executable_path_bundle\.dylib]] + [[@rpath/librpath_loader_path_unresolved\.dylib]] + [[@rpath/librpath_unresolved\.dylib]] + ) +check_contents(deps/udeps4.txt "^${_check}$") + +set(_check + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/bundle_executable/bin/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]] + [[/usr/lib/libSystem\.B\.dylib]] + ) +check_contents(deps/deps5.txt "^${_check}$") + +set(_check + [[@executable_path/../lib/executable_path/libexecutable_path\.dylib]] + [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]] + [[@rpath/librpath_executable_path\.dylib]] + [[@rpath/librpath_executable_path_bundle\.dylib]] + [[@rpath/librpath_loader_path_unresolved\.dylib]] + [[@rpath/librpath_unresolved\.dylib]] + ) +check_contents(deps/udeps5.txt "^${_check}$") + +set(_check + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/bundle_executable/bin/../lib/executable_path_bundle/libexecutable_path_bundle\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/libtestlib\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/normal/libnormal\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]] + [[/usr/lib/libSystem\.B\.dylib]] + ) +check_contents(deps/deps6.txt "^${_check}$") + +set(_check + [[@executable_path/../lib/executable_path/libexecutable_path\.dylib]] + [[@loader_path/loader_path_unresolved/libloader_path_unresolved\.dylib]] + [[@rpath/librpath_executable_path\.dylib]] + [[@rpath/librpath_executable_path_bundle\.dylib]] + [[@rpath/librpath_loader_path_unresolved\.dylib]] + [[@rpath/librpath_unresolved\.dylib]] + ) +check_contents(deps/udeps6.txt "^${_check}$") + +set(_check + "^libconflict\\.dylib:[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/conflict/libconflict\\.dylib;[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-build/root-all/executable/lib/conflict2/libconflict\\.dylib\n$" + ) +check_contents(deps/cdeps1.txt "${_check}") +check_contents(deps/cdeps2.txt "${_check}") +check_contents(deps/cdeps3.txt "${_check}") +check_contents(deps/cdeps4.txt "${_check}") +check_contents(deps/cdeps5.txt "${_check}") +check_contents(deps/cdeps6.txt "${_check}") diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-stderr.txt new file mode 100644 index 0000000..7f36f71 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-all-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Multiple conflicting paths found for librpath\.dylib: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-build/root-all/lib/rpath1/librpath\.dylib + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-conflict-build/root-all/lib/rpath2/librpath\.dylib$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-conflict.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-conflict.cmake new file mode 100644 index 0000000..a8446fe --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-conflict.cmake @@ -0,0 +1,55 @@ +enable_language(C) + +set(test1_names rpath) +set(test2_names rpath) + +file(WRITE "${CMAKE_BINARY_DIR}/rpath.c" "void rpath(void) {}\n") +add_library(rpath SHARED "${CMAKE_BINARY_DIR}/rpath.c") +set_property(TARGET rpath PROPERTY INSTALL_NAME_DIR @rpath) +install(TARGETS rpath DESTINATION lib/rpath1) +install(TARGETS rpath DESTINATION lib/rpath2) + +file(REMOVE "${CMAKE_BINARY_DIR}/test1.c") +add_library(test1 SHARED "${CMAKE_BINARY_DIR}/test1.c") +foreach(name ${test1_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "extern void ${name}(void);\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "void test1(void)\n{\n") +foreach(name ${test1_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test1.c" " ${name}();\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "}\n") + +target_link_libraries(test1 PRIVATE ${test1_names}) +set_property(TARGET test1 PROPERTY INSTALL_RPATH + "${CMAKE_BINARY_DIR}/root-all/lib/rpath1" + ) + +file(REMOVE "${CMAKE_BINARY_DIR}/test2.c") +add_library(test2 SHARED "${CMAKE_BINARY_DIR}/test2.c") +foreach(name ${test2_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "extern void ${name}(void);\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "void test2(void)\n{\n") +foreach(name ${test2_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test2.c" " ${name}();\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "}\n") + +target_link_libraries(test2 PRIVATE ${test2_names}) +set_property(TARGET test2 PROPERTY INSTALL_RPATH + "${CMAKE_BINARY_DIR}/root-all/lib/rpath2" + ) + +install(TARGETS test1 test2 DESTINATION lib) + +install(CODE [[ + file(GET_RUNTIME_DEPENDENCIES + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test1>" + "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test2>" + PRE_INCLUDE_REGEXES "^@rpath/librpath\\.dylib$" + PRE_EXCLUDE_REGEXES ".*" + ) + message(FATAL_ERROR "This message should not be displayed") + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-stderr.txt new file mode 100644 index 0000000..1aac009 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-all-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Failed to run otool on: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-notfile-build/root-all/bin/\.\./lib/libtest\.dylib$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-notfile.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-notfile.cmake new file mode 100644 index 0000000..3e4c434 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-notfile.cmake @@ -0,0 +1,30 @@ +enable_language(C) + +file(WRITE "${CMAKE_BINARY_DIR}/test.c" "void test(void) {}\n") +file(WRITE "${CMAKE_BINARY_DIR}/main.c" [[extern void test(void); + +int main(void) +{ + test(); + return 0; +} +]]) + +add_library(test SHARED "${CMAKE_BINARY_DIR}/test.c") +set_property(TARGET test PROPERTY INSTALL_NAME_DIR @rpath) +add_executable(exe "${CMAKE_BINARY_DIR}/main.c") +target_link_libraries(exe PRIVATE test) +set_property(TARGET exe PROPERTY INSTALL_RPATH "@loader_path/../lib") + +install(TARGETS exe DESTINATION bin) + +install(CODE [[ + file(MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:test>") + file(GET_RUNTIME_DEPENDENCIES + EXECUTABLES + "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:exe>" + PRE_INCLUDE_REGEXES "^@rpath/libtest\\.dylib$" + PRE_EXCLUDE_REGEXES ".*" + ) + message(FATAL_ERROR "This message should not be displayed") + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-stderr.txt new file mode 100644 index 0000000..01762b4 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved-all-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Could not resolve file @rpath/libunresolved\.dylib$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved.cmake new file mode 100644 index 0000000..c9b6c95 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos-unresolved.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +file(WRITE "${CMAKE_BINARY_DIR}/testlib.c" "extern void unresolved(void);\nvoid testlib(void)\n{\n unresolved();\n}\n") +add_library(testlib SHARED "${CMAKE_BINARY_DIR}/testlib.c") +file(WRITE "${CMAKE_BINARY_DIR}/unresolved.c" "void unresolved(void) {}\n") +add_library(unresolved SHARED "${CMAKE_BINARY_DIR}/unresolved.c") +target_link_libraries(testlib PRIVATE unresolved) +install(TARGETS testlib DESTINATION lib) + +install(CODE [[ + file(GET_RUNTIME_DEPENDENCIES + PRE_INCLUDE_REGEXES "^@rpath/libunresolved\\.dylib$" + PRE_EXCLUDE_REGEXES ".*" + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:testlib>" + ) + message(FATAL_ERROR "This message should not be displayed") + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos.cmake new file mode 100644 index 0000000..6db05b3 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos.cmake @@ -0,0 +1,216 @@ +enable_language(C) + +set(testlib_names + preexcluded + executable_path + executable_path_bundle + executable_path_postexcluded + loader_path + loader_path_unresolved + loader_path_postexcluded + rpath + rpath_unresolved + rpath_postexcluded + rpath_executable_path + rpath_executable_path_bundle + rpath_executable_path_postexcluded + rpath_loader_path + rpath_loader_path_unresolved + rpath_loader_path_postexcluded + normal + normal_unresolved + normal_postexcluded + conflict + ) + +file(REMOVE "${CMAKE_BINARY_DIR}/testlib.c") +add_library(testlib SHARED "${CMAKE_BINARY_DIR}/testlib.c") +foreach(name ${testlib_names}) + if(name STREQUAL "normal") + file(WRITE "${CMAKE_BINARY_DIR}/normal.c" "extern void rpath(void);\nvoid normal(void)\n{\n rpath();\n}\n") + else() + file(WRITE "${CMAKE_BINARY_DIR}/${name}.c" "void ${name}(void) {}\n") + endif() + add_library(${name} SHARED "${CMAKE_BINARY_DIR}/${name}.c") + + file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "extern void ${name}(void);\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "void testlib(void)\n{\n") +foreach(name ${testlib_names}) + file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" " ${name}();\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "}\n") +set_property(TARGET ${testlib_names} PROPERTY BUILD_WITH_INSTALL_NAME_DIR 1) +target_link_libraries(normal PRIVATE rpath) +set_property(TARGET normal PROPERTY INSTALL_RPATH + "${CMAKE_BINARY_DIR}/root-all/executable/lib/normal/../rpath" + ) + +file(WRITE "${CMAKE_BINARY_DIR}/testlib_conflict.c" "extern void conflict(void);\nvoid testlib_conflict(void)\n{\n conflict();\n}\n") +add_library(testlib_conflict SHARED "${CMAKE_BINARY_DIR}/testlib_conflict.c") +target_link_libraries(testlib_conflict PRIVATE conflict) + +set_property(TARGET testlib PROPERTY INSTALL_RPATH + "${CMAKE_BINARY_DIR}/root-all/executable/lib/rpath" + "${CMAKE_BINARY_DIR}/root-all/executable/lib/rpath_unresolved" + "${CMAKE_BINARY_DIR}/root-all/executable/lib/rpath_postexcluded" + "${CMAKE_BINARY_DIR}/root-all/executable/lib/conflict" + @executable_path/../lib/rpath_executable_path + @executable_path/../lib/rpath_executable_path_unresolved + @executable_path/../lib/rpath_executable_path_postexcluded + @loader_path/rpath_loader_path + @loader_path/rpath_loader_path_unresolved + @loader_path/rpath_loader_path_postexcluded + ) +set_property(TARGET testlib_conflict PROPERTY INSTALL_RPATH + "${CMAKE_BINARY_DIR}/root-all/executable/lib/conflict2" + ) + +foreach(t + executable_path + executable_path_postexcluded + loader_path + loader_path_postexcluded + rpath + rpath_postexcluded + rpath_executable_path + rpath_executable_path_postexcluded + rpath_loader_path + rpath_loader_path_postexcluded + conflict + ) + install(TARGETS ${t} DESTINATION executable/lib/${t}) +endforeach() +install(TARGETS conflict DESTINATION executable/lib/conflict2) + +foreach(t + executable_path_bundle + executable_path_postexcluded + loader_path_postexcluded + rpath_postexcluded + rpath_executable_path_bundle + rpath_executable_path_postexcluded + rpath_loader_path_postexcluded + ) + install(TARGETS ${t} DESTINATION bundle_executable/lib/${t}) +endforeach() + +foreach(t executable_path executable_path_bundle executable_path_postexcluded) + set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR @executable_path/../lib/${t}) +endforeach() + +foreach(t loader_path loader_path_unresolved loader_path_postexcluded) + set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR @loader_path/${t}) +endforeach() + +foreach(t + rpath + rpath_unresolved + rpath_postexcluded + rpath_executable_path + rpath_executable_path_bundle + rpath_executable_path_postexcluded + rpath_loader_path + rpath_loader_path_unresolved + rpath_loader_path_postexcluded + conflict + ) + set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR @rpath) +endforeach() + +foreach(t normal normal_unresolved normal_postexcluded) + set_property(TARGET ${t} PROPERTY INSTALL_NAME_DIR "${CMAKE_BINARY_DIR}/root-all/executable/lib/${t}") + if(NOT t STREQUAL "normal_unresolved") + install(TARGETS ${t} DESTINATION executable/lib/${t}) + endif() +endforeach() + +target_link_libraries(testlib PRIVATE ${testlib_names}) + +add_executable(topexe file-GET_RUNTIME_DEPENDENCIES-macos/topexe.c) +add_library(toplib SHARED file-GET_RUNTIME_DEPENDENCIES-macos/toplib.c) +add_library(topmod MODULE file-GET_RUNTIME_DEPENDENCIES-macos/toplib.c) +target_link_libraries(topexe PRIVATE testlib) +target_link_libraries(toplib PRIVATE testlib) +target_link_libraries(topmod PRIVATE testlib) + +set_property(TARGET topexe toplib topmod PROPERTY INSTALL_RPATH "${CMAKE_BINARY_DIR}/root-all/executable/lib") + +install(TARGETS topexe toplib topmod testlib testlib_conflict RUNTIME DESTINATION executable/bin LIBRARY DESTINATION executable/lib) +install(TARGETS topexe toplib topmod testlib testlib_conflict RUNTIME DESTINATION bundle_executable/bin LIBRARY DESTINATION bundle_executable/lib) + +install(CODE [[ + function(exec_get_runtime_dependencies depsfile udepsfile cdepsfile) + file(GET_RUNTIME_DEPENDENCIES + RESOLVED_DEPENDENCIES_VAR deps + UNRESOLVED_DEPENDENCIES_VAR udeps + CONFLICTING_DEPENDENCIES_PREFIX cdeps + PRE_INCLUDE_REGEXES "^.*/lib(testlib|executable_path|executable_path_bundle|executable_path_postexcluded|loader_path|loader_path_unresolved|loader_path_postexcluded|rpath|rpath_unresolved|rpath_postexcluded|rpath_executable_path|rpath_executable_path_bundle|rpath_executable_path_postexcluded|rpath_loader_path|rpath_loader_path_unresolved|rpath_loader_path_postexcluded|normal|normal_unresolved|normal_postexcluded|conflict|System\\.B)\\.dylib$" + PRE_EXCLUDE_REGEXES ".*" + POST_INCLUDE_REGEXES "^.*/lib(testlib|executable_path|executable_path_bundle|loader_path|rpath|rpath_executable_path|rpath_executable_path_bundle|rpath_loader_path|normal|conflict|System\\.B)\\.dylib$" + POST_EXCLUDE_REGEXES ".*" + ${ARGN} + ) + list(SORT deps) + list(SORT udeps) + list(SORT cdeps_FILENAMES) + file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${depsfile}" "${deps}") + file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${udepsfile}" "${udeps}") + file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "") + foreach(cdep IN LISTS cdeps_FILENAMES) + set(cdep_values ${cdeps_${cdep}}) + list(SORT cdep_values) + file(APPEND "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "${cdep}:${cdep_values}\n") + endforeach() + endfunction() + + exec_get_runtime_dependencies( + deps1.txt udeps1.txt cdeps1.txt + EXECUTABLES + "${CMAKE_INSTALL_PREFIX}/executable/bin/$<TARGET_FILE_NAME:topexe>" + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>" + ) + + exec_get_runtime_dependencies( + deps2.txt udeps2.txt cdeps2.txt + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:toplib>" + "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>" + ) + + exec_get_runtime_dependencies( + deps3.txt udeps3.txt cdeps3.txt + MODULES + "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:topmod>" + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>" + ) + + exec_get_runtime_dependencies( + deps4.txt udeps4.txt cdeps4.txt + EXECUTABLES + "${CMAKE_INSTALL_PREFIX}/executable/bin/$<TARGET_FILE_NAME:topexe>" + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>" + BUNDLE_EXECUTABLE + "${CMAKE_INSTALL_PREFIX}/bundle_executable/bin/$<TARGET_FILE_NAME:topexe>" + ) + + exec_get_runtime_dependencies( + deps5.txt udeps5.txt cdeps5.txt + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:toplib>" + "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>" + BUNDLE_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/bundle_executable/bin/$<TARGET_FILE_NAME:topexe>" + ) + + exec_get_runtime_dependencies( + deps6.txt udeps6.txt cdeps6.txt + MODULES + "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:topmod>" + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>" + BUNDLE_EXECUTABLE "${CMAKE_INSTALL_PREFIX}/bundle_executable/bin/$<TARGET_FILE_NAME:topexe>" + ) + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos/topexe.c b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos/topexe.c new file mode 100644 index 0000000..20c6087 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos/topexe.c @@ -0,0 +1,7 @@ +extern void testlib(void); + +int main(void) +{ + testlib(); + return 0; +} diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos/toplib.c b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos/toplib.c new file mode 100644 index 0000000..cff1bff --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-macos/toplib.c @@ -0,0 +1,6 @@ +extern void testlib(void); + +void toplib(void) +{ + testlib(); +} diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-project-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-project-stderr.txt new file mode 100644 index 0000000..d506645 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-project-stderr.txt @@ -0,0 +1,13 @@ +^CMake Warning \(dev\) at file-GET_RUNTIME_DEPENDENCIES-project\.cmake:[0-9]+ \(file\): + You have used file\(GET_RUNTIME_DEPENDENCIES\) in project mode\. This is + probably not what you intended to do\. Instead, please consider using it in + an install\(CODE\) or install\(SCRIPT\) command\. For example: + + install\(CODE \[\[ + file\(GET_RUNTIME_DEPENDENCIES + # \.\.\. + \) + ]]\) +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) +This warning is for project developers\. Use -Wno-dev to suppress it\.$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-project.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-project.cmake new file mode 100644 index 0000000..842d7ab --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-project.cmake @@ -0,0 +1 @@ +file(GET_RUNTIME_DEPENDENCIES RESOLVED_DEPENDENCIES_VAR deps) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-unsupported-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-unsupported-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-unsupported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-unsupported-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-unsupported-stderr.txt new file mode 100644 index 0000000..3db835c --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-unsupported-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at file-GET_RUNTIME_DEPENDENCIES-unsupported\.cmake:[0-9]+ \(file\): + file GET_RUNTIME_DEPENDENCIES is not supported on system "[^ + ]+" +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-unsupported.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-unsupported.cmake new file mode 100644 index 0000000..b91eefe --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-unsupported.cmake @@ -0,0 +1,2 @@ +file(GET_RUNTIME_DEPENDENCIES RESOLVED_DEPENDENCIES_VAR deps) +message(FATAL_ERROR "This message should not be displayed") diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-stderr.txt new file mode 100644 index 0000000..591a5e7 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-all-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(message\): +.* +.*CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM: custom-platform.* +.*CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: custom-platform-objdump.* +.*CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND: path/to/custom-objdump.* +.*CMAKE_OBJDUMP: custom-objdump.* diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-stderr.txt new file mode 100644 index 0000000..591a5e7 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation-dev-stderr.txt @@ -0,0 +1,6 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(message\): +.* +.*CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM: custom-platform.* +.*CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: custom-platform-objdump.* +.*CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND: path/to/custom-objdump.* +.*CMAKE_OBJDUMP: custom-objdump.* diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation.cmake new file mode 100644 index 0000000..07bbc5e --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-variable-propagation.cmake @@ -0,0 +1,17 @@ +enable_language(C) + +set(CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM "custom-platform") +set(CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL "custom-platform-objdump") +set(CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND "path/to/custom-objdump") +set(CMAKE_OBJDUMP "custom-objdump") + +install(CODE [[ +message(FATAL_ERROR " + CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM: ${CMAKE_GET_RUNTIME_DEPENDENCIES_PLATFORM} + CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL: ${CMAKE_GET_RUNTIME_DEPENDENCIES_TOOL} + CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND: ${CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND} + CMAKE_OBJDUMP: ${CMAKE_OBJDUMP} +") +]] +COMPONENT dev +) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-all-check.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-all-check.cmake new file mode 100644 index 0000000..b1ba6df --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-all-check.cmake @@ -0,0 +1,38 @@ +function(check_contents filename contents_regex) + if(EXISTS "${CMAKE_INSTALL_PREFIX}/${filename}") + file(READ "${CMAKE_INSTALL_PREFIX}/${filename}" contents) + if(NOT contents MATCHES "${contents_regex}") + string(APPEND RunCMake_TEST_FAILED "File contents: + ${contents} +do not match what we expected: + ${contents_regex} +in file: + ${CMAKE_INSTALL_PREFIX}/${filename}\n") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) + endif() + else() + string(APPEND RunCMake_TEST_FAILED "File ${CMAKE_INSTALL_PREFIX}/${filename} does not exist") + set(RunCMake_TEST_FAILED "${RunCMake_TEST_FAILED}" PARENT_SCOPE) + endif() +endfunction() + +set(_check + [=[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-build/root-all/bin/\.conflict/\.\./(lib)?libdir\.dll]=] + [=[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-build/root-all/bin/\.search/(lib)?search\.dll]=] + [=[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-build/root-all/bin/(lib)?testlib\.dll]=] + ) +check_contents(deps/deps1.txt "^${_check}$") +check_contents(deps/deps2.txt "^${_check}$") +check_contents(deps/deps3.txt "^${_check}$") +set(_check + [=[(lib)?unresolved\.dll]=] + ) +check_contents(deps/udeps1.txt "^${_check}$") +check_contents(deps/udeps2.txt "^${_check}$") +check_contents(deps/udeps3.txt "^${_check}$") +set(_check + "^(lib)?conflict\\.dll:[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-build/root-all/bin/\\.conflict/(lib)?conflict\\.dll;[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-build/root-all/bin/(lib)?conflict\\.dll\n$" + ) +check_contents(deps/cdeps1.txt "${_check}") +check_contents(deps/cdeps2.txt "${_check}") +check_contents(deps/cdeps3.txt "${_check}") diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-stderr.txt new file mode 100644 index 0000000..a9ca6d0 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-all-stderr.txt @@ -0,0 +1,7 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Multiple conflicting paths found for (lib)?path\.dll: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-build/root-all/lib/test1/(lib)?path\.dll + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-conflict-build/root-all/lib/test2/(lib)?path\.dll$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-conflict.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-conflict.cmake new file mode 100644 index 0000000..d413443 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-conflict.cmake @@ -0,0 +1,47 @@ +enable_language(C) + +set(test1_names path) +set(test2_names path) + +file(WRITE "${CMAKE_BINARY_DIR}/path.c" "__declspec(dllexport) void path(void) {}\n") +add_library(path SHARED "${CMAKE_BINARY_DIR}/path.c") + +file(REMOVE "${CMAKE_BINARY_DIR}/test1.c") +add_library(test1 SHARED "${CMAKE_BINARY_DIR}/test1.c") +foreach(name ${test1_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "__declspec(dllimport) extern void ${name}(void);\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "__declspec(dllexport) void test1(void)\n{\n") +foreach(name ${test1_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test1.c" " ${name}();\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test1.c" "}\n") + +target_link_libraries(test1 PRIVATE ${test1_names}) + +file(REMOVE "${CMAKE_BINARY_DIR}/test2.c") +add_library(test2 SHARED "${CMAKE_BINARY_DIR}/test2.c") +foreach(name ${test2_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "__declspec(dllimport) extern void ${name}(void);\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "__declspec(dllexport) void test2(void)\n{\n") +foreach(name ${test2_names}) + file(APPEND "${CMAKE_BINARY_DIR}/test2.c" " ${name}();\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/test2.c" "}\n") + +target_link_libraries(test2 PRIVATE ${test2_names}) + +install(TARGETS test1 path DESTINATION lib/test1) +install(TARGETS test2 path DESTINATION lib/test2) + +install(CODE [[ + file(GET_RUNTIME_DEPENDENCIES + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/lib/test1/$<TARGET_FILE_NAME:test1>" + "${CMAKE_INSTALL_PREFIX}/lib/test2/$<TARGET_FILE_NAME:test2>" + PRE_INCLUDE_REGEXES "^(lib)?path\\.dll$" + PRE_EXCLUDE_REGEXES ".*" + ) + message(FATAL_ERROR "This message should not be displayed") + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-stderr.txt new file mode 100644 index 0000000..432ac32 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-all-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Failed to run (dumpbin|objdump) on: + + [^ +]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-notfile-build/root-all/bin/(lib)?test\.dll$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-notfile.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-notfile.cmake new file mode 100644 index 0000000..6665a3b --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-notfile.cmake @@ -0,0 +1,28 @@ +enable_language(C) + +file(WRITE "${CMAKE_BINARY_DIR}/test.c" "__declspec(dllexport) void test(void) {}\n") +file(WRITE "${CMAKE_BINARY_DIR}/main.c" [[__declspec(dllimport) extern void test(void); + +int main(void) +{ + test(); + return 0; +} +]]) + +add_library(test SHARED "${CMAKE_BINARY_DIR}/test.c") +add_executable(exe "${CMAKE_BINARY_DIR}/main.c") +target_link_libraries(exe PRIVATE test) + +install(TARGETS exe DESTINATION bin) + +install(CODE [[ + file(MAKE_DIRECTORY "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:test>") + file(GET_RUNTIME_DEPENDENCIES + EXECUTABLES + "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:exe>" + PRE_INCLUDE_REGEXES "^(lib)?test\\.dll$" + PRE_EXCLUDE_REGEXES ".*" + ) + message(FATAL_ERROR "This message should not be displayed") + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-result.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-stderr.txt b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-stderr.txt new file mode 100644 index 0000000..a20654c --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved-all-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error at cmake_install\.cmake:[0-9]+ \(file\): + file Could not resolve file (lib)?unresolved\.dll$ diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved.cmake new file mode 100644 index 0000000..4cc74c7 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows-unresolved.cmake @@ -0,0 +1,18 @@ +enable_language(C) + +file(WRITE "${CMAKE_BINARY_DIR}/testlib.c" "__declspec(dllimport) extern void unresolved(void);\n__declspec(dllexport) void testlib(void)\n{\n unresolved();\n}\n") +add_library(testlib SHARED "${CMAKE_BINARY_DIR}/testlib.c") +file(WRITE "${CMAKE_BINARY_DIR}/unresolved.c" "__declspec(dllexport) void unresolved(void) {}\n") +add_library(unresolved SHARED "${CMAKE_BINARY_DIR}/unresolved.c") +target_link_libraries(testlib PRIVATE unresolved) +install(TARGETS testlib DESTINATION lib) + +install(CODE [[ + file(GET_RUNTIME_DEPENDENCIES + PRE_INCLUDE_REGEXES "^(lib)?unresolved\\.dll$" + PRE_EXCLUDE_REGEXES ".*" + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/lib/$<TARGET_FILE_NAME:testlib>" + ) + message(FATAL_ERROR "This message should not be displayed") + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows.cmake new file mode 100644 index 0000000..19288d8 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows.cmake @@ -0,0 +1,114 @@ +enable_language(C) + +set(testlib_names + preexcluded + libdir_postexcluded + libdir + search_postexcluded + search + unresolved + conflict + ) + +file(REMOVE "${CMAKE_BINARY_DIR}/testlib.c") +add_library(testlib SHARED "${CMAKE_BINARY_DIR}/testlib.c") +foreach(name ${testlib_names}) + file(WRITE "${CMAKE_BINARY_DIR}/${name}.c" "__declspec(dllexport) void ${name}(void) {}\n") + add_library(${name} SHARED "${CMAKE_BINARY_DIR}/${name}.c") + + file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "__declspec(dllimport) extern void ${name}(void);\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "__declspec(dllexport) void testlib(void)\n{\n") +foreach(name ${testlib_names}) + file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" " ${name}();\n") +endforeach() +file(APPEND "${CMAKE_BINARY_DIR}/testlib.c" "}\n") + +target_link_libraries(testlib PRIVATE ${testlib_names}) + +file(WRITE "${CMAKE_BINARY_DIR}/testlib_conflict.c" "__declspec(dllimport) extern void conflict(void);\n__declspec(dllexport) void testlib_conflict(void)\n{\n conflict();\n}\n") +add_library(testlib_conflict SHARED "${CMAKE_BINARY_DIR}/testlib_conflict.c") +target_link_libraries(testlib_conflict PRIVATE conflict) + +file(WRITE "${CMAKE_BINARY_DIR}/testlib_noconflict.c" "__declspec(dllimport) extern void libdir(void);\n__declspec(dllexport) void testlib_noconflict(void)\n{\n libdir();\n}\n") +add_library(testlib_noconflict SHARED "${CMAKE_BINARY_DIR}/testlib_noconflict.c") +target_link_libraries(testlib_noconflict PRIVATE libdir) + +install(TARGETS testlib libdir_postexcluded libdir conflict testlib_noconflict DESTINATION bin) +install(TARGETS libdir search_postexcluded search DESTINATION bin/.search) # Prefixing with "." ensures it is the first item after list(SORT) +install(TARGETS testlib_conflict conflict DESTINATION bin/.conflict) + +add_executable(topexe file-GET_RUNTIME_DEPENDENCIES-windows/topexe.c) +add_library(toplib SHARED file-GET_RUNTIME_DEPENDENCIES-windows/toplib.c) +add_library(topmod MODULE file-GET_RUNTIME_DEPENDENCIES-windows/toplib.c) +target_link_libraries(topexe PRIVATE testlib) +target_link_libraries(toplib PRIVATE testlib) +target_link_libraries(topmod PRIVATE testlib) + +install(TARGETS topexe toplib topmod DESTINATION bin) + +install(CODE [[ + function(exec_get_runtime_dependencies depsfile udepsfile cdepsfile) + file(GET_RUNTIME_DEPENDENCIES + RESOLVED_DEPENDENCIES_VAR deps + UNRESOLVED_DEPENDENCIES_VAR udeps + CONFLICTING_DEPENDENCIES_PREFIX cdeps + PRE_INCLUDE_REGEXES + "^(lib)?testlib\\.dll$" + "^(lib)?libdir_postexcluded\\.dll$" + "^(lib)?libdir\\.dll$" + "^(lib)?search_postexcluded\\.dll$" + "^(lib)?search\\.dll$" + "^(lib)?unresolved\\.dll$" + "^(lib)?conflict\\.dll$" + "^kernel32\\.dll$" + PRE_EXCLUDE_REGEXES ".*" + POST_INCLUDE_REGEXES + "^.*/(lib)?testlib\\.dll$" + "^.*/(lib)?libdir\\.dll$" + "^.*/(lib)?search\\.dll$" + "^.*/(lib)?conflict\\.dll$" + POST_EXCLUDE_REGEXES ".*" + DIRECTORIES + "${CMAKE_INSTALL_PREFIX}/bin/.search" + ${ARGN} + ) + list(SORT deps) + list(SORT udeps) + list(SORT cdeps_FILENAMES) + file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${depsfile}" "${deps}") + file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${udepsfile}" "${udeps}") + file(WRITE "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "") + foreach(cdep IN LISTS cdeps_FILENAMES) + set(cdep_values ${cdeps_${cdep}}) + list(SORT cdep_values) + file(APPEND "${CMAKE_INSTALL_PREFIX}/deps/${cdepsfile}" "${cdep}:${cdep_values}\n") + endforeach() + endfunction() + + exec_get_runtime_dependencies( + deps1.txt udeps1.txt cdeps1.txt + EXECUTABLES + "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:topexe>" + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/bin/.conflict/$<TARGET_FILE_NAME:testlib_conflict>" + "${CMAKE_INSTALL_PREFIX}/bin/.conflict/../$<TARGET_FILE_NAME:testlib_noconflict>" + ) + + exec_get_runtime_dependencies( + deps2.txt udeps2.txt cdeps2.txt + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:toplib>" + "${CMAKE_INSTALL_PREFIX}/bin/.conflict/$<TARGET_FILE_NAME:testlib_conflict>" + "${CMAKE_INSTALL_PREFIX}/bin/.conflict/../$<TARGET_FILE_NAME:testlib_noconflict>" + ) + + exec_get_runtime_dependencies( + deps3.txt udeps3.txt cdeps3.txt + MODULES + "${CMAKE_INSTALL_PREFIX}/bin/$<TARGET_FILE_NAME:topmod>" + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/bin/.conflict/$<TARGET_FILE_NAME:testlib_conflict>" + "${CMAKE_INSTALL_PREFIX}/bin/.conflict/../$<TARGET_FILE_NAME:testlib_noconflict>" + ) + ]]) diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows/topexe.c b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows/topexe.c new file mode 100644 index 0000000..713b8eb --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows/topexe.c @@ -0,0 +1,7 @@ +__declspec(dllimport) extern void testlib(void); + +int main(void) +{ + testlib(); + return 0; +} diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows/toplib.c b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows/toplib.c new file mode 100644 index 0000000..6997175 --- /dev/null +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/file-GET_RUNTIME_DEPENDENCIES-windows/toplib.c @@ -0,0 +1,6 @@ +__declspec(dllimport) extern void testlib(void); + +__declspec(dllexport) void toplib(void) +{ + testlib(); +} |