-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
CMakeLists.txt
124 lines (109 loc) · 3.66 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
cmake_minimum_required(VERSION 3.16)
project(
isobus
VERSION 0.1
LANGUAGES CXX
DESCRIPTION
"A control function focused implementation of the major ISOBUS and J1939 transport layers"
)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# Make CTest available and the BUILD_TESTING option (OFF by default)
option(BUILD_TESTING "Set to ON to enable building of tests from top level" OFF)
include(CTest)
if(BUILD_TESTING
AND NOT MSVC
AND NOT APPLE)
# Set --coverage flag for gcovr (SonarCloud)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
option(
CAN_STACK_DISABLE_THREADS
"Set to ON to disable multi-threading, which removes the need for std::thread, std::mutex, and related libraries."
OFF)
if(NOT CAN_STACK_DISABLE_THREADS AND NOT ARDUINO)
# Find packages required for Threading
set(THREADS_PREFER_PTHREAD_FLAG ON)
# ESP-IDF doesn't implement find_package(Threads) correctly (dec 2022)
if(NOT ESP_PLATFORM)
find_package(Threads REQUIRED)
endif()
endif()
# A handy function to prepend text to all elements in a list (useful for
# subdirectories)
function(prepend var prefix)
set(listVar "")
foreach(arg ${ARGN})
list(APPEND listVar "${prefix}/${arg}")
endforeach(arg)
set(${var}
"${listVar}"
PARENT_SCOPE)
endfunction(prepend)
# Add subdirectories
add_subdirectory("utility")
add_subdirectory("isobus")
add_subdirectory("hardware_integration")
option(BUILD_EXAMPLES "Set to ON to enable building of examples from top level"
OFF)
if(BUILD_EXAMPLES)
add_subdirectory("examples/transport_layer")
add_subdirectory("examples/diagnostic_protocol")
add_subdirectory("examples/pgn_requests")
add_subdirectory("examples/nmea2000/fast_packet_protocol")
add_subdirectory("examples/nmea2000/nmea2000_generator")
add_subdirectory("examples/nmea2000/nmea2000_parser")
add_subdirectory("examples/virtual_terminal/version3_object_pool")
add_subdirectory("examples/virtual_terminal/aux_functions")
add_subdirectory("examples/virtual_terminal/aux_inputs")
add_subdirectory("examples/task_controller_client")
add_subdirectory("examples/task_controller_server")
add_subdirectory("examples/guidance")
add_subdirectory("examples/seeder_example")
endif()
if(BUILD_TESTING)
add_subdirectory("test")
endif()
install(
TARGETS Isobus Utility HardwareIntegration
EXPORT isobusTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin)
# Install all the header files for all the libraries
install(
DIRECTORY isobus/include/
DESTINATION include
FILES_MATCHING
PATTERN "*.hpp")
install(
DIRECTORY hardware_integration/include/
DESTINATION include
FILES_MATCHING
PATTERN "*.hpp")
install(
DIRECTORY utility/include/
DESTINATION include
FILES_MATCHING
PATTERN "*.hpp")
install(
EXPORT isobusTargets
FILE isobusTargets.cmake
NAMESPACE isobus::
DESTINATION lib/cmake/isobus)
configure_file(cmake/isobusConfig.cmake.in isobusConfig.cmake @ONLY)
write_basic_package_version_file(isobusConfigVersion.cmake
COMPATIBILITY SameMajorVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/isobusConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/isobusConfigVersion.cmake"
DESTINATION lib/cmake/isobus)
set(CPACK_PACKAGE_CONTACT "delgrossoengineering@protonmail.com")
set(CPACK_DEBIAN_FILENAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE
"https://github.com/Open-Agriculture/AgIsoStack-plus-plus")
set(CPACK_PACKAGE_VENDOR "Open-Agriculture")
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
include(CPack)