set compiler and linker flags only for msvc

This commit is contained in:
HarpyWar 2018-05-09 01:01:46 +03:00
parent 9796253960
commit 70c654989e

View file

@ -46,26 +46,25 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message(FATAL_ERROR "Visual Studio 2015 or higher required")
endif()
# DEBUG compiler flags:
# /Zi create debugging information PDB file
# /Od disable optimizations
# /Oy- do not suppress frame pointers (recommended for debugging)
# /MTd use statically linked, thread-safe, debug CRT libs (Magic Builder set this flag when build)
#
# RELEASE compiler flags:
# /MT use statically linked, thread-safe CRT libs (Magic Builder set this flag when build)
# /GS- no Buffer Security Check
#
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Zi /Od /Oy-")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
# Explaining of linker flags and why enable pdb with debug info for Release build is on:
# https://www.wintellect.com/correctly-creating-native-c-release-build-pdbs
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
endif()
# DEBUG compiler flags:
# /Zi create debugging information PDB file
# /Od disable optimizations
# /Oy- do not suppress frame pointers (recommended for debugging)
# /MTd use statically linked, thread-safe, debug CRT libs (Magic Builder set this flag when build)
#
# RELEASE compiler flags:
# /MT use statically linked, thread-safe CRT libs (Magic Builder set this flag when build)
# /GS- no Buffer Security Check
#
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Zi /Od /Oy-")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
# Explaining of linker flags and why enable pdb with debug info for Release build is on:
# https://www.wintellect.com/correctly-creating-native-c-release-build-pdbs
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_STATIC_LINKER_FLAGS_RELEASEz} /DEBUG /OPT:REF /OPT:ICF")
subdirs(src conf man files)
if(WITH_LUA)
add_subdirectory(lua)