[PATCH] D155431: [CMake] Clean up old code for handling MSVC runtime setting the old way
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 28 05:51:43 PDT 2023
mstorsjo added a comment.
In D155431#4651666 <https://reviews.llvm.org/D155431#4651666>, @yurybura wrote:
>> That define should be set implicitly if `CMAKE_MSVC_RUNTIME_LIBRARY` is set to one of the debug choices, no?
>
> I think, no. At least I cannot find information about this in CMake documentation <https://cmake.org/cmake/help/latest/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html>.
It's not set explicitly by CMake, but if you set `CMAKE_MSVC_RUNTIME_LIBRARY` to `MultiThreadedDebug` or `MultiThreadedDebugDLL`, it passes `-MTd` or `-MDd` to the compiler. When the compiler gets either of those, it implicitly sets `-D_DEBUG`. Example:
$ cat crtdefs.c
#ifdef _DEBUG
#error _DEBUG
#endif
$ cl -c crtdefs.c -MDd
Microsoft (R) C/C++ Optimizing Compiler Version 19.30.30705 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
crtdefs.c
crtdefs.c(2): fatal error C1189: #error: _DEBUG
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155431/new/
https://reviews.llvm.org/D155431
More information about the llvm-commits
mailing list