-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
132 lines (117 loc) · 6.83 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
cmake_minimum_required(VERSION 3.10)
if (DEFINED LN_SDK_ROOT)
message(STATUS "<GET> LN_SDK_ROOT = ${LN_SDK_ROOT}")
if (NOT ${LN_SDK_ROOT} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
set(ERR_MSG "--------------------------------------------------------\n"
"LN_SDK_ROOT expects to be current directory: \n"
"LN_SDK_ROOT = ${LN_SDK_ROOT} \n"
"CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR} \n"
"--------------------------------------------------------\n")
message(FATAL_ERROR "${ERR_MSG}")
endif()
else()
set(LN_SDK_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "<SET> LN_SDK_ROOT = ${LN_SDK_ROOT}")
endif()
if(DEFINED CHIP_SERIAL)
message(STATUS "<GET> CHIP_SERIAL = ${CHIP_SERIAL}")
else()
set(CHIP_SERIAL ln882h)
message(STATUS "<SET> CHIP_SERIAL = ${CHIP_SERIAL}")
endif()
################################################################################
## NOTE: no need to setup toolchain if LN SDK is used as git submodule.
## It's the git main module's duty to setup toolchain.
################################################################################
if(NOT DEFINED VENDOR_SDK_ADAPTED)
############################################################################
####################### NOTE: select user project here ##################
############################################################################
if(NOT DEFINED USER_PROJECT)
set(USER_PROJECT OpenBeken)
#set(USER_PROJECT wifi_mcu_basic_example)
#set(USER_PROJECT ble_mcu_data_trans)
#set(USER_PROJECT ble_mcu_prf_hid_mouse)
#set(USER_PROJECT ble_mcu_prf_battery)
#set(USER_PROJECT combo_mcu_basic_example)
#set(USER_PROJECT mcu_peripheral_driver_test)
message(STATUS "<SET> USER_PROJECT = ${USER_PROJECT}")
else()
message(STATUS "<GET> USER_PROJECT= ${USER_PROJECT}")
endif()
############################################################################
############################ Debug/Release ###############################
############################################################################
set(CMAKE_BUILD_TYPE Release CACHE STRING "build for release" FORCE)
# set(CMAKE_BUILD_TYPE Debug CACHE STRING "build for debug" FORCE)
set(allowableBuildTypes Debug Release)
if (NOT CMAKE_BUILD_TYPE IN_LIST allowableBuildTypes)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "build for debug" FORCE)
endif()
message(STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
############################################################################
####################### set up cross compiler toolchain ##################
############################################################################
include(${LN_SDK_ROOT}/project/${USER_PROJECT}/gcc/gcc-toolchain-setup.cmake)
include(${LN_SDK_ROOT}/project/${USER_PROJECT}/gcc/gcc-compiler-flags.cmake)
############################################################################
######################### project language selection ####################
############################################################################
project(LN-Combo-SDK
VERSION 1.0.0
LANGUAGES C CXX ASM
)
############################################################################
########################### misc settings ##############################
############################################################################
set(CMAKE_VERBOSE_MAKEFILE ON)
#----------------------------- output path -----------------------------
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
else()
message(STATUS "----------------------------------------------------------")
message(STATUS "----------- LN SDK Configured by third_party -----------")
message(STATUS "----------------------------------------------------------")
set(USER_PROJECT main_entry_for_tuya)
endif()
################################################################################
########################## default module selection ########################
#-------------------------- library built within LN software team -------------
option(COMP_WIFI_SUPPORT "LN WiFi firmware." OFF)
option(COMP_BLE_SUPPORT "LN BLE firmware." OFF)
#---------------------------- library choosen by customer -------------------
option(COMP_DHCPD_SUPPORT "DHCP client." OFF)
option(COMP_LWIP_SUPPORT "Light weight TCP/IP stack." OFF)
################################################################################
########################### define module top dir ##########################
################################################################################
set(MCU_LN882X_DIR ${LN_SDK_ROOT}/mcu)
set(COMP_BLE_DIR ${LN_SDK_ROOT}/components/ble)
set(COMP_FOTA_DIR ${LN_SDK_ROOT}/components/fota)
set(COMP_KV_DIR ${LN_SDK_ROOT}/components/fs/kv)
set(COMP_NVDS_DIR ${LN_SDK_ROOT}/components/fs/nvds)
set(COMP_PARTMGR_DIR ${LN_SDK_ROOT}/components/fs/partition_mgr)
set(COMP_KERNEL_DIR ${LN_SDK_ROOT}/components/kernel)
set(COMP_LNAT_DIR ${LN_SDK_ROOT}/components/ln_at)
set(COMP_LNAT_CMD_DIR ${LN_SDK_ROOT}/components/ln_at_cmd)
set(COMP_DHCPD_DIR ${LN_SDK_ROOT}/components/net/dhcpd)
set(COMP_IPERF_DIR ${LN_SDK_ROOT}/components/net/iperf)
set(COMP_PING_DIR ${LN_SDK_ROOT}/components/net/ping)
set(COMP_HTTPSCLIENT_DIR ${LN_SDK_ROOT}/components/net/httpsclient)
set(COMP_MBEDTLS_DIR ${LN_SDK_ROOT}/components/net/mbedtls)
set(COMP_SERIAL_DIR ${LN_SDK_ROOT}/components/serial)
set(COMP_UTILS_DIR ${LN_SDK_ROOT}/components/utils)
set(COMP_LIBC_STUB_DIR ${LN_SDK_ROOT}/components/libc)
set(COMP_WIFI_DIR ${LN_SDK_ROOT}/components/wifi)
set(COMP_SMARTLINK_DIR ${LN_SDK_ROOT}/components/smartlink)
if(DEFINED THIRD_PARTY_LWIP AND (THIRD_PARTY_LWIP))
message(STATUS "LwIP: third-party provided.")
else()
message(STATUS "LwIP: LN SDK provided.")
set(COMP_LWIP_DIR ${LN_SDK_ROOT}/components/net/lwip-2.1.3/src)
endif()
################################################################################
############################# user project ###############################
################################################################################
add_subdirectory(${LN_SDK_ROOT}/project/${USER_PROJECT})
add_subdirectory(components)