-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
119 lines (96 loc) · 3.34 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
# Leka - LekaOS
# Copyright 2020 APF France handicap
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.21)
# Activate ccache if available
find_program(CCACHE "ccache")
if(CCACHE)
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE}")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE}")
endif(CCACHE)
# Activate LogKit
option(ENABLE_LOG_DEBUG "Enable LogKit output" OFF)
message(STATUS "ENABLE_LOG_DEBUG --> ${ENABLE_LOG_DEBUG}")
if(ENABLE_LOG_DEBUG)
add_definitions(-DENABLE_LOG_DEBUG)
endif(ENABLE_LOG_DEBUG)
# Set C/C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS TRUE)
set(CMAKE_C_STANDARD 17)
set(CMAKE_C_EXTENSIONS TRUE)
# Add custom flags
add_compile_options(
-fdiagnostics-color=always
)
# Before all, set ROOT_DIR, MBED_OS_DIR
set(ROOT_DIR ${CMAKE_CURRENT_LIST_DIR})
set(MBED_OS_DIR ${ROOT_DIR}/extern/mbed-os)
set(MCUBOOT_DIR ${ROOT_DIR}/extern/mcuboot/boot)
set(MBED_HTTP_DIR ${ROOT_DIR}/extern/mbed-http)
# Bootloader option
option(BUILD_TARGETS_TO_USE_WITH_BOOTLOADER "Build targets with padding to use with bootloader" OFF)
message(STATUS "Build targets with padding to use with bootloader --> ${BUILD_TARGETS_TO_USE_WITH_BOOTLOADER}")
if (BUILD_TARGETS_TO_USE_WITH_BOOTLOADER)
set(MBED_APP_FLAGS
-DMBED_APP_START=0x08041000
-DMBED_APP_SIZE=0x17E000
)
endif(BUILD_TARGETS_TO_USE_WITH_BOOTLOADER)
# And include mbed-cmake.cmake
include(./mbed-cmake.cmake)
# Then configure name of the project
project(LekaOS LANGUAGES C CXX ASM)
# Generate compile commands database
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
if(CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES})
endif()
# For convenience you can define useful variables
set(OS_DIR ${ROOT_DIR}/app/os)
set(LIBS_DIR ${ROOT_DIR}/libs)
set(TESTS_DIR ${ROOT_DIR}/tests)
set(SPIKES_DIR ${ROOT_DIR}/spikes)
set(DRIVERS_DIR ${ROOT_DIR}/drivers)
set(TARGETS_DIR ${ROOT_DIR}/targets)
set(INCLUDE_DIR ${ROOT_DIR}/include)
set(BOOTLOADER_DIR ${ROOT_DIR}/app/bootloader)
# Add custom target subdirectory
set(AVAILABLE_CUSTOM_TARGETS DISCO_ORIGINAL LEKA_V1_0_DEV LEKA_V1_1_DEV LEKA_V1_2_DEV)
if (${TARGET_BOARD} IN_LIST AVAILABLE_CUSTOM_TARGETS)
add_subdirectory(${TARGETS_DIR}/TARGET_${TARGET_BOARD})
endif()
include_directories(BEFORE
${INCLUDE_DIR}
)
# Link libraries to all targets
add_subdirectory(${LIBS_DIR}/Utils)
add_subdirectory(${LIBS_DIR}/LogKit)
add_subdirectory(${LIBS_DIR}/HelloWorld)
add_subdirectory(${LIBS_DIR}/CriticalSection)
link_libraries(
Utils
LogKit
HelloWorld
CriticalSection
)
# Add external libraries
add_compile_definitions(MCUBOOT_BOOTLOADER_SIZE=0x40000)
add_compile_definitions(MCUBOOT_SCRATCH_SIZE=0x40000)
add_compile_definitions(MCUBOOT_SCRATCH_START_ADDR=0x081C0000)
add_compile_definitions(MCUBOOT_RSA_SIGNATURE_LENGTH=2048)
add_compile_definitions(MCUBOOT_SLOT_SIZE=0x200000-MCUBOOT_BOOTLOADER_SIZE-MCUBOOT_SCRATCH_SIZE)
add_subdirectory(${MCUBOOT_DIR})
add_subdirectory(${MBED_HTTP_DIR})
# Add drivers & libraries
add_subdirectory(${DRIVERS_DIR})
add_subdirectory(${LIBS_DIR})
# Add spikes, functional tests
add_subdirectory(${SPIKES_DIR})
add_subdirectory(${TESTS_DIR}/functional)
# Add bootloader
add_subdirectory(${BOOTLOADER_DIR})
# Add LekaOS
add_subdirectory(${OS_DIR})
# Finally print the mbed-cmake build report
mbed_cmake_print_build_report()