forked from bolderflight/sbus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
62 lines (62 loc) · 1.81 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
# v3.14 required for FetchContent_MakeAvailable
cmake_minimum_required(VERSION 3.14)
if (DEFINED MCU)
include(FetchContent)
FetchContent_Declare(
mcu_support
GIT_REPOSITORY https://github.com/bolderflight/mcu-support.git
GIT_TAG v1.1.0
)
FetchContent_MakeAvailable(mcu_support)
# Setting up the toolchain
set(CMAKE_TOOLCHAIN_FILE "${mcu_support_SOURCE_DIR}/cmake/cortex.cmake")
# Project information
project(Sbus
VERSION 8.1.4
DESCRIPTION "SBUS encoder and decoder"
LANGUAGES C CXX
)
# Grab the processor and set up definitions and compile options
include(${mcu_support_SOURCE_DIR}/cmake/config_mcu.cmake)
configMcu(${MCU} ${mcu_support_SOURCE_DIR})
# Fetch core
FetchContent_Declare(
core
GIT_REPOSITORY https://github.com/bolderflight/core.git
GIT_TAG v3.1.3
)
FetchContent_MakeAvailable(core)
# Add the library target
add_library(sbus
src/sbus.cpp
src/sbus.h
)
# Link libraries
target_link_libraries(sbus
PUBLIC
core
)
# Setup include directories
target_include_directories(sbus PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:include>
)
# Example and test if this project is built separately
if (PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME)
# Add the example target
add_executable(sbus_example examples/cmake/sbus_example.cc)
# Add the includes
target_include_directories(sbus_example PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Link libraries to the example target
target_link_libraries(sbus_example
PRIVATE
sbus
)
# Add hex and upload targets
include(${mcu_support_SOURCE_DIR}/cmake/flash_mcu.cmake)
FlashMcu(sbus_example ${MCU} ${mcu_support_SOURCE_DIR})
endif()
endif()