Skip to content

Commit 9b02e8d

Browse files
committed
[libcxx] Respect CMAKE_MSVC_RUNTIME_LIBRARY wrt whether to use the debug CRT
If CMAKE_MSVC_RUNTIME_LIBRARY isn't set, then CMake defaults to the debug CRT, if CMAKE_BUILD_TYPE is set to Debug. If CMAKE_MSVC_RUNTIME_LIBRARY is set though, that overrides any implicit defaults. Match this in libcxx's own manual linking logic. This allows decoupling the debug CRT from the CMAKE_BUILD_TYPE and allows users to configure their builds exactly how they want. Differential Revision: https://reviews.llvm.org/D155561
1 parent 9853e9b commit 9b02e8d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

libcxx/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,8 @@ function(cxx_link_system_libraries target)
682682
endif()
683683

684684
if (MSVC)
685-
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
685+
if ((NOT CMAKE_MSVC_RUNTIME_LIBRARY AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
686+
OR (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "Debug"))
686687
set(LIB_SUFFIX "d")
687688
else()
688689
set(LIB_SUFFIX "")

libcxx/test/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ if (MSVC)
5959
set(cxx_lib "libcpmt")
6060
endif()
6161

62-
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
62+
if ((NOT CMAKE_MSVC_RUNTIME_LIBRARY AND uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
63+
OR (CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "Debug"))
6364
set(dbg_include " -D_DEBUG -include set_windows_crt_report_mode.h")
6465
set(crt_lib "${crt_lib}d")
6566
set(cxx_lib "${cxx_lib}d")

0 commit comments

Comments
 (0)