-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
133 lines (111 loc) · 3.58 KB
/
Copy pathCMakeLists.txt
File metadata and controls
133 lines (111 loc) · 3.58 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
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
cmake_minimum_required(VERSION 3.1)
project(real_time_tools)
# required to use std::shared_ptr in code and to link the python bindings
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--no-as-needed")
endif()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
# Use C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED on)
find_package(catkin REQUIRED COMPONENTS
mpi_cmake_modules
pybind11_catkin
)
search_for_eigen()
set(BOOST_COMPONENTS filesystem)
search_for_boost()
search_for_pthread()
set(LIBRARY_NAME ${PROJECT_NAME})
catkin_package(
LIBRARIES ${LIBRARY_NAME}
INCLUDE_DIRS include
CATKIN_DEPENDS mpi_cmake_modules
DEPENDS Boost
)
# This macro sets the C++ preprocessor flags "XENOMAI", "RT_PREEMPT", or
# "UBUNTU" according to the current operating system.
DEFINE_OS()
include_directories(include ${catkin_INCLUDE_DIRS})
add_library(${LIBRARY_NAME}
src/realtime_check.cpp
src/thread.cpp
src/spinner.cpp
src/hard_spinner.cpp
src/timer.cpp
src/iostream.cpp
src/usb_stream.cpp
src/process_manager.cpp
src/frequency_manager.cpp
)
target_link_libraries(${LIBRARY_NAME}
${CMAKE_THREAD_LIBS_INIT}
${Boost_LIBRARIES}
${Xenomai_LIBS}
)
#########
# DEMOS #
#########
macro(add_real_time_tools_demo source_file)
add_executable(${source_file} demos/${source_file}.cpp)
target_link_libraries(${source_file} ${LIBRARY_NAME})
endmacro(add_real_time_tools_demo source_file)
add_real_time_tools_demo(demo_realtime_check)
add_real_time_tools_demo(demo_realtime_strict_check)
add_real_time_tools_demo(demo_spinner)
add_real_time_tools_demo(demo_timing)
add_real_time_tools_demo(demo_thread)
# add_real_time_tools_demo(demo_segfault)
add_real_time_tools_demo(demo_usb_stream_imu_3DM_GX3_25)
add_real_time_tools_demo(demo_checkpoint_timer)
###############
# EXECUTABLES #
###############
#set(EXE1 realtime_test)
#add_executable(${EXE1} src/bin/realtime_test.cpp)
#target_link_libraries(${EXE1} ${LIBRARY_NAME} ${catkin_LIBRARIES})
#set(EXE2 realtime_test_display)
#add_executable(${EXE2} src/bin/realtime_test_display.cpp)
#target_link_libraries(${EXE2} ${LIBRARY_NAME} ${catkin_LIBRARIES})
##################
# Python wrapper #
##################
pybind11_add_module(real_time_tools_py srcpy/wrappers.cpp)
target_link_libraries(real_time_tools_py PRIVATE real_time_tools ${catkin_LIBRARIES})
set_target_properties(real_time_tools_py PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CATKIN_DEVEL_PREFIX}/${CATKIN_GLOBAL_PYTHON_DESTINATION}
OUTPUT_NAME real_time_tools)
install(TARGETS real_time_tools_py DESTINATION ${CATKIN_GLOBAL_PYTHON_DESTINATION})
###################################################
## Set a general config folder path for all tests #
###################################################
set(TEST_CONFIG_PATH ${PROJECT_SOURCE_DIR}/tests/config/)
###################
## add unit tests #
###################
# create the executable
catkin_add_gtest(test_real_time_tools
tests/main.cpp
tests/test_real_time_tools.cpp
tests/threadsafe_object_test.cpp
tests/threadsafe_timeseries_test.cpp
)
# link the dependecies to it
if (TARGET test_real_time_tools)
target_link_libraries(test_real_time_tools
${LIBRARY_NAME}
${catkin_LIBRARIES}
${Boost_LIBRARIES}
)
# add some preprocessor variable
target_compile_definitions(test_real_time_tools PUBLIC
TEST_CONFIG_FOLDER="${TEST_CONFIG_PATH}"
)
endif()
catkin_install_python(PROGRAMS
src/bin/compute_statistics
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
##########################
# building documentation #
##########################
build_doxygen_documentation()