-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
175 lines (145 loc) · 4.89 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
# Copyright (c) 2012-2018 CNRS
# Author: Olivier Roussel
#
# This file is part of the qserl package.
# qserl is free software: you can redistribute it
# and/or modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
#
# qserl is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty
# of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Lesser Public License for more details. You should have
# received a copy of the GNU Lesser General Public License along with
# qserl. If not, see
# <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.5)
include(cmake/base.cmake)
include(cmake/eigen.cmake)
project(libqserl VERSION 1.1.0 LANGUAGES CXX)
if(NOT ${CMAKE_VERSION} VERSION_GREATER 3.8)
set(CMAKE_CXX_STANDARD 11)
endif()
# Use cmake/ dir for user modules
list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake)
# Option for building shared lib
option(QSERL_BUILD_SHARED "Build shared libraries" ON)
# Option for building tests
option(QSERL_BUILD_TEST "Build tests" OFF)
#------------------------------------------------------------------------------
# Dependencies
#------------------------------------------------------------------------------
find_package(Boost 1.55 REQUIRED MODULE COMPONENTS python)
SEARCH_FOR_EIGEN("eigen3 >= 3.2")
ADD_OPTIONAL_DEPENDENCY("eigenpy")
#------------------------------------------------------------------------------
# Setting up target
#------------------------------------------------------------------------------
set(qserl_SOURCES
src/rod2d/analytic_dqda.cc
src/rod2d/analytic_energy.cc
src/rod2d/analytic_mu.cc
src/rod2d/analytic_q.cc
src/rod2d/costate_system.cc
src/rod2d/inverse_geometry.cc
src/rod2d/jacobian_system.cc
src/rod2d/rod.cc
src/rod2d/state_system.cc
src/rod2d/workspace_integrated_state.cc
src/rod2d/workspace_state.cc
src/rod3d/parameters.cc
src/rod3d/rod.cc
src/rod3d/ik.cc
src/rod3d/full_system.cc
src/rod3d/workspace_integrated_state.cc
src/rod3d/workspace_state.cc
src/util/lie_algebra_utils.cc
src/util/timer.cc
src/util/utils.cc
)
if(QSERL_BUILD_SHARED)
add_definitions(-DQSERL_DLL_EXPORTS)
add_definitions(-DQSERL_USE_SHARED)
add_library(qserl SHARED
${qserl_SOURCES})
else()
add_library(qserl STATIC
${qserl_SOURCES})
endif()
target_include_directories(qserl
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
if(${CMAKE_VERSION} VERSION_GREATER 3.8)
target_compile_features(qserl PRIVATE cxx_std_11)
endif()
target_compile_options(qserl PRIVATE -Wall -Wextra)
target_link_libraries(qserl
PUBLIC
Boost::boost
)
#------------------------------------------------------------------------------
# Installation rules
#------------------------------------------------------------------------------
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/Qserl)
install(TARGETS qserl
EXPORT qserl-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
set_target_properties(PROPERTIES EXPORT_NAME Qserl)
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
# Export the targets to a script
install(EXPORT qserl-targets
FILE
QserlTargets.cmake
DESTINATION
${INSTALL_CONFIGDIR}
)
# Create a ConfigVersion.cmake file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/QserlConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/install/QserlConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/QserlConfig.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)
# Install the config, configversion and custom find modules
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/QserlConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/QserlConfigVersion.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)
export(EXPORT qserl-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/QserlTargets.cmake)
# Register package in user's package registry
export(PACKAGE Qserl)
# Uninstall target
if(NOT TARGET uninstall)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)
endif()
#------------------------------------------------------------------------------
# Add subdirectories
#------------------------------------------------------------------------------
add_subdirectory(examples)
IF(EIGENPY_FOUND)
add_subdirectory(bindings)
ENDIF(EIGENPY_FOUND)
if(QSERL_BUILD_TEST)
add_subdirectory(test)
endif()
SETUP_PROJECT_FINALIZE()