cmake: Improved way to set default compiler flags

pull/207/head
Yuri D'Elia 2022-10-02 00:19:32 +02:00
parent f43884a0ca
commit 38657f5d77
1 changed files with 6 additions and 5 deletions

View File

@ -95,11 +95,12 @@ add_compile_options(-g)
# optimizations # optimizations
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-Og) # default optimization flags
else() set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
add_compile_options(-Os) set(CMAKE_CXX_FLAGS_RELEASE "-Os -g -DNDEBUG")
endif() set(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
set(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
# mcu related settings # mcu related settings
set(MCU_FLAGS -mmcu=atmega32u4 -DF_CPU=16000000L) set(MCU_FLAGS -mmcu=atmega32u4 -DF_CPU=16000000L)