forked from EdgeTX/edgetx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
142 lines (117 loc) · 3.84 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
cmake_minimum_required(VERSION 3.13)
project(EdgeTX)
set(VERSION_MAJOR "2")
set(VERSION_MINOR "9")
set(VERSION_REVISION "0")
set(CODENAME "dev")
if(MINGW OR WIN32)
set(CMAKE_OBJECT_PATH_MAX 200)
endif()
if(DEFINED ENV{EDGETX_VERSION_TAG})
set(VERSION_TAG "$ENV{EDGETX_VERSION_TAG}")
else()
if(DEFINED ENV{EDGETX_VERSION_SUFFIX})
set(VERSION_SUFFIX "$ENV{EDGETX_VERSION_SUFFIX}")
else()
set(VERSION_SUFFIX "selfbuild") # If not defined, set suffix to selfbuild
endif()
endif()
set(VERSION_FAMILY ${VERSION_MAJOR}.${VERSION_MINOR})
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION})
option(EdgeTX_SUPERBUILD "Cross-compile EdgeTX for each toolchain" ON)
include(ExternalProject)
if(EdgeTX_SUPERBUILD)
# Fetch all command line args into CMAKE_ARGS
get_cmake_property(CACHE_VARS CACHE_VARIABLES)
foreach(CACHE_VAR ${CACHE_VARS})
get_property(CACHE_VAR_HELPSTRING CACHE ${CACHE_VAR} PROPERTY HELPSTRING)
if(CACHE_VAR_HELPSTRING STREQUAL "No help, variable specified on the command line.")
get_property(CACHE_VAR_TYPE CACHE ${CACHE_VAR} PROPERTY TYPE)
if(CACHE_VAR_TYPE STREQUAL "UNINITIALIZED")
set(CACHE_VAR_TYPE)
else()
set(CACHE_VAR_TYPE :${CACHE_VAR_TYPE})
endif()
list(APPEND CMAKE_ARGS "-D${CACHE_VAR}${CACHE_VAR_TYPE}=${${CACHE_VAR}}")
endif()
endforeach()
message("-- CMAKE_ARGS: ${CMAKE_ARGS}")
message("-- CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
# Add explicit targets for triggering cmake in the external projects
set_property(DIRECTORY PROPERTY EP_STEP_TARGETS configure clean)
# Native targets
ExternalProject_Add(native
SOURCE_DIR ${CMAKE_SOURCE_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/native
CMAKE_ARGS ${CMAKE_ARGS} -Wno-dev -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
CMAKE_CACHE_ARGS
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_SOURCE_DIR}/cmake/toolchain/native.cmake
-DEdgeTX_SUPERBUILD:BOOL=0
-DNATIVE_BUILD:BOOL=1
INSTALL_COMMAND ""
EXCLUDE_FROM_ALL TRUE
)
# ARM targets
ExternalProject_Add(arm-none-eabi
SOURCE_DIR ${CMAKE_SOURCE_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/arm-none-eabi
CMAKE_ARGS ${CMAKE_ARGS} -Wno-dev -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
CMAKE_CACHE_ARGS
-DCMAKE_TOOLCHAIN_FILE:FILEPATH=${CMAKE_SOURCE_DIR}/cmake/toolchain/arm-none-eabi.cmake
-DEdgeTX_SUPERBUILD:BOOL=0
-DNATIVE_BUILD:BOOL=0
INSTALL_COMMAND ""
EXCLUDE_FROM_ALL TRUE
)
add_custom_target(configure
DEPENDS native-configure arm-none-eabi-configure)
add_custom_target(libsimulator
COMMAND $(MAKE) -C native libsimulator
DEPENDS native-configure
)
add_custom_target(simulator
COMMAND $(MAKE) -C native simulator
DEPENDS native-configure
)
add_custom_target(simu
COMMAND $(MAKE) -C native simu
DEPENDS native-configure
)
add_custom_target(companion
COMMAND $(MAKE) -C native companion
DEPENDS native-configure
)
add_custom_target(gtests-radio
COMMAND $(MAKE) -C native gtests-radio
DEPENDS native-configure
)
add_custom_target(tests-radio
COMMAND $(MAKE) -C native tests-radio
DEPENDS native-configure
)
add_custom_target(firmware
COMMAND $(MAKE) -C arm-none-eabi firmware
DEPENDS arm-none-eabi-configure
)
add_custom_target(firmware-size
COMMAND $(MAKE) -C arm-none-eabi firmware-size
DEPENDS arm-none-eabi-configure
)
# Quit cmake at this point
return()
endif()
enable_language(ASM)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
include(GenericDefinitions)
if (VERSION_TAG)
message(STATUS "EdgeTX ${VERSION_TAG} @ ${GIT_STR}")
else()
message(STATUS "EdgeTX ${VERSION}-${VERSION_SUFFIX} @ ${GIT_STR}")
endif()
if(NATIVE_BUILD)
include(NativeTargets)
else()
# Prevent CMake warnings
set(IGNORE "${SDL_LIBRARY_PATH}")
endif()
add_subdirectory(${RADIO_SRC_DIR})