Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,17 @@ if (${TARGET_PLATFORM} STREQUAL "x64")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /CETCOMPAT")
endif()

# Hybrid CRT: static-link the C++ runtime and STL (/MT|/MTd from CMAKE_MSVC_RUNTIME_LIBRARY),
# but dynamic-link the Universal CRT (ucrt.dll) which is an OS component on Windows 10+.
# This eliminates the VCRUNTIME/MSVCP redistributable dependency while avoiding the size
# cost of statically linking the UCRT. See https://aka.ms/hybridcrt for details.
foreach(config RELEASE RELWITHDEBINFO MINSIZEREL)
set(CMAKE_SHARED_LINKER_FLAGS_${config} "${CMAKE_SHARED_LINKER_FLAGS_${config}} /NODEFAULTLIB:libucrt.lib /defaultlib:ucrt.lib")
set(CMAKE_EXE_LINKER_FLAGS_${config} "${CMAKE_EXE_LINKER_FLAGS_${config}} /NODEFAULTLIB:libucrt.lib /defaultlib:ucrt.lib")
endforeach()
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libucrtd.lib /defaultlib:ucrtd.lib")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libucrtd.lib /defaultlib:ucrtd.lib")

# Common link libraries
link_directories(${WSLDEPS_SOURCE_DIR}/lib/)
set(COMMON_LINK_LIBRARIES
Expand Down