diff --git a/CMakeLists.txt b/CMakeLists.txt index ccfd8cd..c7d190a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,7 @@ target_compile_options(${EXECUTABLE} PRIVATE -Wall -Wpedantic -Wno-unused-parameter + -Os # Optimize for size (that uses O2) ) # Linker options diff --git a/cmake/gcc-arm-none-eabi.cmake b/cmake/gcc-arm-none-eabi.cmake index a110017..bb598df 100644 --- a/cmake/gcc-arm-none-eabi.cmake +++ b/cmake/gcc-arm-none-eabi.cmake @@ -1,21 +1,21 @@ -set(CMAKE_SYSTEM_NAME Generic) -set(CMAKE_SYSTEM_PROCESSOR arm) - -# Some default GCC settings -# arm-none-eabi- must be part of path environment -set(TOOLCHAIN_PREFIX arm-none-eabi-) -set(FLAGS "-fdata-sections -ffunction-sections --specs=nano.specs -Wl,--gc-sections") -set(CPP_FLAGS "-fno-rtti -fno-exceptions -fno-threadsafe-statics") - -# Define compiler settings -set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc ${FLAGS}) -set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) -set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++ ${FLAGS} ${CPP_FLAGS}) -set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy) -set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size) - -set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf") -set(CMAKE_EXECUTABLE_SUFFIX_C ".elf") -set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf") - +set(CMAKE_SYSTEM_NAME Generic) +set(CMAKE_SYSTEM_PROCESSOR arm) + +# Some default GCC settings +# arm-none-eabi- must be part of path environment +set(TOOLCHAIN_PREFIX arm-none-eabi-) +set(C_FLAGS "-fdata-sections -ffunction-sections --specs=nano.specs -Wl,--gc-sections") +set(CPP_FLAGS "-fno-rtti -fno-exceptions -fno-threadsafe-statics") + +# Define compiler settings +set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc ${C_FLAGS}) +set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER}) +set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}g++ ${C_FLAGS} ${CPP_FLAGS}) +set(CMAKE_OBJCOPY ${TOOLCHAIN_PREFIX}objcopy) +set(CMAKE_SIZE ${TOOLCHAIN_PREFIX}size) + +set(CMAKE_EXECUTABLE_SUFFIX_ASM ".elf") +set(CMAKE_EXECUTABLE_SUFFIX_C ".elf") +set(CMAKE_EXECUTABLE_SUFFIX_CXX ".elf") + set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) \ No newline at end of file