cmake_minimum_required(VERSION 3.16) project(NixieClock) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_C_STANDARD 11) set(CMAKE_C_STANDARD_REQUIRED True) set(CMAKE_EXPORT_COMPILE_COMMANDS True) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer") set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer") set(cpu_options -mthumb -mcpu=cortex-m0 -msoft-float) set(nixie_clock_sources "third_party/TouchSense/stmCriticalSection.c" "third_party/TouchSense/STMTouch_Driver/src/tsl_linrot.c" "third_party/TouchSense/STMTouch_Driver/src/tsl_dxs.c" "third_party/TouchSense/STMTouch_Driver/src/tsl_time.c" "third_party/TouchSense/STMTouch_Driver/src/tsl_globals.c" "third_party/TouchSense/STMTouch_Driver/src/tsl_acq_stm32f0xx.c" "third_party/TouchSense/STMTouch_Driver/src/tsl_object.c" "third_party/TouchSense/STMTouch_Driver/src/tsl_filter.c" "third_party/TouchSense/STMTouch_Driver/src/tsl_acq.c" "third_party/TouchSense/STMTouch_Driver/src/tsl_time_stm32f0xx.c" "third_party/TouchSense/STMTouch_Driver/src/tsl_touchkey.c" "third_party/TouchSense/STMTouch_Driver/src/tsl.c" "third_party/TouchSense/STMTouch_Driver/src/tsl_ecs.c" "third_party/TouchSense/tsl_user.c" "third_party/FreeRTOS/queue.c" "third_party/FreeRTOS/timers.c" "third_party/FreeRTOS/tasks.c" "third_party/FreeRTOS/list.c" "third_party/FreeRTOS/croutine.c" "third_party/FreeRTOS/event_groups.c" "third_party/FreeRTOS/heap_2.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_exti.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_iwdg.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_comp.c" "third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_gpio.c" "third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_rcc.c" "third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_spi.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_wwdg.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_dbgmcu.c" "third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_tim.c" "third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_rtc.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_crc.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_crs.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_syscfg.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_dac.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_cec.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_dma.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_can.c" "third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_pwr.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_flash.c" "third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_misc.c" "third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_adc.c" #"third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_i2c.c" "third_party/STM32F0xx_StdPeriph_Driver/src/stm32f0xx_usart.c" "app/time/time.c" "app/indicate/indicate_modes_task.c" "app/button/button_handler.c" "app/button/button_task.c" "app/led_driver/led_driver_config.c" "app/led_driver/led_driver_process.c" "app/led_driver/led_driver_task.c" "app/ltimers/ltimers.c" "app/ltimers/ltimers_config.c" "app/nixie_driver/nixie_driver_config.c" "app/nixie_driver/nixie_driver_task.c" "app/nixie_driver/nixie_driver_process.c" "app/head_task/head_task.c" "app/light_sensor/light_sensor_task.c" "app/main.c" "app/stm32f0xx_it.c" "app/system_stm32f0xx.c" "app/platform/stm32f0-gcc/freertos/port.c" "app/platform/stm32f0-gcc/interrupts.cpp" "app/platform/stm32f0-gcc/platform.cpp" "app/platform/stm32f0-gcc/startup/handlers_cm.c" "app/platform/stm32f0-gcc/startup/stack.cpp" "app/platform/stm32f0-gcc/startup/startup.cpp" "app/platform/stm32f0-gcc/retarget.cpp" "app/platform/stm32f0-gcc/uart.cpp" ) set(newlib_sources "third_party/newlib/string/memcmp.c" "third_party/newlib/string/memcpy.c" "third_party/newlib/string/memmove.c" "third_party/newlib/string/memset.c" "third_party/newlib/stdlib/abort.c" ) set(printf_sources "third_party/printf/printf.c" ) set_source_files_properties( "third_party/printf/printf.c" PROPERTIES INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/third_party" COMPILE_DEFINITIONS PRINTF_INCLUDE_CONFIG_H=1) set_source_files_properties( "third_party/FreeRTOS/queue.c" "third_party/newlib/string/memcmp.c" "third_party/newlib/string/memcpy.c" "third_party/newlib/string/memmove.c" "third_party/newlib/string/memset.c" PROPERTIES COMPILE_FLAGS -Wno-cast-align) add_executable(${PROJECT_NAME} ${nixie_clock_sources} ${newlib_sources} ${printf_sources} ) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR} "third_party/TouchSense/STMTouch_Driver/inc" "third_party/CMSIS/Device/Include" "third_party/FreeRTOS/include" "third_party/TouchSense" "third_party/STM32F0xx_StdPeriph_Driver/inc" "app" "app/platform/stm32f0-gcc/freertos" "." ) target_compile_definitions(${PROJECT_NAME} PRIVATE STM32F072=1 LED_DRIVER=1 __FREERTOS__=1 _POSIX_C_SOURCE=200809L ) set(linker_script_mcu "${CMAKE_SOURCE_DIR}/app/ld/stm32f072x8.ld") set(linker_script_flash "${CMAKE_SOURCE_DIR}/app/ld/_flash.ld") set(linker_script_sram "${CMAKE_SOURCE_DIR}/app/ld/_sram.ld") target_compile_options(${PROJECT_NAME} PRIVATE ${cpu_options} $<$:-std=c11> $<$:-std=c++17> $<$:-fms-extensions> $<$:-fno-exceptions> $<$:-fno-rtti> $<$:-fno-use-cxa-atexit> $<$:-fno-threadsafe-statics> $<$:-Wold-style-cast> $<$:-Wsuggest-override> $<$:-Wsuggest-final-types> $<$:-Wsuggest-final-methods> -fstrict-volatile-bitfields -ffunction-sections -fdata-sections -g3 -Wall -Wextra -Wcast-align -Wshadow -Wlogical-op -Os -fno-builtin-printf -fno-builtin-fprintf -fno-builtin-_exit ) target_link_options(${PROJECT_NAME} PRIVATE --specs=nano.specs ${cpu_options} -Wl,--gc-sections -T${linker_script_mcu} -T${linker_script_flash} -T${linker_script_sram} -Wl,-Map=${PROJECT_NAME}.map -nostartfiles -nostdlib ) link_directories( ${CMAKE_SOURCE_DIR} ) target_link_libraries(${PROJECT_NAME} gcc ) set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_DEPENDS ${linker_script_mcu} ${linker_script_flash} ${linker_script_sram} ) set_property(TARGET ${PROJECT_NAME} PROPERTY SUFFIX ".elf") add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_OBJSIZE} $ ) add_custom_command( TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_OBJCOPY} $ -O ihex $.hex )