forked from NordicSemiconductor/nRF5-SDK-for-Mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
120 lines (97 loc) · 3.96 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
cmake_minimum_required(VERSION 3.6)
if (NOT CMAKE_VERSION VERSION_LESS 3.9)
# Allow user to enable CMAKE_INTERPROCEDURAL_OPTIMIZATION (LTO) if supported for the toolchain.
# This is supported from CMake version 9 and later.
cmake_policy(SET CMP0069 NEW)
endif ()
set(VERSION_MAJOR 3)
set(VERSION_MINOR 2)
set(VERSION_BUGFIX 0)
set(VERSION_SUFFIX "")
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUGFIX}${VERSION_SUFFIX}" CACHE STRING "" FORCE)
message(STATUS "Configuring CMake for nRF5 SDK for Bluetooth Mesh ${VERSION_STRING}")
set(NRF_MESH_TEST_BUILD 0 CACHE STRING "")
option(BUILD_HOST "Build for host (unit test build)" OFF)
option(BUILD_EXAMPLES "Build all examples with default target." ON)
option(EXPERIMENTAL_INSTABURST_ENABLED "Use experimental Instaburst feature." OFF)
set(MESH_MEM_BACKEND "stdlib" CACHE STRING "Mesh dynamic memory manager backend")
if (NOT BUILD_HOST)
set(CMAKE_SYSTEM_NAME "Generic")
set(CMAKE_SYSTEM_PROCESSOR "ARM")
endif (NOT BUILD_HOST)
# We enable the project() here for CMake to initialize variables s.a. "CMAKE_HOST_W32".
# Languages are enabled _after_ the toolchain has been setup.
project(MBTLE
VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_BUGFIX}
LANGUAGES NONE)
set(CMAKE_CONFIG_DIR "${CMAKE_SOURCE_DIR}/CMake")
set(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR} CACHE STRING "" FORCE)
# Needed tools for generating documentation and serial PyACI
find_package(PythonInterp)
find_package(Doxygen)
find_program(DOT_EXECUTABLE "dot" PATHS ENV PATH)
find_program(MSCGEN_EXECUTABLE "mscgen" PATHS ENV PATH)
include("${CMAKE_CONFIG_DIR}/Toolchain.cmake")
include("${CMAKE_CONFIG_DIR}/Platform.cmake")
include("${CMAKE_CONFIG_DIR}/SoftDevice.cmake")
include("${CMAKE_CONFIG_DIR}/FindDependency.cmake")
include("${CMAKE_CONFIG_DIR}/FindSDK.cmake")
# We have to return manually from here s.t. the CMake generation
# doesn't stop and we have the nRF5_SDK target available.
if (NOT SDK_ROOT)
return()
endif ()
include("${CMAKE_CONFIG_DIR}/BuildType.cmake")
include("${CMAKE_CONFIG_DIR}/Board.cmake")
include("${CMAKE_CONFIG_DIR}/PCLint.cmake")
include("${CMAKE_CONFIG_DIR}/GenerateSESProject.cmake")
include("${CMAKE_CONFIG_DIR}/sdk/${nRF5_SDK_VERSION}.cmake")
include("${CMAKE_CONFIG_DIR}/platform/${PLATFORM}.cmake")
include("${CMAKE_CONFIG_DIR}/softdevice/${SOFTDEVICE}.cmake")
include("${CMAKE_CONFIG_DIR}/board/${BOARD}.cmake")
message(STATUS "SDK: ${nRF5_SDK_VERSION}")
message(STATUS "Platform: ${PLATFORM}")
message(STATUS "Arch: ${${PLATFORM}_ARCH}")
message(STATUS "SoftDevice: ${SOFTDEVICE}")
message(STATUS "Board: ${BOARD}")
set(ARCH ${${PLATFORM}_ARCH})
enable_language(C ASM)
if (NOT BUILD_HOST)
set(CMAKE_EXECUTABLE_SUFFIX ".elf")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
else ()
message(STATUS "Building for HOST")
include("${CMAKE_CONFIG_DIR}/UnitTest.cmake")
include("${CMAKE_CONFIG_DIR}/Coverage.cmake")
include("${CMAKE_CONFIG_DIR}/UBSAN.cmake")
endif ()
if (EXPERIMENTAL_INSTABURST_ENABLED)
if (PLATFORM STREQUAL "nrf52832_xxAA")
add_definitions("-DEXPERIMENTAL_INSTABURST_ENABLED")
else()
message(WARNING "Instaburst is only available on nrf52832_xxAA")
set(EXPERIMENTAL_INSTABURST_ENABLED OFF)
endif()
endif()
# Export compilation commands to .json file (used by clang-complete backends)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_subdirectory("mesh")
add_subdirectory("external")
if (NOT PYTHON_EXECUTABLE)
message(WARNING "Need python executable to generate serial documentation and PyACI")
elseif (NOT DOXYGEN_EXECUTABLE)
message(WARNING "Doxygen not found, documentation build is not available")
else ()
add_subdirectory("tools")
add_subdirectory("doc")
endif ()
if (NOT BUILD_HOST)
include("${CMAKE_CONFIG_DIR}/Nrfjprog.cmake")
add_subdirectory("models")
if (BUILD_EXAMPLES)
add_subdirectory("examples")
else()
add_subdirectory("examples" EXCLUDE_FROM_ALL)
endif ()
endif ()