[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
This commit is contained in:
Shoaib Meenai 2018-10-05 00:08:27 +00:00
parent 5f74590867
commit c26a80208b

View File

@ -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)
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}/${symlink_name}")
"${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()