-
Notifications
You must be signed in to change notification settings - Fork 502
/
CMakeLists.txt
154 lines (137 loc) · 5.01 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT
#
cmake_minimum_required(VERSION 3.22.0)
include(cmake/CMakeCommon.cmake REQUIRED)
project(libcyphal
VERSION ${LIBCYPHAL_VERSION}
LANGUAGES CXX C
HOMEPAGE_URL https://github.com/OpenCyphal-Garage/libcyphal
)
# Use -DNO_STATIC_ANALYSIS=1 to suppress static analysis.
# If not suppressed, the tools used here shall be available, otherwise the build will fail.
if (NOT NO_STATIC_ANALYSIS)
# clang-tidy (separate config files per directory)
find_program(clang_tidy NAMES clang-tidy)
if (NOT clang_tidy)
message(FATAL_ERROR "Could not locate clang-tidy")
endif ()
message(STATUS "Using clang-tidy: ${clang_tidy}")
endif ()
# +---------------------------------------------------------------------------+
# | BUILD DSDL TYPES
# +---------------------------------------------------------------------------+
find_package(public_regulated_data_types REQUIRED)
find_package(nnvg REQUIRED)
if (CETL_ENABLE_DEBUG_ASSERT)
set(NNVG_ASSERT_ARGS "ENABLE_SER_ASSERT")
else()
set(NNVG_ASSERT_ARGS )
endif()
if (${CMAKE_MESSAGE_LOG_LEVEL} MATCHES "VERBOSE|TRACE|DEBUG")
set(NNVG_VERBOSE_ARGS "VERBOSE")
else()
set(NNVG_VERBOSE_ARGS )
endif()
define_nunavut_support_target(
TARGET dsdl_support
${NNVG_ASSERT_ARGS}
${NNVG_VERBOSE_ARGS}
)
add_dsdl_cpp_codegen(
TARGET dsdl_public_types
DSDL_ROOT_DIR ${public_regulated_data_types_SOURCE_DIR}/uavcan
${NNVG_ASSERT_ARGS}
${NNVG_VERBOSE_ARGS}
DSDL_DEPENDENCIES
dsdl_support
)
add_subdirectory(test/unittest)
add_subdirectory(docs)
add_custom_target(
docs
DEPENDS
generate_libcyphal_docs
)
add_custom_target(
build
DEPENDS
build_unittests
build_examples
)
if (CMAKE_BUILD_TYPE STREQUAL "Coverage")
add_custom_target(
unittest
DEPENDS
run_unittests
gcovr_html_report_for_unittest
run_examples
gcovr_html_report_for_examples
)
else()
add_custom_target(
unittest
DEPENDS
run_unittests
run_examples
)
endif()
add_custom_target(
release
DEPENDS
build
unittest
docs
)
if (${CMAKE_CXX_PLATFORM_ID} STREQUAL "Linux")
message(STATUS "TODO: add GNU/Linux demos")
#add_subdirectory(demonstration/linux)
#add_dependencies(build libcyphal_demo_posix)
endif()
# Don't normalize deviance: if CMAKE_TOOLCHAIN_FILE is not set then provide
# an initialized default to display in the status thus avoiding a warning about
# using an uninitialized variable.
if (NOT CMAKE_TOOLCHAIN_FILE)
set(LOCAL_CMAKE_TOOLCHAIN_FILE "(not set)")
else()
set(LOCAL_CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
endif()
message(STATUS "-------------------------------------------------------------------\n\
| ${CMAKE_PROJECT_NAME}
-- -------------------------------------------------------------------\n\
LIBCYPHAL_ROOT: ${LIBCYPHAL_ROOT}\n\
LIBCYPHAL_INCLUDE: ${LIBCYPHAL_INCLUDE}\n\
LIBCYPHAL_VERSION: ${LIBCYPHAL_VERSION}\n\
LIBCYPHAL_INTROSPECTION_TRACE_ENABLE: ${LIBCYPHAL_INTROSPECTION_TRACE_ENABLE}\n\
LIBCYPHAL_INTROSPECTION_ENABLE_ASSERT: ${LIBCYPHAL_INTROSPECTION_ENABLE_ASSERT}\n\
CETLVAST_CPP_STANDARD: ${CETLVAST_CPP_STANDARD}\n\
CMAKE_PROJECT_NAME: ${CMAKE_PROJECT_NAME}\n\
CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}\n\
CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}\n\
CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}\n\
CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}\n\
CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}\n\
CMAKE_MESSAGE_LOG_LEVEL: ${CMAKE_MESSAGE_LOG_LEVEL}\n\
CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}\n\
CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}\n\
FETCHCONTENT_FULLY_DISCONNECTED: ${FETCHCONTENT_FULLY_DISCONNECTED}\n\
\n\
CETL
CETL_ENABLE_DEBUG_ASSERT: ${CETL_ENABLE_DEBUG_ASSERT}\n\
\n\
Standard Library\n\
LIBCXX_ENABLE_ASSERTIONS: ${LIBCXX_ENABLE_ASSERTIONS}\n\
-- ------------------------------------------------------------------\n\
")
message(STATUS "[ Build Kit ]-------------------------------------------\n\
CMAKE_TOOLCHAIN_FILE: ${LOCAL_CMAKE_TOOLCHAIN_FILE}\n\
CETLVAST_FLAG_SET: ${CETLVAST_FLAG_SET}\n\
CMAKE_CXX_COMPILER_[ID-VER]: ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}\n\
CMAKE_C_COMPILER_[ID-VER]: ${CMAKE_CXX_COMPILER_ID}-${CMAKE_C_COMPILER_VERSION}\n\
CMAKE_AR: ${CMAKE_AR}\n\
CMAKE_LINKER: ${CMAKE_LINKER}\n\
CMAKE_RANLIB: ${CMAKE_RANLIB}\n\
CMAKE_[lang]_PLATFORM_ID: ${CMAKE_CXX_PLATFORM_ID}\n\
-----------------------------------------------------------\n\
")