forked from apache/nuttx-apps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
93 lines (73 loc) · 3.34 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
# ##############################################################################
# apps/canutils/libdronecan/CMakeLists.txt
#
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership. The ASF licenses this
# file to you under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.
#
# ##############################################################################
if(CONFIG_CANUTILS_LIBDRONECAN)
# ############################################################################
# Config and Fetch libdronecan lib
# ############################################################################
set(LIBDRONECAN_DIR ${CMAKE_CURRENT_LIST_DIR}/libcanard)
if(NOT EXISTS ${LIBDRONECAN_DIR})
FetchContent_Declare(
libdronecan_fetch
URL ${CONFIG_LIBDRONECAN_URL}/${CONFIG_LIBDRONECAN_VERSION}.zip SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/libcanard BINARY_DIR
${CMAKE_BINARY_DIR}/apps/canutils/libdronecan/libcanard
DOWNLOAD_NO_PROGRESS true
TIMEOUT 30)
FetchContent_GetProperties(libdronecan_fetch)
if(NOT libdronecan_fetch_POPULATED)
FetchContent_Populate(libdronecan_fetch)
endif()
endif()
# ############################################################################
# Flags
# ############################################################################
set(CFLAGS -std=c99 -DCANARD_ASSERT=DEBUGASSERT)
# Conflict with Cyphal's libcanard
if(CONFIG_CANUTILS_LIBOPENCYPHAL)
list(APPEND CFLAGS -DcanardInit=dronecanardInit)
endif()
if(CONFIG_LIBDRONECAN_CANFD)
list(APPEND CFLAGS -DCANARD_ENABLE_CANFD=1)
endif()
# ############################################################################
# Sources
# ############################################################################
set(CSRCS ${LIBDRONECAN_DIR}/canard.c)
if(CONFIG_NET_CAN)
list(APPEND CSRCS ${LIBDRONECAN_DIR}/drivers/socketcan/socketcan.c)
else()
list(APPEND CSRCS ${LIBDRONECAN_DIR}/drivers/nuttx/canard_nuttx.c)
endif()
# ############################################################################
# Include Directory
# ############################################################################
set(INCDIR ${NUTTX_APPS_DIR}/canutils/libdronecan/libcanard)
if(CONFIG_NET_CAN)
list(APPEND INCDIR
${NUTTX_APPS_DIR}/canutils/libdronecan/libcanard/drivers/socketcan)
endif()
# ############################################################################
# Library Configuration
# ############################################################################
nuttx_add_user_library(libdronecan)
target_sources(libdronecan PRIVATE ${CSRCS})
target_compile_options(libdronecan PRIVATE ${CFLAGS})
target_include_directories(libdronecan PRIVATE ${INCDIR})
endif()