-
-
Notifications
You must be signed in to change notification settings - Fork 219
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
66 lines (60 loc) · 2.59 KB
/
CMakeLists.txt
File metadata and controls
66 lines (60 loc) · 2.59 KB
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
# This software is distributed under the terms of the MIT License.
# Copyright (C) OpenCyphal Development Team <opencyphal.org>
# SPDX-License-Identifier: MIT
# Author: Pavel Kirienko <pavel@opencyphal.org>
#
# This file is only needed for library development and testing. It is not needed to use the library in your project;
# instead, users should integrate the library by copying canard.c and canard.h.
cmake_minimum_required(VERSION 3.20)
project(canard)
enable_testing()
set(CMAKE_CTEST_ARGUMENTS "-V") # Enable test outputs when running `make test`
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# STATIC ANALYSIS
option(NO_STATIC_ANALYSIS "Disable static analysis to speed up the build" OFF)
if (NOT NO_STATIC_ANALYSIS)
# Clang-Tidy
find_program(clang_tidy NAMES clang-tidy REQUIRED)
message(STATUS "Using clang-tidy: ${clang_tidy}")
set(CMAKE_CXX_CLANG_TIDY ${clang_tidy})
set(CMAKE_C_CLANG_TIDY ${clang_tidy})
# Cppcheck
find_program(cppcheck NAMES cppcheck)
if (NOT cppcheck)
message(FATAL_ERROR "Could not locate cppcheck")
endif ()
message(STATUS "Using cppcheck: ${cppcheck}")
set(cppcheck_options
--enable=warning,style,performance,portability
--error-exitcode=2
--suppress=missingIncludeSystem
--suppress=badBitmaskCheck
--suppress=constParameterCallback
--suppress=duplInheritedMember
--suppress=preprocessorErrorDirective
--suppress=unreadVariable
--suppress=passedByValue
--suppress=containerOutOfBounds
--suppress=redundantAssignment
--inline-suppr
)
set(CMAKE_C_CPPCHECK ${cppcheck};--language=c;--std=c11;${cppcheck_options})
set(CMAKE_CXX_CPPCHECK ${cppcheck};--language=c++;--std=c++20;${cppcheck_options})
# Clang-Format
find_program(clang_format NAMES clang-format REQUIRED)
file(GLOB format_files
${CMAKE_SOURCE_DIR}/libcanard/*.[ch]
${CMAKE_SOURCE_DIR}/tests/*/*.[ch]
${CMAKE_SOURCE_DIR}/tests/*/*.[ch]pp
)
message(STATUS "Using clang-format: ${clang_format}; files to format: ${format_files}")
add_custom_target(format COMMAND ${clang_format} -i -fallback-style=none -style=file --verbose ${format_files})
add_custom_target(
format_check
ALL
COMMAND ${clang_format} --dry-run --Werror -fallback-style=none -style=file --verbose ${format_files}
COMMENT "Checking clang-format conformance"
)
endif ()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/demos)