-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
57 lines (56 loc) · 1.69 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
# 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.0.0
)
FetchContent_MakeAvailable(mcu_support)
# Setting up the toolchain
set(CMAKE_TOOLCHAIN_FILE "${mcu_support_SOURCE_DIR}/cmake/cortex.cmake")
# Project information
project(Pwm
VERSION 6.0.2
DESCRIPTION "PWM actuator library"
LANGUAGES 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.0.2
)
FetchContent_MakeAvailable(core)
# Add the library target
add_library(pwm INTERFACE)
# Link libraries
target_link_libraries(pwm
INTERFACE
core
)
# Setup include directories
target_include_directories(pwm INTERFACE src/)
# Example and test if this project is built separately
if (PROJECT_NAME STREQUAL CMAKE_PROJECT_NAME)
# Add the example target
add_executable(pwm_example examples/cmake/pwm_example.cc)
# Add the includes
target_include_directories(pwm_example PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# Link libraries to the example target
target_link_libraries(pwm_example
PRIVATE
pwm
)
# Add hex and upload targets
include(${mcu_support_SOURCE_DIR}/cmake/flash_mcu.cmake)
FlashMcu(pwm_example ${MCU} ${mcu_support_SOURCE_DIR})
endif()
endif()