-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
153 lines (136 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
cmake_minimum_required(VERSION 3.5.1)
project(PnC)
##=============================================================================
## CMake Flags
##=============================================================================
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()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS on)
set(CXX_DISABLE_WERROR True)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
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})
set(PYTHON_BINDING TRUE)
##=============================================================================
## Include Directory
##=============================================================================
include_directories("${PROJECT_SOURCE_DIR}")
include_directories("${PROJECT_SOURCE_DIR}/build")
include_directories("/usr/local/include")
link_directories("/usr/local/lib")
##=============================================================================
## Dependancy
##=============================================================================
# dart
find_package(DART 6.10 REQUIRED COMPONENTS utils-urdf gui-osg CONFIG)
include_directories(${DART_INCLUDE_DIRS})
# eigen
if(NOT EIGEN_FOUND)
find_package(Eigen 3.3 REQUIRED)
endif()
include_directories(${EIGEN_INCLUDE_DIRS})
# doxygen
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(DOXYGEN_DOXYFILE_IN "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in" )
set(DOXYGEN_DOXYFILE "${PROJECT_BINARY_DIR}/doxygen/Doxyfile" )
set(DOXYGEN_HTML_INDEX "${PROJECT_BINARY_DIR}/doxygen/html/index.html")
set(DOXYGEN_OUTPUT_ROOT "${PROJECT_BINARY_DIR}/doxygen/html" )
set(DOXYGEN_GENERATE_TAGFILE "${DOXYGEN_OUTPUT_ROOT}/${PROJECT_NAME}.tag" )
set(DOXYGEN_INCLUDE_PATH "${PROJECT_SOURCE_DIR}" )
set(DOXYGEN_INPUT_ROOT "${PROJECT_SOURCE_DIR}/pnc" )
set(DOXYGEN_EXTRA_INPUTS "${PROJECT_SOURCE_DIR}/doxygen/mainpage.dox" )
set(DOXYGEN_EXCLUDE "${PROJECT_SOURCE_DIR}/pnc/draco_pnc \
${PROJECT_SOURCE_DIR}/pnc/atlas_pnc" )
set(DOXYGEN_STRIP_FROM_PATH "${CMAKE_CURRENT_SOURCE_DIR}" )
# Generate a Doxyfile. This uses the variables:
#
# - DOXYGEN_OUTPUT_ROOT
# - DOXYGEN_GENERATE_TAGFILE
# - DOXYGEN_EXTRA_INPUTS
# - DOXYGEN_INPUT_ROOT
# - DOXYGEN_EXCLUDE
# - DOXYGEN_STRIP_FROM_PATH
configure_file(${DOXYGEN_DOXYFILE_IN} ${DOXYGEN_DOXYFILE} @ONLY)
add_custom_command(
OUTPUT ${DOXYGEN_HTML_INDEX}
COMMAND ${CMAKE_COMMAND} -E echo_append "Building API Documentation..."
COMMAND ${DOXYGEN_EXECUTABLE} -u ${DOXYGEN_DOXYFILE}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_DOXYFILE}
# Strip path prefix from all paths in dart.tag
COMMAND ${CMAKE_COMMAND} -E echo "Stripping paths from"
"${DOXYGEN_GENERATE_TAGFILE}"
COMMAND sed -i s:${DOXYGEN_STRIP_FROM_PATH}::g ${DOXYGEN_GENERATE_TAGFILE}
# Strip all doxygen="path" HTML tags
COMMAND ${CMAKE_COMMAND} -E echo "Stripping Doxygen HTML tags"
COMMAND find "${DOXYGEN_OUTPUT_ROOT}" -type f -name "*.html"
-exec sed -i 's: doxygen=\"[^\"]*\"::g' {} \\$<SEMICOLON>
COMMAND ${CMAKE_COMMAND} -E echo "Done."
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/doxygen
DEPENDS ${DOXYGEN_DOXYFILE}
)
# add_custom_target(docs ALL DEPENDS ${DOXYGEN_HTML_INDEX})
add_custom_target(docs DEPENDS ${DOXYGEN_HTML_INDEX})
add_custom_target(
docs_forced
COMMAND ${CMAKE_COMMAND} -E echo_append "Building API Documentation..."
COMMAND ${DOXYGEN_EXECUTABLE} -u ${DOXYGEN_DOXYFILE}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_DOXYFILE}
COMMAND ${CMAKE_COMMAND} -E echo "Done."
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/doxygen
)
# Add the "view_docs" target that opens the generated API documentation.
if(APPLE)
set(OPEN_COMMAND "open")
else()
set(OPEN_COMMAND "xdg-open")
endif()
add_custom_target(view_docs "${OPEN_COMMAND}" "${DOXYGEN_HTML_INDEX}"
DEPENDS "${DOXYGEN_HTML_INDEX}"
COMMENT "Opening documentation in a web browser.")
endif()
# zmq and protobuf
set(B_MESSAGING false)
find_package(ZMQ)
find_package(Protobuf)
if(ZMQ_FOUND AND Protobuf_FOUND)
include_directories(${ZMQ_INCLUDE_DIRS})
include_directories(${Protobuf_INCLUDE_DIRS})
add_subdirectory(messages)
set(B_MESSAGING true)
endif()
# pybind11
if(PYTHON_BINDING)
# control pc requires this snippet for some reason..
set(pybind11_DIR "/home/apptronik/.local/lib/python3.6/site-packages/pybind11/share/cmake/pybind11")
find_package(Python COMPONENTS Interpreter Development)
find_package(pybind11 CONFIG REQUIRED)
include_directories(${pybind11_INCLUDE_DIRS})
add_subdirectory(bindings)
endif()
##=============================================================================
## Add Subdirectory
##=============================================================================
add_subdirectory(simulator)
add_subdirectory(utils)
add_subdirectory(third_party)
add_subdirectory(pnc)
add_subdirectory(test)
##=============================================================================
## Configuration File
##=============================================================================
set(THIS_COM "${PROJECT_SOURCE_DIR}/" )
set(SERVO_RATE 0.001)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/config.h.cmake
${PROJECT_SOURCE_DIR}/configuration.hpp)
install(FILES ${PROJECT_SOURCE_DIR}/configuration.hpp DESTINATION "${INSTALL_INCLUDE_DIR}")