-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
98 lines (82 loc) · 2.18 KB
/
CMakeLists.txt
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
cmake_policy(SET CMP0048 NEW)
project(kxmx_grundton VERSION 0.0.1)
cmake_minimum_required(VERSION 3.20)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(TARGET kxmx_grundton)
set(LIBDAISY_DIR lib/libDaisy)
set(DAISYSP_DIR lib/DaisySP)
set(Q_DIR lib/q)
option(Q_BUILD_EXAMPLES "" OFF)
option(Q_BUILD_TEST "" OFF)
option(Q_BUILD_IO "" OFF)
# open-ocd
set(CHIPSET stm32h7x)
set(OCD openocd)
set(OCD_DIR /usr/local/share/openocd/scripts)
set(PGM_DEVICE interface/stlink.cfg)
set(OCDFLAGS -f ${PGM_DEVICE} -f target/${CHIPSET}.cfg)
set(OCD_PROGRAM ${OCD} -s ${OCD_DIR} ${OCDFLAGS} -c "program ${TARGET}.elf verify reset exit")
add_subdirectory(${LIBDAISY_DIR})
add_subdirectory(${DAISYSP_DIR})
add_subdirectory(${Q_DIR})
include_directories(src)
add_executable(${TARGET} src/kxmx_grundton.cpp src/kxmx_bluemchen.cpp)
target_link_libraries(${TARGET} PUBLIC
libq
daisy
DaisySP
)
get_filename_component(LIBDAISY_DIR_ABS "${LIBDAISY_DIR}"
REALPATH BASE_DIR "${CMAKE_SOURCE_DIR}")
set(LINKER_SCRIPT ${LIBDAISY_DIR_ABS}/core/STM32H750IB_flash.lds)
set_target_properties(${TARGET} PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
SUFFIX ".elf"
LINK_DEPENDS ${LINKER_SCRIPT}
)
target_link_options(${TARGET} PUBLIC
-T ${LINKER_SCRIPT}
-Wl,-Map=${TARGET}.map,--cref
-Wl,--check-sections
-Wl,--unresolved-symbols=report-all
-Wl,--warn-common
-Wl,--warn-section-align
-Wl,--print-memory-usage
)
target_compile_options(${TARGET}
PUBLIC
-Os
-Wall
-Wno-attributes
-Wno-strict-aliasing
-Wno-maybe-uninitialized
-Wno-missing-attributes
-Wno-stringop-overflow
-Wno-error=reorder
-Wno-error=sign-compare
-fexceptions
-DQ_DONT_USE_THREADS=1
$<$<COMPILE_LANGUAGE:CXX>:-Wno-register>
)
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_OBJCOPY}
ARGS -O ihex
-S ${TARGET}.elf
${TARGET}.hex
BYPRODUCTS
${TARGET}.hex
COMMENT "Generating HEX image"
VERBATIM)
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_OBJCOPY}
ARGS -O binary
-S ${TARGET}.elf
${TARGET}.bin
BYPRODUCTS
${TARGET}.bin
COMMENT "Generating binary image"
VERBATIM)
add_custom_target(program
COMMAND ${OCD_PROGRAM}
)