Browse Source

Merge topic 'swift-implib'

a2aad7eb8d Swift: fix Windows DLL import library support for CMP0157 NEW

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Acked-by: Jeremy Day <[email protected]>
Merge-request: !9140
Brad King 1 year ago
parent
commit
97713da650

+ 1 - 1
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)

+ 1 - 0
Tests/RunCMake/Swift/ImportLibraryFlags-check-stdout.txt

@@ -0,0 +1 @@
+.*-implib:lib\\L.lib

+ 6 - 0
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)

+ 8 - 0
Tests/RunCMake/Swift/RunCMakeTest.cmake

@@ -77,6 +77,14 @@ elseif(RunCMake_GENERATOR STREQUAL Ninja)
       run_cmake_command(ForceResponseFile-check ${CMAKE_COMMAND} --build ${ForceResponseFile_TEST_BINARY_DIR} -- -vn)
     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)