forked from eclipse-iceoryx/iceoryx2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
126 lines (101 loc) · 3.63 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
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache Software License 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
# which is available at https://opensource.org/licenses/MIT.
#
# SPDX-License-Identifier: Apache-2.0 OR MIT
cmake_minimum_required(VERSION 3.22)
set(IOX2_VERSION_STRING "0.4.1")
project(iceoryx2 VERSION ${IOX2_VERSION_STRING})
#TODO how to handle feature flags
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # "Create compile_commands.json file"
macro(add_option)
set(ONE_VALUE_ARGS NAME DESCRIPTION DEFAULT_VALUE)
cmake_parse_arguments(ADD_OPTION "" "${ONE_VALUE_ARGS}" "" ${ARGN})
option(${ADD_OPTION_NAME} ${ADD_OPTION_DESCRIPTION} ${ADD_OPTION_DEFAULT_VALUE})
message(STATUS " ${ADD_OPTION_NAME}: ${${ADD_OPTION_NAME}} (Description: ${ADD_OPTION_DESCRIPTION})")
endmacro()
macro(add_param)
set(ONE_VALUE_ARGS NAME DESCRIPTION DEFAULT_VALUE)
cmake_parse_arguments(ADD_PARAM "" "${ONE_VALUE_ARGS}" "" ${ARGN})
if(NOT ${ADD_PARAM_NAME})
set(${ADD_PARAM_NAME} ${ADD_PARAM_DEFAULT_VALUE})
endif()
message(STATUS " ${ADD_PARAM_NAME}: ${${ADD_PARAM_NAME}} (Description: ${ADD_PARAM_DESCRIPTION})")
endmacro()
set(IOX2_RUST_FEATURES "")
macro(add_rust_feature)
set(ONE_VALUE_ARGS NAME DESCRIPTION DEFAULT_VALUE RUST_FEATURE)
cmake_parse_arguments(ADD_RUST_FEATURE "" "${ONE_VALUE_ARGS}" "" ${ARGN})
option(${ADD_RUST_FEATURE_NAME} ${ADD_RUST_FEATURE_DESCRIPTION} ${ADD_RUST_FEATURE_DEFAULT_VALUE})
message(STATUS " ${ADD_RUST_FEATURE_NAME}: ${${ADD_RUST_FEATURE_NAME}} (Description: ${ADD_RUST_FEATURE_DESCRIPTION})")
if(${ADD_RUST_FEATURE_NAME})
list(APPEND IOX2_RUST_FEATURES ${ADD_RUST_FEATURE_RUST_FEATURE})
endif()
endmacro()
message(STATUS "iceoryx2 options:")
add_option(
NAME BUILD_CXX_BINDING
DESCRIPTION "Build C++ binding"
DEFAULT_VALUE ON
)
add_option(
NAME BUILD_EXAMPLES
DESCRIPTION "Build examples"
DEFAULT_VALUE OFF
)
add_option(
NAME BUILD_TESTING
DESCRIPTION "Build tests"
DEFAULT_VALUE OFF
)
add_option(
NAME SANITIZERS
DESCRIPTION "Build with undefined-behavior- and address-sanitizer"
DEFAULT_VALUE OFF
)
add_param(
NAME RUST_TARGET_TRIPLET
DESCRIPTION "The target triplet for cross compilation, e.g. 'aarch64-unknown-linux-gnu'"
DEFAULT_VALUE ""
)
message(STATUS "iceoryx2 Rust feature flags:")
add_rust_feature(
NAME IOX2_FEATURE_DEV_PERMISSIONS
DESCRIPTION "The permissions of all resources will be set to read, write, execute for everyone."
DEFAULT_VALUE OFF
RUST_FEATURE "iceoryx2/dev_permissions"
)
add_rust_feature(
NAME IOX2_FEATURE_LOGGER_LOG
DESCRIPTION "Enables https://crates.io/crates/log as default logger"
DEFAULT_VALUE OFF
RUST_FEATURE "iceoryx2/logger_log"
)
add_rust_feature(
NAME IOX2_FEATURE_LOGGER_TRACING
DESCRIPTION "Enables https://crates.io/crates/tracing as default logger"
DEFAULT_VALUE OFF
RUST_FEATURE "iceoryx2/logger_tracing"
)
if(SANITIZERS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fsanitize=undefined")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=undefined")
endif()
# C binding
add_subdirectory(iceoryx2-ffi/c)
if(BUILD_EXAMPLES)
add_subdirectory(examples/c)
endif()
# C++ binding
if(BUILD_CXX_BINDING)
add_subdirectory(iceoryx2-ffi/cxx)
if(BUILD_EXAMPLES)
add_subdirectory(examples/cxx)
endif()
endif()