summaryrefslogtreecommitdiffstats
path: root/googletest/cmake
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2022-10-05 19:26:54 (GMT)
committerCopybara-Service <copybara-worker@google.com>2022-10-05 19:27:31 (GMT)
commit08935483cb22749b3c3774e9bcd5ef35b5a1a7b7 (patch)
tree406fa878e49b7f2734c607de4510542987cba201 /googletest/cmake
parent4052e05c296c6ca7387c12a9cb41749320ffe8d0 (diff)
downloadgoogletest-08935483cb22749b3c3774e9bcd5ef35b5a1a7b7.zip
googletest-08935483cb22749b3c3774e9bcd5ef35b5a1a7b7.tar.gz
googletest-08935483cb22749b3c3774e9bcd5ef35b5a1a7b7.tar.bz2
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
Diffstat (limited to 'googletest/cmake')
-rw-r--r--googletest/cmake/internal_utils.cmake9
1 files changed, 7 insertions, 2 deletions
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake
index 6f7fdc2..4140558 100644
--- a/googletest/cmake/internal_utils.cmake
+++ b/googletest/cmake/internal_utils.cmake
@@ -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.