Skip to content

Commit af8fc10

Browse files
committed
build: install the import libraries for windows
When building the target libraries, we need to install the import library as well. Unfortunately, due to the way that the swift build system works, we do not have the ability to rely on CMake doing the right thing and taking care of this for us. We have to manually construct and track the import library due to the fact that we fight the cross-compilation support. Add some logic to extract the import libraries and install them so that uses can actually build for Windows.
1 parent 6b68303 commit af8fc10

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

cmake/modules/AddSwift.cmake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2223,8 +2223,19 @@ function(add_swift_target_library name)
22232223
FILES "${UNIVERSAL_LIBRARY_NAME}"
22242224
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}"
22252225
PERMISSIONS ${file_permissions})
2226-
swift_is_installing_component("${SWIFTLIB_INSTALL_IN_COMPONENT}" is_installing)
2226+
if(sdk STREQUAL WINDOWS)
2227+
foreach(arch ${SWIFT_SDK_WINDOWS_ARCHITECTURES})
2228+
if(TARGET ${name}-windows-${arch}_IMPLIB)
2229+
get_target_property(import_library ${name}-windows-${arch}_IMPLIB IMPORTED_LOCATION)
2230+
swift_install_in_component(${SWIFTLIB_INSTALL_IN_COMPONENT}
2231+
FILES ${import_library}
2232+
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/${resource_dir}/${resource_dir_sdk_subdir}/${arch}"
2233+
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
2234+
endif()
2235+
endforeach()
2236+
endif()
22272237

2238+
swift_is_installing_component("${SWIFTLIB_INSTALL_IN_COMPONENT}" is_installing)
22282239
if(NOT is_installing)
22292240
set_property(GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS ${VARIANT_NAME})
22302241
else()

0 commit comments

Comments
 (0)