-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
158 lines (125 loc) · 5.79 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
##############################################################################
# Project
##############################################################################
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(delphyne LANGUAGES C CXX VERSION 3.0.0)
##############################################################################
# CMake Support
##############################################################################
# Useful string/list macros
include (${PROJECT_SOURCE_DIR}/cmake/Utils.cmake)
# Set CMAKE_INSTALL_<INCLUDEDIR|BINDIR|LIBDIR>
include(GNUInstallDirs)
##############################################################################
# Find 3rd Party Packages
##############################################################################
message(STATUS "\n\n====== Finding 3rd Party Packages ======\n")
find_package(ament_cmake REQUIRED)
find_package(drake_vendor REQUIRED)
find_package(maliput REQUIRED)
find_package(maliput_py REQUIRED)
find_package(ignition-common3 REQUIRED COMPONENTS graphics)
find_package(ignition-math6 REQUIRED)
find_package(ignition-msgs5 REQUIRED)
find_package(ignition-transport8 REQUIRED COMPONENTS log)
pkg_check_modules(LIBZIP REQUIRED libzip)
# Delphyne relies on drake_vendor for bringing Drake to the workspace.
# Drake brings its own version of pybind11 (https://github.com/RobotLocomotion/pybind11) and it is installed under /opt/drake.
# As some features from this custom pybind11 are used, delphyne depends on the same version of pybind11 as Drake.
# Therefore, we rely directly on the version installed by Drake, to avoid having to install it from source.
#
# Note: As drake_vendor adds /opt/drake to the path, the immediate pybind11 version (2.6.dev0) that is obtained
# via a regular find_package expression is the one brougth by Drake.
# Note2: The ideal would be to use `find_package(pybind11 2.6.dev0 EXACT REQUIRED)` however the patch version can only be numerical.
find_package(pybind11 REQUIRED)
# Since ignition libraries are compiled using C++17 and drake is not,
# we need to define the following macro
# to avoid having undefined references from drake when we use std::variant.
# See https://drake.mit.edu/doxygen_cxx/drake__optional_8h.html
add_definitions(-DSTX_NO_STD_VARIANT)
##############################################################################
# Project Configuration
##############################################################################
message(STATUS "\n\n========= Project Configuration ========\n")
set(BUILD_SHARED_LIBS true)
# Ugh, makefile generators don't set any configuration (build) types. Use GNU's
set(DELPHYNE_CONFIGURATION_TYPES
${CMAKE_CONFIGURATION_TYPES} Debug MinSizeRel Release RelWithDebInfo)
list(REMOVE_DUPLICATES DELPHYNE_CONFIGURATION_TYPES)
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
${DELPHYNE_CONFIGURATION_TYPES})
endif()
if(NOT ${CMAKE_BUILD_TYPE} IN_LIST DELPHYNE_CONFIGURATION_TYPES)
message(
FATAL_ERROR
"Build type '${CMAKE_BUILD_TYPE}' unknown. "
"Valid options are: ${DELPHYNE_CONFIGURATION_TYPES}.")
endif()
# TODO: still convert to uppercase to keep backwards compatibility with
# uppercase old supported and deprecated modes
string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPERCASE)
include(${PROJECT_SOURCE_DIR}/cmake/DefaultCFlags.cmake)
include(${PROJECT_SOURCE_DIR}/cmake/SanitizersConfig.cmake)
# Report out
message(STATUS "Shared Libraries..............${BUILD_SHARED_LIBS}")
message(STATUS "Build Type....................${CMAKE_BUILD_TYPE}")
message(STATUS "Install path..................${CMAKE_INSTALL_PREFIX}")
if (DEFINED CMAKE_CXX_FLAGS)
message(STATUS "Custom CFlags.................${CMAKE_CXX_FLAGS}")
else()
message (STATUS "Using default CFlags")
endif()
message(STATUS "\n----------------------------------------\n")
##############################################################################
# Sources
##############################################################################
add_subdirectory(src)
add_subdirectory(python)
add_subdirectory(media)
##############################################################################
# Tests
##############################################################################
if(BUILD_TESTING)
find_package(ament_cmake_clang_format REQUIRED)
find_package(ament_cmake_flake8 REQUIRED)
enable_testing()
add_subdirectory(test)
ament_flake8("--config" ${CMAKE_CURRENT_SOURCE_DIR}/.flake8)
ament_clang_format(CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/.clang-format)
endif()
##############################################################################
# Docs
##############################################################################
if(BUILD_DOCS)
message(STATUS "Doxygen generation - Enabled")
find_package(ament_cmake_doxygen REQUIRED)
ament_doxygen_generate(doxygen_delphyne
CONFIG_OVERLAY doc/Doxyfile.overlay.in
DEPENDENCIES maliput maliput_py
)
add_definitions(-DBUILD_DOCS)
else()
message(STATUS "Doxygen generation - Disabled")
endif()
##############################################################################
# Export
##############################################################################
configure_file(include/delphyne/version.h.in
${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}/version.h
)
install(
DIRECTORY include/
DESTINATION include
)
ament_export_include_directories(include)
ament_environment_hooks(setup.sh.in)
ament_export_dependencies(ament_cmake)
ament_export_dependencies(drake_vendor)
ament_export_dependencies(maliput)
ament_export_targets(${PROJECT_NAME}-targets HAS_LIBRARY_TARGET)
ament_package()