-
Notifications
You must be signed in to change notification settings - Fork 165
/
CMakeLists.txt
189 lines (148 loc) · 5.97 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
cmake_minimum_required(VERSION 3.15)
set(RUCKIG_VERSION 0.14.0)
project(ruckig VERSION ${RUCKIG_VERSION} LANGUAGES CXX)
include(GNUInstallDirs)
option(BUILD_EXAMPLES "Build example programs" ON)
option(BUILD_PYTHON_MODULE "Build python module with pybind11" OFF)
option(BUILD_CLOUD_CLIENT "Build cloud client to calculate Ruckig Pro trajectories remotely" ON)
option(BUILD_TESTS "Build tests" ON)
option(BUILD_BENCHMARK "Build benchmark" OFF)
option(BUILD_SHARED_LIBS "Build as shared library" ON)
if(WIN32 AND BUILD_SHARED_LIBS)
option(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "On Windows, export all symbols when building a shared library." ON)
endif()
add_library(ruckig
src/ruckig/brake.cpp
src/ruckig/position_first_step1.cpp
src/ruckig/position_first_step2.cpp
src/ruckig/position_second_step1.cpp
src/ruckig/position_second_step2.cpp
src/ruckig/position_third_step1.cpp
src/ruckig/position_third_step2.cpp
src/ruckig/velocity_second_step1.cpp
src/ruckig/velocity_second_step2.cpp
src/ruckig/velocity_third_step1.cpp
src/ruckig/velocity_third_step2.cpp
)
target_compile_features(ruckig PUBLIC cxx_std_17)
target_include_directories(ruckig PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(ruckig PUBLIC)
if(MSVC)
target_compile_definitions(ruckig PUBLIC _USE_MATH_DEFINES)
endif()
if(BUILD_CLOUD_CLIENT)
target_sources(ruckig PRIVATE src/ruckig/cloud_client.cpp)
target_include_directories(ruckig PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/third_party>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_compile_definitions(ruckig PUBLIC WITH_CLOUD_CLIENT)
endif()
add_library(ruckig::ruckig ALIAS ruckig)
if(BUILD_TESTS)
enable_testing()
add_library(test-dependencies INTERFACE)
target_link_libraries(test-dependencies INTERFACE ruckig)
target_include_directories(test-dependencies INTERFACE third_party)
if(MSVC)
target_compile_options(test-dependencies INTERFACE /W4)
else()
target_compile_options(test-dependencies INTERFACE -Wall -Wextra)
endif()
add_executable(test-target test/test_target.cpp)
target_link_libraries(test-target PRIVATE test-dependencies)
add_test(NAME test-target COMMAND test-target)
if(NOT MSVC)
include(CTest)
find_program(MEMORYCHECK_COMMAND valgrind)
set(MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --leak-check=full --trace-children=yes \
--track-origins=yes --keep-debuginfo=yes --error-exitcode=100")
endif()
endif()
if(BUILD_BENCHMARK)
add_executable(benchmark-target test/benchmark_target.cpp)
target_link_libraries(benchmark-target PRIVATE ruckig)
endif()
if(BUILD_EXAMPLES)
set(EXAMPLES_LIST 01_position 02_position_offline 05_velocity 06_stop 07_minimum_duration 09_dynamic_dofs 12_custom_vector_type 13_custom_vector_type_dynamic_dofs)
if(TARGET Eigen3::Eigen)
list(APPEND EXAMPLES_LIST 11_eigen_vector_type)
endif()
if(BUILD_CLOUD_CLIENT)
list(APPEND EXAMPLES_LIST 03_waypoints 04_waypoints_online 08_per_section_minimum_duration 10_dynamic_dofs_waypoints)
endif()
foreach(example IN LISTS EXAMPLES_LIST)
add_executable(example-${example} examples/${example}.cpp)
target_link_libraries(example-${example} PRIVATE ruckig)
endforeach()
endif()
if(BUILD_PYTHON_MODULE)
# check if pybind11 is already available
if(NOT TARGET pybind11::module)
# Check if pybind11 exists as a subdirectory
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/pybind11)
add_subdirectory(pybind11)
else()
find_package(pybind11 2.6 REQUIRED)
endif()
endif()
pybind11_add_module(python_ruckig src/ruckig/python.cpp)
target_compile_features(python_ruckig PUBLIC cxx_std_17)
target_link_libraries(python_ruckig PUBLIC ruckig)
if(BUILD_CLOUD_CLIENT)
target_compile_definitions(python_ruckig PUBLIC WITH_CLOUD_CLIENT)
endif()
set_target_properties(python_ruckig PROPERTIES OUTPUT_NAME ruckig)
set_target_properties(python_ruckig PROPERTIES ARCHIVE_OUTPUT_NAME python_ruckig)
install(TARGETS python_ruckig LIBRARY DESTINATION .)
endif()
# Add support for installation
include(CMakePackageConfigHelpers)
# Install headers
install(DIRECTORY include/ruckig DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Install library
install(TARGETS ruckig
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
# Install CMake config files
set(ruckig_INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
install(EXPORT ${PROJECT_NAME}-targets
DESTINATION ${ruckig_INSTALL_CONFIGDIR}
NAMESPACE ruckig::
)
configure_package_config_file(cmake/ruckig-config.cmake.in ruckig-config.cmake
INSTALL_DESTINATION ${ruckig_INSTALL_CONFIGDIR}
)
write_basic_package_version_file(ruckig-config-version.cmake
VERSION ${ruckig_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/ruckig-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/ruckig-config-version.cmake"
DESTINATION ${ruckig_INSTALL_CONFIGDIR}
)
install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/package.xml"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}
)
# Enable Packaging
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_CONTACT "Lars Berscheid ([email protected])")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Motion Generation for Robots and Machines.")
set(CPACK_PACKAGE_VENDOR "Lars Berscheid")
set(CPACK_PACKAGE_VERSION ${RUCKIG_VERSION})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_SYSTEM_NAME ${CMAKE_HOST_SYSTEM_PROCESSOR})
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://ruckig.com")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Lars Berscheid")
set(CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}-1)
set(CPACK_DEBIAN_PACKAGE_CONFLICTS "ros-melodic-ruckig, ros-noetic-ruckig, ros-foxy-ruckig, ros-galactic-ruckig, ros-humble-ruckig, ros-rolling-ruckig")
include(CPack)