more flag-related tweaks

This commit is contained in:
Menche 2015-03-21 17:14:59 -07:00
parent eb909deade
commit 2a654cfe3d
2 changed files with 19 additions and 6 deletions

View File

@ -30,6 +30,8 @@ else()
set(BUILD_SERVER 1 CACHE BOOL "Build server") set(BUILD_SERVER 1 CACHE BOOL "Build server")
endif() endif()
set(CPU_OPTS 0 CACHE BOOL "Enable CPU optimizations")
set(WARN_ALL 1 CACHE BOOL "Enable -Wall for Release build") set(WARN_ALL 1 CACHE BOOL "Enable -Wall for Release build")
if(NOT CMAKE_BUILD_TYPE) if(NOT CMAKE_BUILD_TYPE)

View File

@ -372,10 +372,20 @@ else()
set(SAFETY_FLAGS "-fno-strict-aliasing -fwrapv -fvisibility=hidden -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2") set(SAFETY_FLAGS "-fno-strict-aliasing -fwrapv -fvisibility=hidden -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2")
endif() endif()
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${SAFETY_FLAGS} -O2 -Wall -fomit-frame-pointer -pipe") if(CPU_OPTS)
set(CMAKE_CXX_FLAGS_DEBUG "${SAFETY_FLAGS} -O0 -g2 -ggdb") set(OPT_FLAGS "-march=native -mtune=native -O2 -fomit-frame-pointer")
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG ${SAFETY_FLAGS} -O2 -Wall -fomit-frame-pointer -pipe") else()
set(CMAKE_C_FLAGS_DEBUG "${SAFETY_FLAGS} -O0 -g2 -ggdb") set(OPT_FLAGS "-O2 -fomit-frame-pointer")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${SAFETY_FLAGS} ${OPT_FLAGS} -pipe")
set(CMAKE_CXX_FLAGS_DEBUG "${SAFETY_FLAGS} -Wall -O0 -g2 -ggdb")
set(CMAKE_C_FLAGS_RELEASE "-DNDEBUG ${SAFETY_FLAGS} ${OPT_FLAGS} -pipe")
set(CMAKE_C_FLAGS_DEBUG "${SAFETY_FLAGS} -Wall -O0 -g2 -ggdb")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-O1,--as-needed,--discard-all,--no-undefined,--sort-common,-z,relro,-z,now")
set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "-Wl,-O1,--as-needed,--discard-all,--no-undefined,--sort-common,-z,relro,-z,now")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "-Wl,-O1,--as-needed,--discard-all,--no-undefined,--sort-common,-z,relro,-z,now")
if(USE_GPROF) if(USE_GPROF)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
@ -388,8 +398,9 @@ else()
endif() endif()
MESSAGE(STATUS "CMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}") MESSAGE(STATUS "Release Flags: ${CMAKE_CXX_FLAGS_RELEASE}")
MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}") MESSAGE(STATUS "Debug Flags: ${CMAKE_CXX_FLAGS_DEBUG}")
MESSAGE(STATUS "Linker Flags: ${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
# #
# Installation # Installation