Commit 08935483 authored by Abseil Team's avatar Abseil Team Committed by Copybara-Service
Browse files

Makes Clang compilations via Ninja on Windows define _DLL only for shared CRT...

Makes Clang compilations via Ninja on Windows define _DLL only for shared CRT builds, as one would already expect from MSVC builds. (Previously, static Clang/Ninja builds on Windows also implicitly defined _DLL, which was problematic.)

PiperOrigin-RevId: 479113168
Change-Id: I252d9be90fd33df75dab922e62b197208830d124
parent 4052e05c
......@@ -21,8 +21,9 @@ endif (POLICY CMP0054)
# This must be a macro(), as inside a function string() can only
# update variables in the function scope.
macro(fix_default_compiler_settings_)
if (MSVC)
# For MSVC, CMake sets certain flags to defaults we want to override.
if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC|Clang")
# For MSVC and Clang, CMake sets certain flags to defaults we want to
# override.
# This replacement code is taken from sample in the CMake Wiki at
# https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace.
foreach (flag_var
......@@ -39,6 +40,10 @@ macro(fix_default_compiler_settings_)
# on CRT DLLs being available. CMake always defaults to using shared
# CRT libraries, so we override that default here.
string(REPLACE "/MD" "-MT" ${flag_var} "${${flag_var}}")
# When using Ninja with Clang, static builds pass -D_DLL on Windows.
# This is incorrect and should not happen, so we fix that here.
string(REPLACE "-D_DLL" "" ${flag_var} "${${flag_var}}")
endif()
# We prefer more strict warning checking for building Google Test.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment