From 44ba4dd47064508f4d289b7a33197abcbbcf5c9c Mon Sep 17 00:00:00 2001 From: Jonathan Vander Mey Date: Sat, 17 Jul 2021 12:09:38 -0400 Subject: [PATCH] Clean up target compile option assignments Removed/simplified some generator expressions that had more repeated elements than they needed to. Extracted some repeated sets of options into separate variables as well. --- src/CMakeLists.txt | 116 +++++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 51 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b1075198..07e8ca0b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -778,8 +778,12 @@ link_directories( ) -set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -ftree-vrp -g3 -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin -fshort-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fstack-usage -fno-exceptions -fno-non-call-exceptions) +set(COMMON_FLAGS -MP -MD -mthumb -mabi=aapcs -ftree-vrp -ffunction-sections -fdata-sections -fno-strict-aliasing -fno-builtin -fshort-enums -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fstack-usage -fno-exceptions -fno-non-call-exceptions) set(WARNING_FLAGS -Wall -Wextra -Warray-bounds=2 -Wformat=2 -Wformat-overflow=2 -Wformat-truncation=2 -Wformat-nonliteral -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unknown-pragmas -Wno-expansion-to-defined -Wreturn-type -Werror=return-type) +set(DEBUG_FLAGS -Og -g3) +set(RELEASE_FLAGS -Os) +set(CXX_FLAGS -fno-rtti) +set(ASM_FLAGS -x assembler-with-cpp) add_definitions(-DCONFIG_GPIO_AS_PINRESET) add_definitions(-DNIMBLE_CFG_CONTROLLER) add_definitions(-DOS_CPUTIME_FREQ) @@ -856,11 +860,12 @@ add_library(nrf-sdk STATIC ${SDK_SOURCE_FILES}) target_include_directories(nrf-sdk SYSTEM PUBLIC . ../) target_include_directories(nrf-sdk SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) target_compile_options(nrf-sdk PRIVATE - $<$,$>: ${COMMON_FLAGS} -Wno-expansion-to-defined -Og -g3> - $<$,$>: ${COMMON_FLAGS} -Wno-expansion-to-defined -O3> - $<$,$>: ${COMMON_FLAGS} -Wno-expansion-to-defined -Og -fno-rtti> - $<$,$>: ${COMMON_FLAGS} -Wno-expansion-to-defined -O3 -fno-rtti> - $<$: -MP -MD -x assembler-with-cpp> + ${COMMON_FLAGS} + $<$: ${DEBUG_FLAGS}> + $<$: ${RELEASE_FLAGS}> + $<$: ${CXX_FLAGS}> + $<$: ${ASM_FLAGS}> + -O3 ) # NimBLE @@ -868,11 +873,13 @@ add_library(nimble STATIC ${NIMBLE_SRC} ${TINYCRYPT_SRC}) target_include_directories(nimble SYSTEM PUBLIC . ../) target_include_directories(nimble SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) target_compile_options(nimble PRIVATE - $<$,$>: ${COMMON_FLAGS} -Og -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized> - $<$,$>: ${COMMON_FLAGS} -Os -Wno-unused-but-set-variable -Wno-maybe-uninitialized> - $<$,$>: ${COMMON_FLAGS} -Og -g3 -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-rtti> - $<$,$>: ${COMMON_FLAGS} -Os -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-rtti> - $<$: -MP -MD -x assembler-with-cpp> + ${COMMON_FLAGS} + $<$: ${DEBUG_FLAGS}> + $<$: ${RELEASE_FLAGS}> + $<$: ${CXX_FLAGS}> + $<$: ${ASM_FLAGS}> + -Wno-unused-but-set-variable + -Wno-maybe-uninitialized ) # lvgl @@ -880,11 +887,11 @@ add_library(lvgl STATIC ${LVGL_SRC}) target_include_directories(lvgl SYSTEM PUBLIC . ../) target_include_directories(lvgl SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) target_compile_options(lvgl PRIVATE - $<$,$>: ${COMMON_FLAGS} -Og -g3> - $<$,$>: ${COMMON_FLAGS} -Os> - $<$,$>: ${COMMON_FLAGS} -Og -g3 -fno-rtti> - $<$,$>: ${COMMON_FLAGS} -Os -fno-rtti> - $<$: -MP -MD -x assembler-with-cpp> + ${COMMON_FLAGS} + $<$: ${DEBUG_FLAGS}> + $<$: ${RELEASE_FLAGS}> + $<$: ${CXX_FLAGS}> + $<$: ${ASM_FLAGS}> ) # QCBOR @@ -911,11 +918,12 @@ add_library(littlefs STATIC ${LITTLEFS_SRC}) target_include_directories(littlefs SYSTEM PUBLIC . ../) target_include_directories(littlefs SYSTEM PUBLIC ${INCLUDES_FROM_LIBS}) target_compile_options(littlefs PRIVATE - $<$,$>: ${COMMON_FLAGS} -Wno-unused-function -Og -g3> - $<$,$>: ${COMMON_FLAGS} -Wno-unused-function -Os> - $<$,$>: ${COMMON_FLAGS} -Wno-unused-function -Og -g3 -fno-rtti> - $<$,$>: ${COMMON_FLAGS} -Wno-unused-function -Os -fno-rtti> - $<$: -MP -MD -x assembler-with-cpp> + ${COMMON_FLAGS} + $<$: ${DEBUG_FLAGS}> + $<$: ${RELEASE_FLAGS}> + $<$: ${CXX_FLAGS}> + $<$: ${ASM_FLAGS}> + -Wno-unused-function ) # Build autonomous binary (without support for bootloader) @@ -926,11 +934,12 @@ add_executable(${EXECUTABLE_NAME} ${SOURCE_FILES}) set_target_properties(${EXECUTABLE_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_FILE_NAME}) target_link_libraries(${EXECUTABLE_NAME} nimble nrf-sdk lvgl littlefs QCBOR infinitime_fonts) target_compile_options(${EXECUTABLE_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3 -fno-rtti> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os -fno-rtti> - $<$: -MP -MD -x assembler-with-cpp> + ${COMMON_FLAGS} + ${WARNING_FLAGS} + $<$: ${DEBUG_FLAGS}> + $<$: ${RELEASE_FLAGS}> + $<$: ${CXX_FLAGS}> + $<$: ${ASM_FLAGS}> ) set_target_properties(${EXECUTABLE_NAME} PROPERTIES @@ -960,11 +969,12 @@ add_executable(${EXECUTABLE_MCUBOOT_NAME} ${SOURCE_FILES}) target_link_libraries(${EXECUTABLE_MCUBOOT_NAME} nimble nrf-sdk lvgl littlefs QCBOR infinitime_fonts) set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_FILE_NAME}) target_compile_options(${EXECUTABLE_MCUBOOT_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3 -fno-rtti> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os -fno-rtti> - $<$: -MP -MD -x assembler-with-cpp> + ${COMMON_FLAGS} + ${WARNING_FLAGS} + $<$: ${DEBUG_FLAGS}> + $<$: ${RELEASE_FLAGS}> + $<$: ${CXX_FLAGS}> + $<$: ${ASM_FLAGS}> ) set_target_properties(${EXECUTABLE_MCUBOOT_NAME} PROPERTIES @@ -1002,11 +1012,12 @@ target_link_libraries(${EXECUTABLE_RECOVERY_NAME} nimble nrf-sdk littlefs QCBOR set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_FILE_NAME}) target_compile_definitions(${EXECUTABLE_RECOVERY_NAME} PUBLIC "PINETIME_IS_RECOVERY") target_compile_options(${EXECUTABLE_RECOVERY_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3 -fno-rtti> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os -fno-rtti> - $<$: -MP -MD -x assembler-with-cpp> + ${COMMON_FLAGS} + ${WARNING_FLAGS} + $<$: ${DEBUG_FLAGS}> + $<$: ${RELEASE_FLAGS}> + $<$: ${CXX_FLAGS}> + $<$: ${ASM_FLAGS}> ) set_target_properties(${EXECUTABLE_RECOVERY_NAME} PROPERTIES @@ -1033,11 +1044,12 @@ target_link_libraries(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} nimble nrf-sdk littlef set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERY_MCUBOOT_FILE_NAME}) target_compile_definitions(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC "PINETIME_IS_RECOVERY") target_compile_options(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3 -fno-rtti> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os -fno-rtti> - $<$: -MP -MD -x assembler-with-cpp> + ${COMMON_FLAGS} + ${WARNING_FLAGS} + $<$: ${DEBUG_FLAGS}> + $<$: ${RELEASE_FLAGS}> + $<$: ${CXX_FLAGS}> + $<$: ${ASM_FLAGS}> ) set_target_properties(${EXECUTABLE_RECOVERY_MCUBOOT_NAME} PROPERTIES @@ -1071,11 +1083,12 @@ add_executable(${EXECUTABLE_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE_FILES}) target_link_libraries(${EXECUTABLE_RECOVERYLOADER_NAME} nrf-sdk QCBOR infinitime_fonts) set_target_properties(${EXECUTABLE_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_RECOVERYLOADER_FILE_NAME}) target_compile_options(${EXECUTABLE_RECOVERYLOADER_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3 -fno-rtti> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os -fno-rtti> - $<$: -MP -MD -x assembler-with-cpp> + ${COMMON_FLAGS} + ${WARNING_FLAGS} + $<$: ${DEBUG_FLAGS}> + $<$: ${RELEASE_FLAGS}> + $<$: ${CXX_FLAGS}> + $<$: ${ASM_FLAGS}> ) target_include_directories(${EXECUTABLE_RECOVERYLOADER_NAME} PUBLIC $ @@ -1105,11 +1118,12 @@ add_executable(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} ${RECOVERYLOADER_SOURCE target_link_libraries(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} nrf-sdk QCBOR infinitime_fonts) set_target_properties(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PROPERTIES OUTPUT_NAME ${EXECUTABLE_MCUBOOT_RECOVERYLOADER_FILE_NAME}) target_compile_options(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PUBLIC - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Og -g3 -fno-rtti> - $<$,$>: ${COMMON_FLAGS} ${WARNING_FLAGS} -Os -fno-rtti> - $<$: -MP -MD -x assembler-with-cpp> + ${COMMON_FLAGS} + ${WARNING_FLAGS} + $<$: ${DEBUG_FLAGS}> + $<$: ${RELEASE_FLAGS}> + $<$: ${CXX_FLAGS}> + $<$: ${ASM_FLAGS}> ) target_include_directories(${EXECUTABLE_MCUBOOT_RECOVERYLOADER_NAME} PUBLIC $