Changed: Move /X in build flags, only Debug and Release (default) modes, link flags are set automatically to all projects
This commit is contained in:
parent
cacd5be701
commit
5ed290b256
2 changed files with 46 additions and 49 deletions
|
@ -40,6 +40,10 @@ INCLUDE(${CMAKE_ROOT}/Modules/Documentation.cmake OPTIONAL)
|
|||
# Force out of source builds.
|
||||
CHECK_OUT_OF_SOURCE()
|
||||
|
||||
# Variables which must be set before PROJECT
|
||||
NL_SETUP_BUILD()
|
||||
NL_SETUP_BUILD_FLAGS()
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
PROJECT(RyzomCore CXX C)
|
||||
SET(NL_VERSION_MAJOR 0)
|
||||
|
@ -108,14 +112,9 @@ IF(WITH_STLPORT)
|
|||
STRING(REGEX REPLACE "Common7/IDE/.+" "VC/include" VC_INCLUDE_DIR ${CMAKE_MAKE_PROGRAM})
|
||||
# use VC++ and Windows SDK include paths
|
||||
INCLUDE_DIRECTORIES(${VC_INCLUDE_DIR} ${WINSDK_INCLUDE_DIR})
|
||||
# deactivate all global include paths
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /X")
|
||||
ENDIF(WIN32)
|
||||
ENDIF(WITH_STLPORT)
|
||||
|
||||
NL_SETUP_BUILD()
|
||||
NL_SETUP_BUILD_FLAGS()
|
||||
|
||||
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/PCHSupport.cmake)
|
||||
|
||||
IF(FINAL_VERSION)
|
||||
|
|
|
@ -65,9 +65,9 @@ ENDMACRO(NL_ADD_LIB_SUFFIX)
|
|||
###
|
||||
MACRO(NL_ADD_RUNTIME_FLAGS name)
|
||||
IF(WIN32)
|
||||
SET_TARGET_PROPERTIES(${name} PROPERTIES
|
||||
LINK_FLAGS_DEBUG "${CMAKE_LINK_FLAGS_DEBUG}"
|
||||
LINK_FLAGS_RELEASE "${CMAKE_LINK_FLAGS_RELEASE}")
|
||||
# SET_TARGET_PROPERTIES(${name} PROPERTIES
|
||||
# LINK_FLAGS_DEBUG "${CMAKE_LINK_FLAGS_DEBUG}"
|
||||
# LINK_FLAGS_RELEASE "${CMAKE_LINK_FLAGS_RELEASE}")
|
||||
ENDIF(WIN32)
|
||||
IF(WITH_STLPORT)
|
||||
TARGET_LINK_LIBRARIES(${name} ${STLPORT_LIBRARIES})
|
||||
|
@ -261,9 +261,9 @@ MACRO(NL_SETUP_BUILD)
|
|||
#
|
||||
# None = NL_RELEASE
|
||||
# Debug = NL_DEBUG
|
||||
# Release = NL_RELEASE, NL_NO_DEBUG
|
||||
# RelWithDebInfo = NL_RELEASE
|
||||
# MinSizeRel = NL_RELEASE, NL_NO_DEBUG
|
||||
# Release = NL_RELEASE
|
||||
|
||||
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
|
||||
|
||||
IF(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
SET(NL_BUILD_MODE "NL_DEBUG")
|
||||
|
@ -273,41 +273,46 @@ MACRO(NL_SETUP_BUILD)
|
|||
ELSE(CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
SET(NL_BUILD_MODE "NL_RELEASE")
|
||||
# enforce release mode if it's neither Debug nor Release
|
||||
SET(CMAKE_BUILD_TYPE "Release")
|
||||
SET(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
|
||||
ENDIF(CMAKE_BUILD_TYPE MATCHES "Release")
|
||||
ENDIF(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
|
||||
IF(WIN32)
|
||||
# don't use a /O[012x] flag if you want custom optimizations
|
||||
SET(SPEED_OPTIMIZATIONS "/Ob2 /Oi /Ot /Oy /GT /GF /GS-")
|
||||
SET(SIZE_OPTIMIZATIONS "/O1")
|
||||
# without inlining it's unusable, use custom optimizations again
|
||||
SET(MIN_OPTIMIZATIONS "/Ob1")
|
||||
|
||||
SET(CMAKE_C_FLAGS_DEBUG "/MDd /Zi /RTC1 /D_DEBUG ${MIN_OPTIMIZATIONS}")
|
||||
SET(CMAKE_C_FLAGS_RELEASE "/MD /Zi /D NDEBUG ${SPEED_OPTIMIZATIONS}")
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/MD /Zi /D NDEBUG ${SPEED_OPTIMIZATIONS}")
|
||||
SET(CMAKE_C_FLAGS_MINSIZEREL "/MD /D NDEBUG ${SIZE_OPTIMIZATIONS}")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
|
||||
SET(CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL})
|
||||
SET(PLATFORM_CFLAGS "/D_CRT_SECURE_NO_WARNINGS /DWIN32 /D_WINDOWS /W3 /Zi")
|
||||
|
||||
SET(NL_DEBUG_CFLAGS "/EHa /Zi")
|
||||
SET(NL_RELEASE_CFLAGS "/EHa /Zi")
|
||||
SET(NL_DEBUG_LINK_FLAGS "/NODEFAULTLIB:msvcrt")
|
||||
SET(NL_RELEASE_LINK_FLAGS "/OPT:REF /OPT:ICF")
|
||||
IF(WITH_STLPORT)
|
||||
# deactivate all global include paths
|
||||
SET(PLATFORM_CFLAGS "${PLATFORM_CFLAGS} /X")
|
||||
ENDIF(WITH_STLPORT)
|
||||
|
||||
# Exceptions are only set for C++
|
||||
SET(PLATFORM_CXXFLAGS "${PLATFORM_CFLAGS} /EHa")
|
||||
|
||||
# Common link flags
|
||||
SET(PLATFORM_LINKFLAGS "-DEBUG")
|
||||
|
||||
SET(NL_DEBUG_CFLAGS "/MDd /RTC1 /D_DEBUG ${MIN_OPTIMIZATIONS}")
|
||||
SET(NL_RELEASE_CFLAGS "/MD /D NDEBUG ${SPEED_OPTIMIZATIONS}")
|
||||
SET(NL_DEBUG_LINKFLAGS "/NODEFAULTLIB:msvcrt /INCREMENTAL:YES")
|
||||
SET(NL_RELEASE_LINKFLAGS "/OPT:REF /OPT:ICF /INCREMENTAL:NO")
|
||||
ELSE(WIN32)
|
||||
SET(PLATFORM_CFLAGS "-ftemplate-depth-48 -D_REENTRANT -Wall -ansi -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-long-long -Wno-unused -fno-strict-aliasing")
|
||||
SET(PLATFORM_CFLAGS "-g -ftemplate-depth-48 -D_REENTRANT -Wall -ansi -W -Wpointer-arith -Wsign-compare -Wno-deprecated-declarations -Wno-multichar -Wno-unused -fno-strict-aliasing")
|
||||
IF(WITH_COVERAGE)
|
||||
SET(PLATFORM_CFLAGS "-fprofile-arcs -ftest-coverage ${PLATFORM_CFLAGS}")
|
||||
ENDIF(WITH_COVERAGE)
|
||||
SET(PLATFORM_CXXFLAGS ${PLATFORM_CFLAGS})
|
||||
|
||||
IF(NOT APPLE)
|
||||
SET(PLATFORM_LINKFLAGS "-Wl,--no-undefined -Wl,--as-needed")
|
||||
ENDIF(NOT APPLE)
|
||||
SET(NL_DEBUG_CFLAGS "-DNL_DEBUG -g")
|
||||
SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -O6 -g")
|
||||
SET(NL_NONE_CFLAGS "-DNL_RELEASE -g -finline-functions -O2 ")
|
||||
|
||||
SET(NL_DEBUG_CFLAGS "-DNL_DEBUG -D_DEBUG")
|
||||
SET(NL_RELEASE_CFLAGS "-DNL_RELEASE -DNDEBUG -O6")
|
||||
ENDIF(WIN32)
|
||||
|
||||
# Determine host CPU
|
||||
|
@ -334,29 +339,22 @@ MACRO(NL_SETUP_BUILD_FLAGS)
|
|||
#SET(CMAKE_DEBUG_POSTFIX "_d")
|
||||
#SET(CMAKE_RELEASE_POSTFIX "_r")
|
||||
|
||||
## None
|
||||
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${NL_NONE_CFLAGS} ${PLATFORM_CFLAGS} ")
|
||||
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${NL_NONE_CFLAGS} ${PLATFORM_CFLAGS} ")
|
||||
|
||||
SET(CMAKE_C_FLAGS ${PLATFORM_CFLAGS} CACHE STRING "" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS ${PLATFORM_CXXFLAGS} CACHE STRING "" FORCE)
|
||||
|
||||
## Debug
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${NL_DEBUG_CFLAGS} ${PLATFORM_CFLAGS} ")
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${NL_DEBUG_CFLAGS} ${PLATFORM_CFLAGS} ")
|
||||
SET(CMAKE_LINK_FLAGS_DEBUG "${CMAKE_LINK_FLAGS_DEBUG} ${NL_DEBUG_LINK_FLAGS} ${PLATFORM_LINKFLAGS} ")
|
||||
SET(CMAKE_C_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS_DEBUG ${NL_DEBUG_CFLAGS} CACHE STRING "" FORCE)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${PLATFORM_LINKFLAGS} ${NL_DEBUG_LINKFLAGS}" CACHE STRING "" FORCE)
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${PLATFORM_LINKFLAGS} ${NL_DEBUG_LINKFLAGS}" CACHE STRING "" FORCE)
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${PLATFORM_LINKFLAGS} ${NL_DEBUG_LINKFLAGS}" CACHE STRING "" FORCE)
|
||||
|
||||
## Release
|
||||
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${NL_RELEASE_CFLAGS} ${PLATFORM_CFLAGS} ")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${NL_RELEASE_CFLAGS} ${PLATFORM_CFLAGS} ")
|
||||
SET(CMAKE_LINK_FLAGS_RELEASE "${CMAKE_LINK_FLAGS_RELEASE} ${NL_RELEASE_LINK_FLAGS} ${PLATFORM_LINKFLAGS} ")
|
||||
|
||||
## RelWithDebInfo
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${NL_RELEASE_CFLAGS} ${PLATFORM_CFLAGS} ")
|
||||
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${NL_RELEASE_CFLAGS} ${PLATFORM_CFLAGS} ")
|
||||
SET(CMAKE_LINK_FLAGS_RELWITHDEBINFO "${CMAKE_LINK_FLAGS_RELWITHDEBINFO} ${NL_RELEASE_LINK_FLAGS} ${PLATFORM_LINKFLAGS} ")
|
||||
|
||||
## MinSizeRel
|
||||
SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${NL_RELEASE_CFLAGS} ${PLATFORM_CFLAGS} ")
|
||||
SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${NL_RELEASE_CFLAGS} ${PLATFORM_CFLAGS} ")
|
||||
SET(CMAKE_LINK_FLAGS_MINSIZEREL "${CMAKE_LINK_FLAGS_MINSIZEREL} ${NL_RELEASE_LINK_CFLAGS} ${PLATFORM_LINKFLAGS} ")
|
||||
SET(CMAKE_C_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE)
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE ${NL_RELEASE_CFLAGS} CACHE STRING "" FORCE)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${PLATFORM_LINKFLAGS} ${NL_RELEASE_LINKFLAGS}" CACHE STRING "" FORCE)
|
||||
SET(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${PLATFORM_LINKFLAGS} ${NL_RELEASE_LINKFLAGS}" CACHE STRING "" FORCE)
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${PLATFORM_LINKFLAGS} ${NL_RELEASE_LINKFLAGS}" CACHE STRING "" FORCE)
|
||||
ENDMACRO(NL_SETUP_BUILD_FLAGS)
|
||||
|
||||
MACRO(NL_SETUP_PREFIX_PATHS)
|
||||
|
|
Loading…
Reference in a new issue