1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-17 07:11:52 +08:00

MSVC: Fix regression that links shared libraries with bogus -shared flag

Clear `CMAKE_SHARED_LIBRARY_CREATE_<LANG>_FLAGS` since no special
link flags are needed to create a DLL with MSVC toolchains.
Our shared library creation rules never referenced that placeholder,
so this variable was never used until commit 951e4d3f62 (Ninja,Makefile:
Move builtin linker flags to <LINK_FLAGS> placeholder, 2025-06-09,
v4.1.0-rc1~37^2~2) taught the generators to look it up directly.

This was not previously noticed because the `-shared` flag
is ignored unless the `-WX` flag enables an error on it.

Fixes: #27106
This commit is contained in:
Brad King
2025-08-01 12:31:45 -04:00
parent f4effce6a4
commit e349b471d8

View File

@@ -393,6 +393,7 @@ macro(__windows_compiler_msvc lang)
set(_CMAKE_VS_LINK_DLL "<CMAKE_COMMAND> -E vs_link_dll --msvc-ver=${MSVC_VERSION} --intdir=<OBJECT_DIR> --rc=<CMAKE_RC_COMPILER> --mt=<CMAKE_MT> --manifests <MANIFESTS> -- ")
set(_CMAKE_VS_LINK_EXE "<CMAKE_COMMAND> -E vs_link_exe --msvc-ver=${MSVC_VERSION} --intdir=<OBJECT_DIR> --rc=<CMAKE_RC_COMPILER> --mt=<CMAKE_MT> --manifests <MANIFESTS> -- ")
endif()
set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "")
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsKernelModeDriver")
set(_DLL_DRIVER "-driver")
else()