From 866917657621ee74720f5abcee290b50341882c9 Mon Sep 17 00:00:00 2001 From: Evan Wilde Date: Tue, 30 Jul 2024 09:59:47 -0700 Subject: Swift: Fix INSTALL_NAME_DIR under CMP0157 NEW behavior Setting `CMAKE_INSTALL_NAME_DIR` or the `INSTALL_NAME_DIR` on Swift targets had no effect when CMP0157 was set to `NEW`. This was a result of missing the `` before the ``. Fix that and add a test to verify that the install name directory is included in the install name. Fixes: #26175 --- Modules/CMakeSwiftInformation.cmake | 2 +- .../SwiftLibraryModuleCommand-check-stdout-darwin.txt | 13 +++++++++++++ .../SwiftLibraryModuleCommand-check-stdout-windows.txt | 13 +++++++++++++ .../Swift/SwiftLibraryModuleCommand-check-stdout.txt | 14 +++++++++++--- Tests/RunCMake/Swift/SwiftLibraryModuleCommand.cmake | 1 + 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout-darwin.txt create mode 100644 Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout-windows.txt diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index f8b6748..d891de5 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -132,7 +132,7 @@ if(CMAKE_Swift_COMPILATION_MODE_DEFAULT) endif() if(NOT CMAKE_Swift_CREATE_SHARED_LIBRARY) - set(CMAKE_Swift_CREATE_SHARED_LIBRARY " ${CMAKE_Swift_PARALLEL_FLAGS} -emit-library ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} -o ") + set(CMAKE_Swift_CREATE_SHARED_LIBRARY " ${CMAKE_Swift_PARALLEL_FLAGS} -emit-library ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} -o ") endif() if(NOT CMAKE_Swift_CREATE_SHARED_MODULE) diff --git a/Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout-darwin.txt b/Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout-darwin.txt new file mode 100644 index 0000000..20c656d --- /dev/null +++ b/Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout-darwin.txt @@ -0,0 +1,13 @@ +.*swiftc(.exe)? [^ +]* -parse-as-library -static -emit-module [^ +]* -module-name StaticLibrary [^ +]* +.*swiftc(.exe)? [^ +]* -parse-as-library -emit-module [^ +]* -module-name DynamicLibrary [^ +]* +.*swiftc(.exe)? [^ +]* -emit-library [^ +]* -Xlinker -install_name -Xlinker @rpath/libDynamicLibrary.dylib -o ([A-Za-z]+/)?libDynamicLibrary.dylib [^ +]* +.*swiftc(.exe)? -j [0-9]+ -num-threads [0-9]+ -c -module-name Executable diff --git a/Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout-windows.txt b/Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout-windows.txt new file mode 100644 index 0000000..220a805 --- /dev/null +++ b/Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout-windows.txt @@ -0,0 +1,13 @@ +.*swiftc(.exe)? [^ +]* -parse-as-library -static -emit-module [^ +]* -module-name StaticLibrary [^ +]* +.*swiftc(.exe)? [^ +]* -parse-as-library -emit-module [^ +]* -module-name DynamicLibrary [^ +]* +.*swiftc(.exe)? [^ +]* -emit-library [^ +]* -Xlinker -implib:DynamicLibrary.lib +-o ([A-Za-z]+/)?DynamicLibrary.dll [^ +]* +.*swiftc(.exe)? -j [0-9]+ -num-threads [0-9]+ -c -module-name Executable diff --git a/Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout.txt b/Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout.txt index 7e7fc7d..c3530aa 100644 --- a/Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout.txt +++ b/Tests/RunCMake/Swift/SwiftLibraryModuleCommand-check-stdout.txt @@ -1,5 +1,13 @@ -.*swiftc(.exe)? .* -parse-as-library -static -emit-module .* -module-name StaticLibrary [^ +.*swiftc(.exe)? [^ +]* -parse-as-library -static -emit-module [^ +]* -module-name StaticLibrary [^ ]* -.*swiftc(.exe)? .* -parse-as-library -emit-module .* -module-name DynamicLibrary [^ +.*swiftc(.exe)? [^ +]* -parse-as-library -emit-module [^ +]* -module-name DynamicLibrary [^ ]* -.*swiftc(.exe)? .* -j [0-9]* -num-threads [0-9]* -c -module-name Executable +.*swiftc(.exe)? [^ +]* -emit-library [^ +]* -Xlinker -soname -Xlinker libDynamicLibrary.so -o ([A-Za-z]+/)?libDynamicLibrary.so [^ +]* +.*swiftc(.exe)? -j [0-9]+ -num-threads [0-9]+ -c -module-name Executable diff --git a/Tests/RunCMake/Swift/SwiftLibraryModuleCommand.cmake b/Tests/RunCMake/Swift/SwiftLibraryModuleCommand.cmake index af4aede..700edf0 100644 --- a/Tests/RunCMake/Swift/SwiftLibraryModuleCommand.cmake +++ b/Tests/RunCMake/Swift/SwiftLibraryModuleCommand.cmake @@ -6,6 +6,7 @@ enable_language(Swift) add_library(StaticLibrary STATIC L.swift) add_library(DynamicLibrary SHARED L.swift) +set_target_properties(DynamicLibrary PROPERTIES INSTALL_NAME_DIR "@rpath") add_executable(Executable E.swift) add_dependencies(DynamicLibrary StaticLibrary) -- cgit v0.12