From c26a80208b162ebfd4aab87deb06f490016d9d9e Mon Sep 17 00:00:00 2001 From: Shoaib Meenai Date: Fri, 5 Oct 2018 00:08:27 +0000 Subject: [PATCH] [cmake] Also create lowercase extension WinSDK symlinks Some projects rely on using libraries from the Windows SDK with their original casing, just with a lowercase extension. E.g. the WinSock2 lib is named WS2_32.Lib in the Windows SDK, and we would previously only create a ws2_32.lib symlink for it (i.e. all lowercase). Also create a WS2_32.lib symlink (i.e. original casing with lowercase extension) to cover users of this casing. As a drive-by fix, only create these symlinks when they differ from the original name to reduce the amount of noise in the library symlinks directory. llvm-svn: 343832 --- cmake/platforms/WinMsvc.cmake | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/cmake/platforms/WinMsvc.cmake b/cmake/platforms/WinMsvc.cmake index a736a457872..f625d0e3c05 100644 --- a/cmake/platforms/WinMsvc.cmake +++ b/cmake/platforms/WinMsvc.cmake @@ -136,11 +136,25 @@ function(generate_winsdk_lib_symlinks winsdk_um_lib_dir output_dir) execute_process(COMMAND "${CMAKE_COMMAND}" -E make_directory "${output_dir}") file(GLOB libraries RELATIVE "${winsdk_um_lib_dir}" "${winsdk_um_lib_dir}/*") foreach(library ${libraries}) - string(TOLOWER "${library}" symlink_name) - execute_process(COMMAND "${CMAKE_COMMAND}" - -E create_symlink - "${winsdk_um_lib_dir}/${library}" - "${output_dir}/${symlink_name}") + string(TOLOWER "${library}" all_lowercase_symlink_name) + if(NOT library STREQUAL all_lowercase_symlink_name) + execute_process(COMMAND "${CMAKE_COMMAND}" + -E create_symlink + "${winsdk_um_lib_dir}/${library}" + "${output_dir}/${all_lowercase_symlink_name}") + endif() + + 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 AND + NOT all_lowercase_symlink_name STREQUAL lowercase_ext_symlink_name) + execute_process(COMMAND "${CMAKE_COMMAND}" + -E create_symlink + "${winsdk_um_lib_dir}/${library}" + "${output_dir}/${lowercase_ext_symlink_name}") + endif() endforeach() endfunction()