From 55196a1440e26917d40e6a7a3eb8d9fb323fa657 Mon Sep 17 00:00:00 2001 From: Francisco Facioni Date: Fri, 10 Jan 2020 14:03:25 +0000 Subject: [PATCH] MSVC: Use 'lib' instead of 'link /lib' to create static libraries `link.exe /lib` is an undocumented flag and it just calls `lib.exe`. Also `link.exe` doesn't parse the `/lib` option correctly when in a response file. --- Modules/CMakeCUDACompiler.cmake.in | 1 + Modules/CMakeFindBinUtils.cmake | 1 + Modules/Platform/Windows-Intel.cmake | 2 +- Modules/Platform/Windows-MSVC.cmake | 2 +- Modules/Platform/Windows-NVIDIA-CUDA.cmake | 2 +- 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index 4a615a39bb..14a39a9b5d 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -54,4 +54,5 @@ set(CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES@ set(CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CUDA_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") set(CMAKE_LINKER "@CMAKE_LINKER@") +set(CMAKE_AR "@CMAKE_AR@") set(CMAKE_MT "@CMAKE_MT@") diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index c23e447425..de9ef9a234 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -75,6 +75,7 @@ if(("x${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_SIMULATE_ID}" STREQUAL "xMSVC" AND endif() find_program(CMAKE_LINKER NAMES ${_CMAKE_ADDITIONAL_LINKER_NAMES} link HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_AR NAMES lib HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_MT NAMES mt HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) list(APPEND _CMAKE_TOOL_VARS LINKER MT) diff --git a/Modules/Platform/Windows-Intel.cmake b/Modules/Platform/Windows-Intel.cmake index 96b1760abf..5d8f7fc35f 100644 --- a/Modules/Platform/Windows-Intel.cmake +++ b/Modules/Platform/Windows-Intel.cmake @@ -11,7 +11,7 @@ set(__WINDOWS_INTEL 1) include(Platform/Windows-MSVC) macro(__windows_compiler_intel lang) __windows_compiler_msvc(${lang}) - string(REPLACE " /lib" "xilib" CMAKE_${lang}_CREATE_STATIC_LIBRARY "${CMAKE_${lang}_CREATE_STATIC_LIBRARY}") + string(REPLACE "" "xilib" CMAKE_${lang}_CREATE_STATIC_LIBRARY "${CMAKE_${lang}_CREATE_STATIC_LIBRARY}") foreach(rule CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE) string(REPLACE "" "xilink" CMAKE_${lang}_${rule} "${CMAKE_${lang}_${rule}}") endforeach() diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index e1d6733f26..7ee501bc5e 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -316,7 +316,7 @@ macro(__windows_compiler_msvc lang) "${_CMAKE_VS_LINK_DLL} ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /implib: /pdb: /dll /version:.${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY}) - set(CMAKE_${lang}_CREATE_STATIC_LIBRARY " /lib ${CMAKE_CL_NOLOGO} /out: ") + set(CMAKE_${lang}_CREATE_STATIC_LIBRARY " ${CMAKE_CL_NOLOGO} /out: ") set(CMAKE_${lang}_COMPILE_OBJECT " ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} /Fo /Fd${_FS_${lang}} -c ${CMAKE_END_TEMP_FILE}") diff --git a/Modules/Platform/Windows-NVIDIA-CUDA.cmake b/Modules/Platform/Windows-NVIDIA-CUDA.cmake index f809094e71..af43f46d11 100644 --- a/Modules/Platform/Windows-NVIDIA-CUDA.cmake +++ b/Modules/Platform/Windows-NVIDIA-CUDA.cmake @@ -23,7 +23,7 @@ set(CMAKE_CUDA_CREATE_SHARED_LIBRARY "${_CMAKE_VS_LINK_DLL} ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /implib: /pdb: /dll /version:.${_PLATFORM_LINK_FLAGS} ${__IMPLICT_LINKS} ${CMAKE_END_TEMP_FILE}") set(CMAKE_CUDA_CREATE_SHARED_MODULE ${CMAKE_CUDA_CREATE_SHARED_LIBRARY}) -set(CMAKE_CUDA_CREATE_STATIC_LIBRARY " /lib ${CMAKE_CL_NOLOGO} /out: ") +set(CMAKE_CUDA_CREATE_STATIC_LIBRARY " ${CMAKE_CL_NOLOGO} /out: ") set(CMAKE_CUDA_LINKER_SUPPORTS_PDB ON) set(CMAKE_CUDA_LINK_EXECUTABLE "${_CMAKE_VS_LINK_EXE} ${CMAKE_CL_NOLOGO} ${CMAKE_START_TEMP_FILE} /out: /implib: /pdb: /version:.${_PLATFORM_LINK_FLAGS} ${__IMPLICT_LINKS} ${CMAKE_END_TEMP_FILE}")