Commit 97c268f8 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

Windows, compiling . various cleanups, use /Zi instead of /Z7

parent 0efe50ec
...@@ -98,7 +98,7 @@ IF(MSVC) ...@@ -98,7 +98,7 @@ IF(MSVC)
SET(MSVC_CRT_TYPE /MT CACHE STRING SET(MSVC_CRT_TYPE /MT CACHE STRING
"Runtime library - specify runtime library for linking (/MT,/MTd,/MD,/MDd)" "Runtime library - specify runtime library for linking (/MT,/MTd,/MD,/MDd)"
) )
SET(VALID_CRT_TYPES /MTd /MDd /MD /MT) SET(VALID_CRT_TYPES /MTd /MDd /MD /MT)
IF (NOT ";${VALID_CRT_TYPES};" MATCHES ";${MSVC_CRT_TYPE};") IF (NOT ";${VALID_CRT_TYPES};" MATCHES ";${MSVC_CRT_TYPE};")
MESSAGE(FATAL_ERROR "Invalid value ${MSVC_CRT_TYPE} for MSVC_CRT_TYPE, choose one of /MT,/MTd,/MD,/MDd ") MESSAGE(FATAL_ERROR "Invalid value ${MSVC_CRT_TYPE} for MSVC_CRT_TYPE, choose one of /MT,/MTd,/MD,/MDd ")
ENDIF() ENDIF()
...@@ -107,6 +107,7 @@ IF(MSVC) ...@@ -107,6 +107,7 @@ IF(MSVC)
SET(DYNAMIC_UCRT_LINKER_OPTION " /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib") SET(DYNAMIC_UCRT_LINKER_OPTION " /NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib")
IF(WITH_ASAN) IF(WITH_ASAN)
SET(MSVC_CRT_TYPE /MD CACHE STRING FORCE)
ENABLE_ASAN() ENABLE_ASAN()
ENDIF() ENDIF()
...@@ -119,19 +120,11 @@ IF(MSVC) ...@@ -119,19 +120,11 @@ IF(MSVC)
"${CMAKE_${type}_LINKER_FLAGS_MINSIZEREL} /debug") "${CMAKE_${type}_LINKER_FLAGS_MINSIZEREL} /debug")
ENDFOREACH() ENDFOREACH()
# Force static runtime libraries # Force runtime libraries
# - Choose debugging information: # Compile with /Zi to get debugging information
# /Z7
# Produces an .obj file containing full symbolic debugging
# information for use with the debugger. The symbolic debugging
# information includes the names and types of variables, as well as
# functions and line numbers. No .pdb file is produced by the compiler.
#
# - Remove preprocessor flag _DEBUG that older cmakes use with Config=Debug,
# it is as defined by Debug runtimes itself (/MTd /MDd)
FOREACH(lang C CXX) FOREACH(lang C CXX)
SET(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} /Z7") SET(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} /Zi")
ENDFOREACH() ENDFOREACH()
FOREACH(flag FOREACH(flag
CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
...@@ -141,10 +134,8 @@ IF(MSVC) ...@@ -141,10 +134,8 @@ IF(MSVC)
CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL
) )
STRING(REGEX REPLACE "/M[TD][d]?" "${MSVC_CRT_TYPE}" "${flag}" "${${flag}}" ) STRING(REGEX REPLACE "/M[TD][d]?" "${MSVC_CRT_TYPE}" "${flag}" "${${flag}}" )
STRING(REGEX REPLACE "/D[ ]?_DEBUG" "" "${flag}" "${${flag}}") IF(NOT "${${flag}}" MATCHES "/Zi")
STRING(REPLACE "/Zi" "/Z7" "${flag}" "${${flag}}") STRING(APPEND ${flag} " /Zi")
IF(NOT "${${flag}}" MATCHES "/Z7")
STRING(APPEND ${flag} " /Z7")
ENDIF() ENDIF()
ENDFOREACH() ENDFOREACH()
...@@ -157,7 +148,6 @@ IF(MSVC) ...@@ -157,7 +148,6 @@ IF(MSVC)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_CL_FLAGS}") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CLANG_CL_FLAGS}")
ENDIF() ENDIF()
# Fix CMake's predefined huge stack size
FOREACH(type EXE SHARED MODULE) FOREACH(type EXE SHARED MODULE)
STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS "${CMAKE_${type}_LINKER_FLAGS}") STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS "${CMAKE_${type}_LINKER_FLAGS}")
STRING(REGEX REPLACE "/INCREMENTAL:([^ ]+)" "/INCREMENTAL:NO" CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO}") STRING(REGEX REPLACE "/INCREMENTAL:([^ ]+)" "/INCREMENTAL:NO" CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO}")
...@@ -180,7 +170,7 @@ IF(MSVC) ...@@ -180,7 +170,7 @@ IF(MSVC)
ENDIF() ENDIF()
# Speed up multiprocessor build # Speed up multiprocessor build
IF (MSVC_VERSION GREATER 1400 AND (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)) IF (NOT CMAKE_CXX_COMPILER_ID MATCHES Clang)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ENDIF() ENDIF()
......
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