diff options
author | Brad King <brad.king@kitware.com> | 2021-01-21 14:16:30 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-01-21 14:16:37 (GMT) |
commit | 6bf23b2755e4c9ee57210e6c544f7902fcab9dae (patch) | |
tree | 6b26b7491a782fd54eab4e37d5fd25fb2b2575db | |
parent | d1549824c909ffd69d6bed9eaf5795b46f14df7d (diff) | |
parent | 7e615a540ea346716ba3d94b4bcecb35c42d5107 (diff) | |
download | CMake-6bf23b2755e4c9ee57210e6c544f7902fcab9dae.zip CMake-6bf23b2755e4c9ee57210e6c544f7902fcab9dae.tar.gz CMake-6bf23b2755e4c9ee57210e6c544f7902fcab9dae.tar.bz2 |
Merge topic 'macos-include-weak-dependencies'
7e615a540e file(GET_RUNTIME_DEPENDENCIES): Fix weak macOS libraries not detected
f2d92b983b GetPrerequisites: Include weak macOS dependencies
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5703
4 files changed, 37 insertions, 4 deletions
diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake index f325cfb..ed5c38b 100644 --- a/Modules/GetPrerequisites.cmake +++ b/Modules/GetPrerequisites.cmake @@ -736,7 +736,7 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa set(gp_regex_cmp_count 1) elseif(gp_tool MATCHES "otool$") set(gp_cmd_args "-L") - set(gp_regex "^\t([^\t]+) \\(compatibility version ([0-9]+.[0-9]+.[0-9]+), current version ([0-9]+.[0-9]+.[0-9]+)\\)${eol_char}$") + set(gp_regex "^\t([^\t]+) \\(compatibility version ([0-9]+.[0-9]+.[0-9]+), current version ([0-9]+.[0-9]+.[0-9]+)(, weak)?\\)${eol_char}$") set(gp_regex_error "") set(gp_regex_fallback "") set(gp_regex_cmp_count 3) diff --git a/Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.cxx b/Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.cxx index 351d92a..6d97720 100644 --- a/Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.cxx +++ b/Source/cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool.cxx @@ -44,7 +44,7 @@ bool cmBinUtilsMacOSMachOOToolGetRuntimeDependenciesTool::GetFileInfo( std::string line; static const cmsys::RegularExpression rpathRegex("^ *cmd LC_RPATH$"); static const cmsys::RegularExpression loadDylibRegex( - "^ *cmd LC_LOAD_DYLIB$"); + "^ *cmd LC_LOAD(_WEAK)?_DYLIB$"); static const cmsys::RegularExpression pathRegex( "^ *path (.*) \\(offset [0-9]+\\)$"); static const cmsys::RegularExpression nameRegex( diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-all-check.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-all-check.cmake index e6f2623..e7cdbf6 100644 --- a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-all-check.cmake +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-all-check.cmake @@ -148,6 +148,27 @@ set(_check ) check_contents(deps/udeps6.txt "^${_check}$") +# Weak library reference should have exactly the same dependencies as a regular library reference (test 1) +set_with_libsystem(_check + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-build/root-all/executable/bin/../lib/executable_path/libexecutable_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-build/root-all/executable/bin/../lib/rpath_executable_path/librpath_executable_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-build/root-all/executable/lib/libtestlib\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-build/root-all/executable/lib/loader_path/libloader_path\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-build/root-all/executable/lib/normal/../rpath/librpath\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-build/root-all/executable/lib/normal/libnormal\.dylib]] + [[[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-build/root-all/executable/lib/rpath_loader_path/librpath_loader_path\.dylib]] + ) +check_contents(deps/deps7.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/udeps7.txt "^${_check}$") + set(_check "^libconflict\\.dylib:[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-build/root-all/executable/lib/conflict/libconflict\\.dylib;[^;]*/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos-build/root-all/executable/lib/conflict2/libconflict\\.dylib\n$" ) @@ -157,3 +178,4 @@ check_contents(deps/cdeps3.txt "${_check}") check_contents(deps/cdeps4.txt "${_check}") check_contents(deps/cdeps5.txt "${_check}") check_contents(deps/cdeps6.txt "${_check}") +check_contents(deps/cdeps7.txt "${_check}") diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos.cmake index c56a14b..aab19b7 100644 --- a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos.cmake +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/macos.cmake @@ -128,16 +128,19 @@ endforeach() target_link_libraries(testlib PRIVATE ${testlib_names}) add_executable(topexe macos/topexe.c) +add_executable(topexe_weak macos/topexe.c) add_library(toplib SHARED macos/toplib.c) add_library(topmod MODULE macos/toplib.c) target_link_libraries(topexe PRIVATE testlib) +target_link_libraries(topexe_weak PRIVATE "-weak_library" 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") +set_property(TARGET topexe_weak 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(TARGETS topexe topexe_weak toplib topmod testlib testlib_conflict RUNTIME DESTINATION executable/bin LIBRARY DESTINATION executable/lib) +install(TARGETS topexe topexe_weak 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) @@ -213,4 +216,12 @@ install(CODE [[ "${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( + deps7.txt udeps7.txt cdeps7.txt + EXECUTABLES + "${CMAKE_INSTALL_PREFIX}/executable/bin/$<TARGET_FILE_NAME:topexe_weak>" + LIBRARIES + "${CMAKE_INSTALL_PREFIX}/executable/lib/$<TARGET_FILE_NAME:testlib_conflict>" + ) ]]) |