summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 113b3a18b42fc015be6089127cf84068b193e1ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
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"
    "third_party/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/retarget.cpp"
    "app/platform/stm32f0-gcc/freertos/port.c"
    "app/platform/stm32f0-gcc/startup/handlers_cm.c"
    "app/platform/stm32f0-gcc/startup/stack.cpp"
    "app/platform/stm32f0-gcc/startup/startup.cpp"
    )

set_source_files_properties("third_party/FreeRTOS/queue.c" PROPERTIES
    COMPILE_FLAGS -Wno-cast-align)

add_executable(${PROJECT_NAME}
    ${nixie_clock_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"
    "third_party/Time"
    "app"
    "app/nixie_driver"
    "app/ltimers"
    "app/head_task"
    "app/indicate"
    "app/light_sensor"
    "app/button"
    "app/led_driver"
    "app/platform/stm32f0-gcc/freertos"
    )

target_compile_definitions(${PROJECT_NAME} PRIVATE
    STM32F0XX=1
    LED_DRIVER=1
    __FREERTOS__=1
    )

# select linker script
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}
    $<$<COMPILE_LANGUAGE:C>:-std=c11>
    $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>
    $<$<COMPILE_LANGUAGE:CXX>:-fms-extensions>
    $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
    $<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
    $<$<COMPILE_LANGUAGE:CXX>:-fno-use-cxa-atexit>
    $<$<COMPILE_LANGUAGE:CXX>:-fno-threadsafe-statics>
    $<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast>
    $<$<COMPILE_LANGUAGE:CXX>:-Wsuggest-override>
    $<$<COMPILE_LANGUAGE:CXX>:-Wsuggest-final-types>
    $<$<COMPILE_LANGUAGE:CXX>:-Wsuggest-final-methods>
    -fstrict-volatile-bitfields
    -ffunction-sections
    -g3
    -Wall
    -Wextra
    -Wcast-align
    -Wshadow
    -Wlogical-op
)

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}
    -nostartfiles
    -nostdlib
    )

link_directories(
    ${CMAKE_SOURCE_DIR}
)

target_link_libraries(${PROJECT_NAME}
    c
    gcc
)

set_property(TARGET ${PROJECT_NAME} PROPERTY LINK_DEPENDS
    ${linker_script_mcu}
    ${linker_script_flash}
    ${linker_script_sram}
    )