forked from eProsima/Fast-DDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
141 lines (126 loc) · 5.84 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
# Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://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.
# Require C++ 14 for testing as both GTest v1.14.0 and ROS 2 Jazzy require it anyways
set(FORCE_CXX "14")
check_stdcxx(${FORCE_CXX})
option(PERFORMANCE_TESTS "Activate the building and execution of performance tests" OFF)
option(SYSTEM_TESTS "Activate the building and execution of system tests" OFF)
option(PROFILING_TESTS "Activate the building and execution of profiling tests" OFF)
option(EPROSIMA_BUILD_TESTS "Activate the building and execution unit tests and integral tests" OFF)
option(FASTDDS_EXAMPLE_TESTS "Activate the building and execution of Fast DDS examples tests" OFF)
if(EPROSIMA_BUILD)
set(EPROSIMA_BUILD_TESTS ON)
set(SYSTEM_TESTS ON)
endif()
configure_file(CTestCustom.cmake.in ${PROJECT_BINARY_DIR}/CTestCustom.cmake)
file(TO_CMAKE_PATH "${PROJECT_SOURCE_DIR}/valgrind.supp" MEMORYCHECK_SUPPRESSIONS_FILE_TMP)
set(MEMORYCHECK_SUPPRESSIONS_FILE ${MEMORYCHECK_SUPPRESSIONS_FILE_TMP} CACHE FILEPATH "Valgrind suppresions file")
# Check if /etc/hosts file has been modified to add dummy host test subjects
if(WIN32)
execute_process(COMMAND powershell -C Resolve-DNSName -Name www.acme.com.test -CacheOnly
RESULT_VARIABLE EPROSIMA_TEST_DNS_NOT_SET_UP OUTPUT_QUIET ERROR_QUIET)
elseif(APPLE)
execute_process(
COMMAND dscacheutil -q host -a name www.acme.com.test
COMMAND grep www.acme.com.test
RESULT_VARIABLE EPROSIMA_TEST_DNS_NOT_SET_UP OUTPUT_QUIET ERROR_QUIET)
else()
execute_process(COMMAND getent hosts www.acme.com.test
RESULT_VARIABLE EPROSIMA_TEST_DNS_NOT_SET_UP OUTPUT_QUIET ERROR_QUIET)
endif()
message(STATUS "EPROSIMA_TEST_DNS_NOT_SET_UP: '${EPROSIMA_TEST_DNS_NOT_SET_UP}'")
###############################################################################
# Testing
###############################################################################
if(EPROSIMA_BUILD_TESTS)
find_package(GTest CONFIG REQUIRED)
include(${PROJECT_SOURCE_DIR}/cmake/testing/GoogleTest.cmake)
add_subdirectory(blackbox)
add_subdirectory(unittest)
add_subdirectory(xtypes)
add_subdirectory(dds/communication)
add_subdirectory(dds/communication/security)
add_subdirectory(dds/discovery)
if(UNIX AND NOT APPLE AND STRICT_REALTIME)
add_subdirectory(realtime)
endif()
endif()
###############################################################################
# Example tests
###############################################################################
if (COMPILE_EXAMPLES AND FASTDDS_EXAMPLE_TESTS)
add_subdirectory(examples)
endif()
###############################################################################
# Profiling tests using valgrind
###############################################################################
if(NOT ((MSVC OR MSVC_IDE)) AND PROFILING_TESTS)
find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
if(CTEST_MEMORYCHECK_COMMAND)
add_subdirectory(profiling)
endif()
endif()
###############################################################################
# Performance tests
###############################################################################
if(PERFORMANCE_TESTS)
add_subdirectory(performance)
endif()
###############################################################################
# System tests
###############################################################################
if(SYSTEM_TESTS)
add_subdirectory(system/tools/fastdds)
add_subdirectory(system/tools/fds)
endif()
if(EPROSIMA_BUILD_TESTS AND QNX)
install(DIRECTORY ${PROJECT_BINARY_DIR}/test/
DESTINATION bin/Fast-DDS_test
PATTERN "*.cmake" EXCLUDE
PATTERN "*.d" EXCLUDE
PATTERN "*.dir" EXCLUDE
PATTERN "*.internal" EXCLUDE
PATTERN "*.make" EXCLUDE
PATTERN "*.marks" EXCLUDE
PATTERN "*.o" EXCLUDE
PATTERN "*.ts" EXCLUDE
PATTERN "*.txt" EXCLUDE
PATTERN "CMakeFiles" EXCLUDE
PATTERN "Makefile" EXCLUDE
PATTERN "cmake" EXCLUDE
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/test/certs
DESTINATION bin/Fast-DDS_test
)
endif()
if (ANDROID)
option(INSTALL_ANDROID_TESTS "Install Built Tests to Device" OFF)
if (INSTALL_ANDROID_TESTS)
install(CODE "set(ANDROID \"${ANDROID}\")
set(ANDROID_TESTING_ROOT \"${ANDROID_TESTING_ROOT}\")
set(CMAKE_BINARY_DIR \"${CMAKE_BINARY_DIR}\")
message(STATUS \"Android testing ROOT is '${ANDROID_TESTING_ROOT}'\")
if(ANDROID_TESTING_ROOT)
file(GLOB_RECURSE CTEST_GENERATED_FILES RELATIVE \"${CMAKE_BINARY_DIR}\" \"CTestTestfile.cmake\")
foreach(CTEST_FILE \${CTEST_GENERATED_FILES})
file(READ \${CTEST_FILE} contents)
message(STATUS \"Processing file \${CTEST_FILE}\")
string(REGEX REPLACE \"${CMAKE_BINARY_DIR}\" \"${ANDROID_TESTING_ROOT}\" contents \${contents})
file(REMOVE \${CTEST_FILE})
file(WRITE \${CTEST_FILE} \${contents})
endforeach()
endif()
execute_process(COMMAND adb push \"${CMAKE_BINARY_DIR}/test\" \"${ANDROID_TESTING_ROOT}\") ")
endif()
endif()