-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
124 lines (105 loc) · 5 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
################################################################################
# Copyright (c) 2024 Continental Corporation
#
# This program and the accompanying materials are made available under the
# terms of the Apache License, Version 2.0 which is available at
# https://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.
#
# SPDX-License-Identifier: Apache-2.0
################################################################################
cmake_minimum_required(VERSION 3.13)
include(CMakeDependentOption)
# Project call
include("${CMAKE_CURRENT_LIST_DIR}/ecaludp/version.cmake")
project(ecaludp VERSION ${ECALUDP_VERSION_MAJOR}.${ECALUDP_VERSION_MINOR}.${ECALUDP_VERSION_PATCH})
# Normalize backslashes from Windows paths
file(TO_CMAKE_PATH "${CMAKE_MODULE_PATH}" CMAKE_MODULE_PATH)
file(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH)
message(STATUS "Module Path: ${CMAKE_MODULE_PATH}")
message(STATUS "Prefix Path: ${CMAKE_PREFIX_PATH}")
# CMake Options
option(ECALUDP_ENABLE_NPCAP
"Enable the NPCAP based socket emulation to receive UDP data without actually opening a socket."
OFF)
option(ECALUDP_BUILD_SAMPLES
"Build project samples."
ON)
option(ECALUDP_BUILD_TESTS
"Build the eCAL UDP tests"
OFF)
option(ECALUDP_USE_BUILTIN_ASIO
"Use the builtin asio submodule. If set to OFF, asio must be available from somewhere else (e.g. system libs)."
ON)
option(ECALUDP_USE_BUILTIN_RECYCLE
"Use the builtin steinwurf::recycle submodule. If set to OFF, recycle must be available from somewhere else (e.g. system libs)."
ON)
cmake_dependent_option(ECALUDP_USE_BUILTIN_UDPCAP
"Use the builtin udpcap submodule. Only needed if ECALUDP_ENABLE_NPCAP is ON. If set to OFF, udpcap must be available from somewhere else (e.g. system libs). Setting this option to ON will also use the default dependencies of udpcap (npcap-sdk, pcapplusplus)."
ON # Default value if dependency is met
"ECALUDP_ENABLE_NPCAP" # Dependency
OFF) # Default value if dependency is not met
cmake_dependent_option(ECALUDP_USE_BUILTIN_GTEST
"Use the builtin GoogleTest submodule. Only needed if ECALUDP_BUILD_TESTS is ON. If set to OFF, GoogleTest must be available from somewhere else (e.g. system libs)."
ON # Default value if dependency is met
"ECALUDP_BUILD_TESTS" # Dependency
OFF) # Default value if dependency is not met
# Set Debug postfix
set(CMAKE_DEBUG_POSTFIX d)
set(CMAKE_MINSIZEREL_POSTFIX minsize)
set(CMAKE_RELWITHDEBINFO_POSTFIX reldbg)
# Use builtin asio
if (ECALUDP_USE_BUILTIN_ASIO)
include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/build-asio.cmake")
endif()
# Use builtin recycle
if (ECALUDP_USE_BUILTIN_RECYCLE)
include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/build-recycle.cmake")
endif()
# Use builtin recycle
if (ECALUDP_USE_BUILTIN_UDPCAP)
include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/build-udpcap.cmake")
endif()
# Use builtin gtest
if (ECALUDP_USE_BUILTIN_GTEST)
include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/build-gtest.cmake")
endif()
# For tests we need to make sure that all shared libraries and executables are
# put into the same directory. Otherwise the tests will fail on windows.
if(ECALUDP_BUILD_TESTS AND (BUILD_SHARED_LIBS OR (ECALUDP_LIBRARY_TYPE STREQUAL "SHARED")))
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
endif()
# Add main ecaludp library
add_subdirectory(ecaludp)
# Add the ecaludp dummy module (for finding ecaludp::ecaludp within this build)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ecaludp-module)
# Add samples, if enabled
if (ECALUDP_BUILD_SAMPLES)
add_subdirectory(samples/ecaludp_sample)
add_subdirectory(samples/ecaludp_perftool)
if (ECALUDP_ENABLE_NPCAP)
add_subdirectory(samples/ecaludp_sample_npcap)
endif()
endif()
# Add Tests if enabled
if (ECALUDP_BUILD_TESTS)
enable_testing()
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/tests/ecaludp_test")
if (ECALUDP_ENABLE_NPCAP)
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/tests/ecaludp_npcap_test")
endif()
# Check if ecaludp is a static lib. We can only add the private tests for
# static libs and object libs, as we need to have access to the private
# implementation details.
get_target_property(ecaludp_target_type ecaludp TYPE)
if ((ecaludp_target_type STREQUAL STATIC_LIBRARY) OR (ecaludp_target_type STREQUAL OBJECT_LIBRARY))
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/tests/ecaludp_private_test")
endif()
endif()
# Make this package available for packing with CPack
include("${CMAKE_CURRENT_LIST_DIR}/cpack_config.cmake")