summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2024-01-08 18:27:29 (GMT)
committerSaleem Abdulrasool <compnerd@compnerd.org>2024-01-10 16:02:36 (GMT)
commita2aad7eb8d84d40c13122c6d0a297ff3061baa6c (patch)
tree57241b7103cc15f8e69a730e1f338679aa969675
parent1e8b283554bddc1461eb243ac0079b330d8f1105 (diff)
downloadCMake-a2aad7eb8d84d40c13122c6d0a297ff3061baa6c.zip
CMake-a2aad7eb8d84d40c13122c6d0a297ff3061baa6c.tar.gz
CMake-a2aad7eb8d84d40c13122c6d0a297ff3061baa6c.tar.bz2
Swift: fix Windows DLL import library support for CMP0157 NEW
This was accidentally removed when the command templates were reorganized to introduce the new policy. Restore the flag in the shared library creation to ensure that we emit the import libraries to the correct location.
-rw-r--r--Modules/CMakeSwiftInformation.cmake2
-rw-r--r--Tests/RunCMake/Swift/ImportLibraryFlags-check-stdout.txt1
-rw-r--r--Tests/RunCMake/Swift/ImportLibraryFlags.cmake6
-rw-r--r--Tests/RunCMake/Swift/RunCMakeTest.cmake8
4 files changed, 16 insertions, 1 deletions
diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake
index 7a1c64a..f8b6748 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_COMPILER> ${CMAKE_Swift_PARALLEL_FLAGS} -emit-library <CMAKE_SHARED_LIBRARY_Swift_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <SONAME_FLAG> <TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
+ set(CMAKE_Swift_CREATE_SHARED_LIBRARY "<CMAKE_Swift_COMPILER> ${CMAKE_Swift_PARALLEL_FLAGS} -emit-library <CMAKE_SHARED_LIBRARY_Swift_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} <SONAME_FLAG> <TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
endif()
if(NOT CMAKE_Swift_CREATE_SHARED_MODULE)
diff --git a/Tests/RunCMake/Swift/ImportLibraryFlags-check-stdout.txt b/Tests/RunCMake/Swift/ImportLibraryFlags-check-stdout.txt
new file mode 100644
index 0000000..9b53820
--- /dev/null
+++ b/Tests/RunCMake/Swift/ImportLibraryFlags-check-stdout.txt
@@ -0,0 +1 @@
+.*-implib:lib\\L.lib
diff --git a/Tests/RunCMake/Swift/ImportLibraryFlags.cmake b/Tests/RunCMake/Swift/ImportLibraryFlags.cmake
new file mode 100644
index 0000000..4c76b40
--- /dev/null
+++ b/Tests/RunCMake/Swift/ImportLibraryFlags.cmake
@@ -0,0 +1,6 @@
+cmake_policy(SET CMP0157 NEW)
+enable_language(Swift)
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
+add_library(L SHARED L.swift)
diff --git a/Tests/RunCMake/Swift/RunCMakeTest.cmake b/Tests/RunCMake/Swift/RunCMakeTest.cmake
index b5210c9..56158e3 100644
--- a/Tests/RunCMake/Swift/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Swift/RunCMakeTest.cmake
@@ -78,6 +78,14 @@ elseif(RunCMake_GENERATOR STREQUAL Ninja)
endblock()
block()
+ if(CMAKE_SYSTEM_NAME MATCHES Windows)
+ set(ImportLibraryFlags_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SwiftLibraryModuleCommand-build)
+ run_cmake(ImportLibraryFlags)
+ run_cmake_command(ImportLibraryFlags-check ${CMAKE_COMMAND} --build ${SwiftLibraryModuleCommand_TEST_BINARY_DIR} -- -n -v)
+ endif()
+ endblock()
+
+ block()
set(SwiftLibraryModuleCommand_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SwiftLibraryModuleCommand-build)
run_cmake(SwiftLibraryModuleCommand)
run_cmake_command(SwiftLibraryModuleCommand-check ${CMAKE_COMMAND} --build ${SwiftLibraryModuleCommand_TEST_BINARY_DIR} -- -n -v)