Skip to content

Windows cross compilation #12480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 43 additions & 25 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -486,11 +486,8 @@ function(_add_swift_lipo_target)
DEPENDS ${source_targets})
else()
# We don't know how to create fat binaries for other platforms.
add_custom_command_target(unused_var
COMMAND "${CMAKE_COMMAND}" "-E" "copy" "${source_binaries}" "${LIPO_OUTPUT}"
CUSTOM_TARGET_NAME "${LIPO_TARGET}"
OUTPUT "${LIPO_OUTPUT}"
DEPENDS ${source_targets})
add_custom_target(${LIPO_TARGET})
add_dependencies(${LIPO_TARGET} ${source_targets})
endif()
endfunction()

Expand Down Expand Up @@ -1636,8 +1633,11 @@ function(add_swift_library name)
# Add dependencies on the (not-yet-created) custom lipo target.
foreach(DEP ${SWIFTLIB_LINK_LIBRARIES})
if (NOT "${DEP}" STREQUAL "icucore")
add_dependencies(${VARIANT_NAME}
"${DEP}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "MACHO")
add_dependencies(${VARIANT_NAME} "${DEP}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
else()
add_dependencies(${VARIANT_NAME} "${DEP}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")
endif()
endif()
endforeach()

Expand Down Expand Up @@ -1681,12 +1681,14 @@ function(add_swift_library name)
set(codesign_arg CODESIGN)
endif()
precondition(THIN_INPUT_TARGETS)
_add_swift_lipo_target(
SDK ${sdk}
TARGET ${lipo_target}
OUTPUT ${UNIVERSAL_LIBRARY_NAME}
${codesign_arg}
${THIN_INPUT_TARGETS})
_add_swift_lipo_target(SDK
${sdk}
TARGET
${lipo_target}
OUTPUT
${UNIVERSAL_LIBRARY_NAME}
${codesign_arg}
${THIN_INPUT_TARGETS})

# Cache universal libraries for dependency purposes
set(UNIVERSAL_LIBRARY_NAMES_${SWIFT_SDK_${sdk}_LIB_SUBDIR}
Expand Down Expand Up @@ -1732,11 +1734,13 @@ function(add_swift_library name)
"${name}-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-static")
set(UNIVERSAL_LIBRARY_NAME
"${SWIFTSTATICLIB_DIR}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${name}${CMAKE_STATIC_LIBRARY_SUFFIX}")
_add_swift_lipo_target(
SDK ${sdk}
TARGET ${lipo_target_static}
OUTPUT "${UNIVERSAL_LIBRARY_NAME}"
${THIN_INPUT_TARGETS_STATIC})
_add_swift_lipo_target(SDK
${sdk}
TARGET
${lipo_target_static}
OUTPUT
"${UNIVERSAL_LIBRARY_NAME}"
${THIN_INPUT_TARGETS_STATIC})
swift_install_in_component("${SWIFTLIB_INSTALL_IN_COMPONENT}"
FILES "${UNIVERSAL_LIBRARY_NAME}"
DESTINATION "lib${LLVM_LIBDIR_SUFFIX}/swift_static/${resource_dir_sdk_subdir}"
Expand All @@ -1749,17 +1753,31 @@ function(add_swift_library name)
# Add Swift standard library targets as dependencies to the top-level
# convenience target.
if(SWIFTLIB_TARGET_LIBRARY)
set(FILTERED_UNITTESTS
swiftStdlibCollectionUnittest
swiftStdlibUnicodeUnittest)

foreach(arch ${SWIFT_SDK_${sdk}_ARCHITECTURES})
set(VARIANT_SUFFIX "-${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}")
if(TARGET "swift-stdlib${VARIANT_SUFFIX}" AND TARGET "swift-test-stdlib${VARIANT_SUFFIX}")
if(TARGET "swift-stdlib${VARIANT_SUFFIX}" AND
TARGET "swift-test-stdlib${VARIANT_SUFFIX}")
if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "MACHO")
set(shared_lipo_target ${lipo_target})
set(static_lipo_target ${lipo_target_static})
else()
set(shared_lipo_target ${lipo_target}-${arch})
if(TARGET "${lipo_target_static}")
set(static_lipo_target ${lipo_target_static}-${arch})
endif()
endif()

add_dependencies("swift-stdlib${VARIANT_SUFFIX}"
${lipo_target}
${lipo_target_static})
if((NOT "${name}" STREQUAL "swiftStdlibCollectionUnittest") AND
(NOT "${name}" STREQUAL "swiftStdlibUnicodeUnittest"))
${shared_lipo_target}
${static_lipo_target})
if(NOT "${name}" IN_LIST FILTERED_UNITTESTS)
add_dependencies("swift-test-stdlib${VARIANT_SUFFIX}"
${lipo_target}
${lipo_target_static})
${shared_lipo_target}
${static_lipo_target})
endif()
endif()
endforeach()
Expand Down