-
Notifications
You must be signed in to change notification settings - Fork 71
/
CMakeLists.txt
239 lines (204 loc) · 7.17 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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
cmake_minimum_required(VERSION 3.19.5)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY")
set(MUDITA_CACHE_DIR "~/.mudita/" CACHE STRING "cache directory for our downloaded assets")
project(PureOS)
enable_language(C CXX ASM)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
include(Product)
include(Board)
set(SYSROOT_PATH ${CMAKE_CURRENT_BINARY_DIR}/sysroot)
set(SYSROOT_BIN_PATH ${SYSROOT_PATH}/system_a/bin)
validate_product_selection()
include(products/${PRODUCT}/config.cmake)
select_board()
include(Colours)
include(CCacheConfig)
include(ProjectConfig)
include(ModuleConfig)
include(SerialPort)
include(CopyGdbInit)
include(Utils)
include(ModuleUtils)
include(DiskImage)
include(AddPackage)
include(AutoModuleOption)
include(AddDirectories)
include(AddDatabases)
include(FetchContent)
include(AddScripts)
option(ENABLE_VERSION_PRO "Enable configuration for Pro version" OFF)
if (ENABLE_VERSION_PRO)
add_compile_definitions(CONFIG_VERSION_PRO=1)
endif()
message("Selected product: ${PRODUCT}")
message("Selected board: ${BOARD}")
if (${PRODUCT} STREQUAL "BellHybrid")
message("Pro config: ${ENABLE_VERSION_PRO}")
endif()
message("Board revision: ${BOARD_REVISION}")
message("PROJECT_TARGET: ${PROJECT_TARGET}")
message("Assets version: ${ASSETS_TYPE}")
message("Version: ${OS_VERSION_MAJOR}.${OS_VERSION_MINOR}.${OS_VERSION_PATCH}-${OS_VERSION_LABEL}")
string(REPLACE "TARGET_" "" PROJECT_TARGET_NAME ${PROJECT_TARGET})
string(TOLOWER "${PROJECT_TARGET_NAME}" PROJECT_TARGET_NAME)
message("Project target name: ${PROJECT_TARGET_NAME}")
if (NOT ${PROJECT_TARGET} STREQUAL "TARGET_RT1051")
set(ENABLE_TESTS ON)
else()
add_compile_options(-include ${CMAKE_SOURCE_DIR}/board/rt1051/gthr.h)
endif()
if (${ENABLE_TESTS})
enable_testing()
add_custom_target(check ${CMAKE_CTEST_COMMAND} -V)
add_subdirectory(test)
include(PureCoverage)
endif ()
# setting build flags
if (${PROJECT_TARGET} STREQUAL "TARGET_Linux")
set(CMAKE_C_FLAGS_DEBUG "-ggdb3 -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -ggdb3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-ggdb3 -DDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb3 -DNDEBUG")
else()
set(CMAKE_C_FLAGS_DEBUG "-Og -ggdb3 -DDEBUG")
set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -ggdb3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -ggdb3 -DDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -ggdb3 -DNDEBUG")
endif()
set(TOOLCHAIN_PATH "" CACHE STRING "Path to toolchain directory")
add_compile_definitions(FSL_RTOS_FREE_RTOS
PLATFORM_${PROJECT_TARGET_NAME}
USB_STACK_FREERTOS
DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
FSL_SDK_ENABLE_DRIVER_CACHE_CONTROL=1
__STARTUP_INITIALIZE_NONCACHEDATA
SDK_OS_FREE_RTOS
XIP_EXTERNAL_FLASH=0
CPU_MIMXRT1051DVL6B_cm7
CPU_MIMXRT1051DVL6B
SDK_DEBUGCONSOLE=0
DISABLE_WDOG=0
__MCUXPRESSO
__USE_CMSIS
__NEWLIB__
SKIP_SYSCLK_INIT
_GNU_SOURCE)
add_compile_options(
$<$<COMPILE_LANGUAGE:C>:-std=gnu11>
-fsingle-precision-constant
-ffunction-sections
-fdata-sections
-MMD
-MP
-fno-builtin
# warning flags
-Wall -Wextra -Werror -Wno-unused-parameter -Wno-deprecated-declarations)
include_directories(${CMAKE_SOURCE_DIR})
option(GENERATE_STACK_USAGE "Generate stack usage report" OFF)
if (GENERATE_STACK_USAGE)
add_compile_options (-fstack-usage)
endif ()
option(ENABLE_SECURE_BOOT "Build signed binary for Secure Boot" OFF)
set(SIGN_CLIENT_PATH "${CMAKE_SOURCE_DIR}/../sign_server/key_client" CACHE PATH "signclient.py path")
set(SERVER "https://10.20.50.10:4430" CACHE STRING "sign server address")
if (NOT ENABLE_SECURE_BOOT)
# Only enable the build-time boot header in a non-secure configuration,
# a header for Secure Boot is added post-build when signing the binary
add_compile_definitions(
XIP_BOOT_HEADER_ENABLE=1
XIP_BOOT_HEADER_DCD_ENABLE=0
)
endif ()
FetchContent_Declare(
pure-core
GIT_REPOSITORY https://github.com/mudita/pure-core.git
)
FetchContent_MakeAvailable(pure-core)
add_subdirectory(board)
add_subdirectory(source)
add_subdirectory(module-platform)
add_subdirectory(module-sys)
add_subdirectory(module-utils)
add_subdirectory(module-os)
add_subdirectory(module-bsp)
add_subdirectory(module-vfs)
add_subdirectory(module-gui)
add_subdirectory(module-db)
add_subdirectory(module-cellular)
add_subdirectory(module-audio)
add_subdirectory(module-services)
add_subdirectory(module-apps)
add_subdirectory(module-bluetooth)
add_subdirectory(image)
add_subdirectory(host-tools)
add_subdirectory(third-party)
include(tools/clang-tidy.cmake)
install(
FILES ${PROJECT_SOURCE_DIR}/changelog.md
DESTINATION "./"
COMPONENT Standalone
)
option (BUILD_DOC_WITH_ALL "Build documentation" OFF)
include (GenDoxygenDoc)
include(Version)
add_custom_target(
version ALL
COMMAND ${CMAKE_COMMAND}
-DSRC_DIR=${CMAKE_SOURCE_DIR}
-B ${CMAKE_BINARY_DIR}
-DOS_VERSION_MAJOR=${OS_VERSION_MAJOR}
-DOS_VERSION_MINOR=${OS_VERSION_MINOR}
-DOS_VERSION_PATCH=${OS_VERSION_PATCH}
-DOS_VERSION_LABEL=${OS_VERSION_LABEL}
-P ${CMAKE_SOURCE_DIR}/cmake/modules/GenVersionHpp.cmake
COMMENT
"Generating version info"
)
# Create common system directories
add_directories(
TARGET system_directories_common
PREFIX ${SYSROOT_PATH}/system_a
DEPENDS assets
DIRECTORIES log assets crash_dumps data bin db scripts var
)
# Remove 'var' directory to delete all files created during simulator operation
add_custom_target(
remove_var_directory
COMMAND rm -rf ${SYSROOT_PATH}/system_a/var
COMMENT "Removing 'var' directory"
)
# Create and initialize product-specific databases
add_databases_target(
TARGET create_product_databases
DB_SET ${CMAKE_SOURCE_DIR}/products/${PRODUCT}/services/db/databases/databases.json
COMMON_DIR ${CMAKE_SOURCE_DIR}/module-db/databases/migration
PRODUCT_DIR ${CMAKE_SOURCE_DIR}/products/${PRODUCT}/services/db/databases/migration
DEST_DIR ${SYSROOT_PATH}/system_a/db
DEVEL ${WITH_DEVELOPMENT_FEATURES}
)
# Install scripts
add_scripts_target(
TARGET install_scripts
PRODUCT ${PRODUCT}
DEST_DIR ${SYSROOT_PATH}/system_a/scripts
)
# Create and initialize product-specific databases for tests
add_databases_target(
TARGET create_test_product_databases
DB_SET ${CMAKE_SOURCE_DIR}/products/${PRODUCT}/services/db/databases/databases.json
COMMON_DIR ${CMAKE_SOURCE_DIR}/module-db/databases/migration
PRODUCT_DIR ${CMAKE_SOURCE_DIR}/products/${PRODUCT}/services/db/databases/migration
DEST_DIR ${CMAKE_BINARY_DIR}/test-sysroot/system_a/db
DEVEL ${WITH_DEVELOPMENT_FEATURES}
)
add_library(version-header INTERFACE)
target_include_directories(version-header INTERFACE $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/source/include>)
add_dependencies(version-header version)
add_subdirectory(products)