Add CMake build flags presets

This commit is contained in:
Federico Ficarelli 2020-02-11 15:33:54 +01:00
parent b6af940d20
commit 3d4d58e0bb
2 changed files with 23 additions and 0 deletions

9
cmake/flags/debug.cmake Normal file
View File

@ -0,0 +1,9 @@
# Provide a human-friendly debug experience by keeping symbols and stack frames
set(flags "-Og -g -fno-omit-frame-pointer -fno-optimize-sibling-calls")
# Debug
set(CMAKE_C_FLAGS_DEBUG "${flags}" CACHE STRING "")
set(CMAKE_Fortran_FLAGS_DEBUG "${flags}" CACHE STRING "")
unset(flags)

14
cmake/flags/native.cmake Normal file
View File

@ -0,0 +1,14 @@
# Auto-detect uarch of the build machine and automatically codegen for it
# Be aware that resulting binaries will be unportable even across same arch but different uarch
set(flags "-O3 -DNDEBUG -march=native -mtune=native")
# Release
set(CMAKE_C_FLAGS_RELEASE "${flags}" CACHE STRING "")
set(CMAKE_Fortran_FLAGS_RELEASE "${flags}" CACHE STRING "")
# RelWithDebInfo
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${flags} -g" CACHE STRING "")
set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO "${flags} -g" CACHE STRING "")
unset(flags)