build: workaround incorrectly cased import libraries in WinSDK

The Windows SDK proides kernel32.Lib which on case sensitive file systems will
fail (due to the capital L in the extension).  Workaround that by creating
symbolic links to handle this.  This mirrors the technique used in LLVM.
This commit is contained in:
Saleem Abdulrasool
2018-10-12 14:43:29 -07:00
parent 2f4b9e6e56
commit dae761fbd5
2 changed files with 25 additions and 0 deletions

View File

@@ -282,6 +282,26 @@ macro(configure_sdk_windows name environment architectures)
# to the driver -- rely on the `INCLUDE` AND `LIB` environment variables
# instead.
set(SWIFT_SDK_${prefix}_ARCH_${arch}_PATH "/")
# NOTE(compnerd) workaround incorrectly extensioned import libraries from
# the Windows SDK on case sensitive file systems.
swift_windows_arch_spelling(${arch} WinSDKArchitecture)
set(WinSDK${arch}UMDir "$ENV{UniversalCRTSdkDir}/Lib/$ENV{UCRTVersion}/um/${WinSDKArchitecture}")
set(OverlayDirectory "${CMAKE_BINARY_DIR}/winsdk_lib_${arch}_symlinks")
file(MAKE_DIRECTORY ${OverlayDirectory})
file(GLOB libraries RELATIVE "${WinSDK${arch}UMDir}" "${WinSDK${arch}UMDir}/*")
foreach(library ${libraries})
get_filename_component(name_we "${library}" NAME_WE)
get_filename_component(ext "${library}" EXT)
string(TOLOWER "${ext}" lowercase_ext)
set(lowercase_ext_symlink_name "${name_we}${lowercase_ext}")
if(NOT library STREQUAL lowercase_ext_symlink_name)
execute_process(COMMAND
"${CMAKE_COMMAND}" -E create_symlink "${WinSDK${arch}UMDir}/${library}" "${OverlayDirectory}/${lowercase_ext_symlink_name}")
endif()
endforeach()
endforeach()
# Add this to the list of known SDKs.