This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists_scaffold.txt
177 lines (147 loc) · 5.25 KB
/
CMakeLists_scaffold.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
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
169
170
171
172
173
174
175
176
177
# Copyright (C) 2019 Adolfo E. García
#
# This file is part of STG-8nn-Scaffold.
#
# STG-8nn-Scaffold is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# STG-8nn-Scaffold is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with STG-8nn-Scaffold. If not, see <https://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.20)
set(GENERIC_C_FLAGS "-O0 -flto -Wall -Wextra -Wredundant-decls -Wmissing-prototypes -Wimplicit-function-declaration -Wshadow -Wno-unused-parameter -Wdouble-promotion -Wswitch-enum -Wfloat-equal -Wconversion -Wtype-limits -Wsign-conversion -Wcast-align -Wmissing-declarations -ffunction-sections -fdata-sections")
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
##
## ARM specific flags
##
add_definitions(-DSTM32F0)
add_definitions(-DSTM32F091xC)
if(DEFINED SCAFFOLD_DIR)
include(${SCAFFOLD_DIR}/CMakeLists_startup.txt)
else()
include(CMakeLists_startup.txt)
endif()
list(APPEND SCAFFOLD_SOURCES ${STARTUP_SOURCES})
if("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
##
## GNU ARM Toolchain specific flags
##
set(MCU_FLAGS "-mcpu=cortex-m0 -mtune=cortex-m0 -march=armv6-m -mthumb -mfloat-abi=soft -mgeneral-regs-only")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MCU_FLAGS} ${GENERIC_C_FLAGS} -Wundef -MMD -MP -MF")
elseif("${CMAKE_ASM_COMPILER_ID}" MATCHES "Clang")
##
## Clang's ARM Toolchain specific flags
##
set(MCU_FLAGS "--target=armv6m-unknown-none-eabi -mcpu=cortex-m0 -march=armv6m -mthumb -mfloat-abi=soft")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MCU_FLAGS} -Wno-unused-command-line-argument -ffreestanding ${GENERIC_C_FLAGS}")
endif()
set(CMAKE_ASM_FLAGS "${MCU_FLAGS} -Wall -fdata-sections -ffunction-sections")
set(CMAKE_EXE_LINKER_FLAGS "${MCU_FLAGS} -mthumb -flto --static -specs=nosys.specs -specs=nano.specs -T${STARTUP_LD_SCRIPT} -Wl,--cref,--gc-sections,-Map=stg8nn.map,-print-memory-usage")
else()
##
## x86 specific flags
##
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic ${GENERIC_C_FLAGS}")
set(CMAKE_ASM_FLAGS "-Wall -fdata-sections -ffunction-sections -fno-stack-protector")
if("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
set(CMAKE_ASM_FLAGS "${CMAKE_ASM_FLAGS} -m32")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
endif()
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo Debug DebugFull Profile MinSizeRel"
FORCE)
add_definitions(-DNDEBUG) #qpc,libcanard no debug flag
endif()
set(CMAKE_C_STANDARD 99)
set(BUILD_SHARED_LIBS OFF)
##
## Select model option
##
SET(STG_MODEL "model" CACHE STRING "850")
if("${STG_MODEL}" MATCHES "850")
message(STATUS "STG MODEL: ${STG_MODEL}")
add_definitions(-DMODEL_STG850)
elseif("${STG_MODEL}" MATCHES "856")
message(STATUS "STG MODEL: ${STG_MODEL}")
add_definitions(-DMODEL_STG856)
elseif("${STG_MODEL}" MATCHES "TESTER")
message(STATUS "STG MODEL: ${STG_MODEL}")
add_definitions(-DMODEL_TESTER)
else()
message(FATAL_ERROR "STG MODEL: invalid option")
endif()
##
## Get this revision's commit hash
##
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE _GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
add_definitions("-DAPP_SW_GIT_COMMIT_HASH=0x${_GIT_COMMIT_HASH}")
##
## Some diagnostic messages
##
message(STATUS "System: ${CMAKE_SYSTEM_NAME}")
message(STATUS "Git commit hash: 0x${_GIT_COMMIT_HASH}")
##
## Add dependency: qp/c (with qk kernel)
##
if(DEFINED SCAFFOLD_DIR)
include(${SCAFFOLD_DIR}/CMakeLists_qpc.txt)
else()
include(CMakeLists_qpc.txt)
endif()
list(APPEND SCAFFOLD_SOURCES ${QPC_SOURCES})
list(APPEND SCAFFOLD_INCLUDE ${QPC_INCLUDE})
##
## Add dependency: libcanard
##
if(DEFINED SCAFFOLD_DIR)
include(${SCAFFOLD_DIR}/CMakeLists_libcanard.txt)
else()
include(CMakeLists_libcanard.txt)
endif()
list(APPEND SCAFFOLD_SOURCES ${CANARD_SOURCES})
list(APPEND SCAFFOLD_INCLUDE ${CANARD_INCLUDE})
##
## Add dependency: uavcan dsdl -> C files
##
# This CMakeLists.txt file should be included after including Libcanard's
if(DEFINED SCAFFOLD_DIR)
include(${SCAFFOLD_DIR}/CMakeLists_uavcan_dsdl.txt)
else()
include(CMakeLists_uavcan_dsdl.txt)
endif()
list(APPEND SCAFFOLD_SOURCES ${DSDL_C_SOURCES})
list(APPEND SCAFFOLD_INCLUDE ${DSDL_C_INCLUDE})
##
## Add the BSP
##
if(DEFINED SCAFFOLD_DIR)
include(${SCAFFOLD_DIR}/CMakeLists_bsp.txt)
else()
include(CMakeLists_bsp.txt)
endif()
list(APPEND SCAFFOLD_SOURCES ${BSP_SOURCES})
list(APPEND SCAFFOLD_INCLUDE ${BSP_INCLUDE})
##
## Add the base application
##
if(DEFINED SCAFFOLD_DIR)
include(${SCAFFOLD_DIR}/CMakeLists_app.txt)
else()
include(CMakeLists_app.txt)
endif()
list(APPEND SCAFFOLD_SOURCES ${APP_SOURCES})
list(APPEND SCAFFOLD_INCLUDE ${APP_INCLUDE})