summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-03-13 13:37:07 +0000
committerAlexey Samsonov <samsonov@google.com>2014-03-13 13:37:07 +0000
commit1f0808c4fc2754b5c99c473bd488a7ab0e6af901 (patch)
treeea2c31ebb9e9fc29b3678dcbf2f94dd2a414cf3e /CMakeLists.txt
parent9cdcf37ef1c7cf59dea0fecb1938f77d60324d70 (diff)
[CMake] More fixes for Windows build
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@203798 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt13
1 files changed, 5 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5502bc124..aa175c3e3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -264,20 +264,17 @@ append_if(COMPILER_RT_HAS_FNO_FUNCTION_SECTIONS_FLAG -fno-function-sections SANI
if(MSVC)
# Remove /MD flag so that it doesn't conflict with /MT.
if(COMPILER_RT_HAS_MT_FLAG)
- string(REGEX REPLACE "(^| ) */MD *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ string(REGEX REPLACE "(^| ) */MDd? *( |$)" "\\1 \\2" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
list(APPEND SANITIZER_COMMON_CFLAGS /MT)
endif()
append_if(COMPILER_RT_HAS_Oy_FLAG /Oy- SANITIZER_COMMON_CFLAGS)
append_if(COMPILER_RT_HAS_GS_FLAG /GS- SANITIZER_COMMON_CFLAGS)
endif()
-# Build with optimization, unless we're in debug mode.
-if(NOT COMPILER_RT_DEBUG)
- if(MSVC)
- list(APPEND SANITIZER_COMMON_CFLAGS /O2)
- else()
- list(APPEND SANITIZER_COMMON_CFLAGS -O3)
- endif()
+# Build with optimization, unless we're in debug mode. If we're using MSVC,
+# always respect the optimization flags set by CMAKE_BUILD_TYPE instead.
+if(NOT COMPILER_RT_DEBUG AND NOT MSVC)
+ list(APPEND SANITIZER_COMMON_CFLAGS -O3)
endif()
# Build sanitizer runtimes with debug info.