generated from jaredwolff/zephyr-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
96 lines (78 loc) · 3.37 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
#
# Copyright (c) 2022 Circuit Dojo LLC
#
# SPDX-License-Identifier: Apache-2.0
#
cmake_minimum_required(VERSION 3.13.4)
# Determine the build type
if (NOT BUILD_TYPE)
set(BUILD_TYPE debug)
endif()
# Print out build type
message(STATUS "Build type: ${BUILD_TYPE} 🚀")
# Set environment variables
# set(ZEPHYR_TOOLCHAIN_VARIANT gnuarmemb)
# set(GNUARMEMB_TOOLCHAIN_PATH "C:\\Program Files (x86)\\GNU Tools Arm Embedded\\9 2019-q4-major")
# set(GNUARMEMB_TOOLCHAIN_PATH /Users/jaredwolff/gcc-arm-none-eabi-9-2019-q4-major)
# Set auto generation notice
file(WRITE conf/version.conf "# File is autogenerated. Do not modify.\n\n")
# Get the version from Git
find_package(Git QUIET)
if(GIT_FOUND)
execute_process(
COMMAND git describe --tags --long
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE version
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE stderr
RESULT_VARIABLE return_code
)
if(return_code)
message(STATUS "git describe failed: ${stderr}; ${KERNEL_VERSION_STRING} will be used instead")
elseif(CMAKE_VERBOSE_MAKEFILE)
message(STATUS "git describe stderr: ${stderr}")
endif()
endif()
if(version)
string(REGEX REPLACE "^([0-9]+).*$" "\\1" version_major ${version})
string(REGEX REPLACE "^[0-9]+\.([0-9]+).*$" "\\1" version_minor "${version}")
string(REGEX REPLACE "^[0-9]+\.[0-9]+\.([0-9]+).*$" "\\1" version_patch "${version}")
string(REGEX REPLACE "^[0-9]+\.[0-9]+\.[0-9]+-([0-9]+)-.*$" "\\1" version_commit "${version}")
string(REGEX REPLACE "^[0-9]+\.[0-9]+\.[0-9]+-[0-9]+-(.*)$" "\\1" version_hash "${version}")
# Create version.conf
file(APPEND conf/version.conf "CONFIG_APP_VERSION_MAJOR=${version_major}\n")
file(APPEND conf/version.conf "CONFIG_APP_VERSION_MINOR=${version_minor}\n")
file(APPEND conf/version.conf "CONFIG_APP_VERSION_PATCH=${version_patch}\n")
file(APPEND conf/version.conf "CONFIG_APP_VERSION_COMMIT=${version_commit}\n")
file(APPEND conf/version.conf "CONFIG_APP_VERSION_HASH=\"${version_hash}\"\n")
file(APPEND conf/version.conf "CONFIG_APP_VERSION=\"${version}\"\n")
file(APPEND conf/version.conf "CONFIG_MCUBOOT_IMAGE_VERSION=\"${version_major}.${version_minor}.${version_patch}+${version_commit}\"\n")
message(STATUS "Version: ${version_major}.${version_minor}.${version_patch}-${version_commit}-${version_hash}")
endif()
if(BUILD_TYPE)
file(APPEND conf/version.conf "CONFIG_APP_RELEASE_TYPE=\"${BUILD_TYPE}\"\n")
endif()
# Define configuration files.
list(APPEND CONF_FILE
${CMAKE_CURRENT_SOURCE_DIR}/conf/prj.conf
${CMAKE_CURRENT_SOURCE_DIR}/conf/version.conf
${CMAKE_CURRENT_SOURCE_DIR}/conf/${BUILD_TYPE}.conf
${CMAKE_CURRENT_SOURCE_DIR}/boards/${BOARD}.conf
)
# MCUboot related
list(APPEND mcuboot_OVERLAY_CONFIG
"${CMAKE_CURRENT_SOURCE_DIR}/conf/mcuboot/mcuboot.conf"
)
# Adding custom overlay to add settings that aren't included in the SDK (yet) for the nRF9160 Feather
if(${BOARD} STREQUAL circuitdojo_feather_nrf9160ns)
message(STATUS "Adding .overlay for mcuboot.")
list(APPEND mcuboot_DTC_OVERLAY_FILE
"${CMAKE_CURRENT_SOURCE_DIR}/conf/mcuboot/circuitdojo_feather_nrf9160ns.overlay"
)
endif()
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(application)
add_subdirectory(src/event_manager)
add_subdirectory(src/version)
target_sources(app PRIVATE src/main.c)