forked from RossHartley/invariant-ekf
-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
163 lines (146 loc) · 3.87 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
cmake_minimum_required(VERSION 2.8.3)
project(legged_state_estimator)
if (NOT "${CMAKE_CXX_STANDARD}")
set(CMAKE_CXX_STANDARD 11)
else()
if ("${CMAKE_CXX_STANDARD}" LESS 11)
set(CMAKE_CXX_STANDARD 11)
endif()
endif()
################
## Build type ##
################
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
if(NOT CMAKE_BUILD_TYPE MATCHES Release)
message(STATUS "WARNING: CMAKE_BUILD_TYPE is NOT set to Release, which can decrease performance significantly.")
endif()
#############
## Options ##
#############
option(OPTIMIZE_FOR_NATIVE "Enable -march=native" ON)
option(BUILD_PYTHON_INTERFACE "Build Python bindings" ON)
option(BUILD_EXAMPLES "Build examples and tests" ON)
###########
## Build ##
###########
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
find_package(Eigen3 REQUIRED)
find_package(pinocchio REQUIRED)
file(GLOB_RECURSE ${PROJECT_NAME}_SOURCES src/*.cpp)
file(GLOB_RECURSE ${PROJECT_NAME}_HEADERS include/${PROJECT_NAME}/*.h*)
add_library(
${PROJECT_NAME}
SHARED
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS}
)
target_link_libraries(
${PROJECT_NAME}
PUBLIC
${PINOCCHIO_LIBRARIES}
)
target_include_directories(
${PROJECT_NAME}
PUBLIC
${EIGEN3_INCLUDE_DIR}
${PINOCCHIO_INCLUDE_DIRS}
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
if (OPTIMIZE_FOR_NATIVE)
target_compile_options(
${PROJECT_NAME}
PUBLIC
-march=native
)
endif()
##############
## Bindings ##
##############
if (BUILD_PYTHON_INTERFACE)
add_subdirectory(bindings/python)
endif()
######################
# Add Execuatables #
######################
find_package(Threads)
find_package(Boost REQUIRED COMPONENTS system)
macro(legged_state_estimator_add_test EXACUTABLE)
add_executable(
${EXACUTABLE}
${PROJECT_SOURCE_DIR}/tests/${EXACUTABLE}.cpp
)
target_link_libraries(
${EXACUTABLE}
PRIVATE
${PROJECT_NAME}
${Boost_LIBRARIES}
)
target_include_directories(
${EXACUTABLE}
PRIVATE
${PROJECT_SOURCE_DIR}/include
${Boost_INCLUDE_DIRS}
)
endmacro()
if (BUILD_EXAMPLES)
legged_state_estimator_add_test(propagation_speed)
legged_state_estimator_add_test(correction_speed)
legged_state_estimator_add_test(large_state_speed)
legged_state_estimator_add_test(left_vs_right_error_dynamics)
legged_state_estimator_add_test(legged_state_estimation)
endif()
macro(legged_state_estimator_add_example EXACUTABLE)
add_executable(
${EXACUTABLE}
${PROJECT_SOURCE_DIR}/examples/${EXACUTABLE}.cpp
)
target_link_libraries(
${EXACUTABLE}
PRIVATE
${PROJECT_NAME}
${Boost_LIBRARIES}
)
target_include_directories(
${EXACUTABLE}
PRIVATE
${PROJECT_SOURCE_DIR}/include
${Boost_INCLUDE_DIRS}
)
endmacro()
if (BUILD_EXAMPLES)
legged_state_estimator_add_example(landmarks)
legged_state_estimator_add_example(kinematics)
endif()
#############
## Install ##
#############
include(GNUInstallDirs)
# Install lib files
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-config
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}
)
# Install header files
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
)
# Install config file
set(CONFIG_PACKAGE_LOCATION "share/${PROJECT_NAME}/cmake")
install(
EXPORT ${PROJECT_NAME}-config
FILE ${PROJECT_NAME}-config.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
# Install alias
add_library(
${PROJECT_NAME}::${PROJECT_NAME}
ALIAS ${PROJECT_NAME}
)