forked from shbang91/rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
175 lines (144 loc) · 4.85 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
cmake_minimum_required(VERSION 3.10)
project(rpc)
##==================================================
## CMake Flags
##==================================================
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS on)
add_compile_options(-fPIC)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/build/Release/generators/")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
##==================================================
## Build Setup
##==================================================
set(INSTALL_LIB_DIR ${CMAKE_INSTALL_PREFIX}/lib)
set(INSTALL_BIN_DIR ${CMAKE_INSTALL_PREFIX}/bin)
set(INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})
option(PYTHON_BINDING "use pybind11" ON)
option(BUILD_WITH_PINOCCHIO "compile with PINOCCHIO" ON)
option(BUILD_WITH_MUJOCO "compile with mujoco" ON)
option(BUILD_WITH_DART "compile with DART" OFF)
option(BUILD_WITH_PROXQP "compile with ProxQP" OFF)
option(BUILD_WITH_MATLOGGER "compile with MatLogger2" OFF)
option(BUILD_WITH_ZMQ_PROTOBUF "compile with zmq and protobuf" OFF)
option(BUILD_WITH_FOXGLOVE "compile with foxglove" OFF)
option(BUILD_WITH_TELEOP "compile with teleop" OFF)
option(BUILD_WITH_HPIPM "compile with HPIPM" OFF)
# unit-testing tools
option(BUILD_WITH_GTESTS "build google tests" OFF)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: Debug | Release | RelWithDebInfo | MinSizeRel" FORCE)
endif()
##==================================================
## Include Directory
##==================================================
include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/build")
##==================================================
## Dependency
##==================================================
#ProxQP
if(BUILD_WITH_PROXQP)
find_package(proxsuite REQUIRED)
endif()
#pybind11
if(PYTHON_BINDING)
find_package(pybind11 REQUIRED)
include_directories(${pybind11_INCLUDE_DIRS})
add_subdirectory(binding)
endif()
#Pinocchio
if(BUILD_WITH_PINOCCHIO)
find_package(pinocchio)
include_directories(${pinocchio_INCLUDE_DIRS})
endif()
#Mujoco
if(BUILD_WITH_MUJOCO)
find_package(Threads REQUIRED)
find_package(glfw3 REQUIRED)
find_library(mujoco_LIBRARIES mujoco HINTS ${CMAKE_SOURCE_DIR}/mujoco/lib)
include_directories(${glfw3_INCLUDE_DIRS})
include_directories(mujoco/include)
endif()
#DART
if(BUILD_WITH_DART)
find_package(DART 6.10 REQUIRED COMPONENTS utils-urdf gui-osg CONFIG)
include_directories(${DART_INCLUDE_DIRS})
endif()
#Eigen
find_package(Eigen 3.3 REQUIRED)
include_directories(${EIGEN_INCLUDE_DIRS})
#MatLogger2
if(BUILD_WITH_MATLOGGER)
find_package(matlogger2 REQUIRED)
set(B_USE_MATLOGGER true)
else()
set(B_USE_MATLOGGER false)
endif()
#Protobuf & ZMQ
if (BUILD_WITH_ZMQ_PROTOBUF OR BUILD_WITH_TELEOP)
find_package(ZMQ REQUIRED)
find_package(Protobuf REQUIRED)
if(Protobuf_FOUND AND ZMQ_FOUND)
include_directories(${Protobuf_INCLUDE_DIRS})
include_directories(${ZMQ_INCLUDE_DIRS})
add_subdirectory(messages)
endif()
set(B_USE_ZMQ true)
else()
set(B_USE_ZMQ false)
endif()
#Teleop
if (BUILD_WITH_TELEOP)
set(B_USE_TELEOP true)
else()
set(B_USE_TELEOP false)
endif()
#hpipm-cpp
if (BUILD_WITH_HPIPM)
find_package(hpipm-cpp REQUIRED)
set(B_USE_HPIPM true)
else()
set(B_USE_HPIPM false)
endif()
#Boost
#find_package(Boost QUIET REQUIRED COMPONENTS system thread filesystem)
#include_directories(${Boost_INCLUDE_DIRS})
# Foxglove for UI
if(BUILD_WITH_FOXGLOVE)
find_package(foxglove-schemas-protobuf REQUIRED)
find_package(foxglove-websocket REQUIRED)
find_package(Boost COMPONENTS program_options REQUIRED)
# warning message if trying to build with foxglove but without zmq/protobuf
if (NOT BUILD_WITH_ZMQ_PROTOBUF)
message("\n*** WARNING ***\nPLEASE ENABLE ZMQ/PROTOBUF -- needed dependencies\n")
endif ()
set(B_USE_FOXGLOVE true)
else()
set(B_USE_FOXGLOVE false)
endif()
##==================================================
## Subdirectories
##==================================================
add_subdirectory(controller)
add_subdirectory(planner)
add_subdirectory(util)
add_subdirectory(third_party)
add_subdirectory(UI)
if(BUILD_WITH_GTESTS)
add_subdirectory(test)
endif()
if(BUILD_WITH_MUJOCO)
add_subdirectory(mujoco)
add_subdirectory(simulator)
endif()
##==================================================
## Configuration File
##==================================================
set(THIS_COM "${PROJECT_SOURCE_DIR}/")
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/config.h.cmake
${PROJECT_SOURCE_DIR}/configuration.hpp)
install(FILES ${PROJECT_SOURCE_DIR}/configuration.hpp DESTINATION
"${INSTALL_INCLUDE_DIR}")