-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
160 lines (137 loc) · 5.9 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
cmake_minimum_required(VERSION 3.5)
project(ompl VERSION 1.5.2 LANGUAGES CXX)
set(OMPL_ABI_VERSION 16)
# set the default build type
if (NOT CMAKE_BUILD_TYPE)
# By default, use Release mode
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Type of build" FORCE)
# On 32bit architectures, use RelWithDebInfo
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Type of build" FORCE)
endif()
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
set(CMAKE_MODULE_PATH
"${CMAKE_MODULE_PATH}"
"${CMAKE_ROOT_DIR}/cmake/Modules"
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
include(GNUInstallDirs)
include(FeatureSummary)
include(CompilerSettings)
include(OMPLUtils)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set(OMPL_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src;${CMAKE_CURRENT_BINARY_DIR}/src")
set(OMPL_DEMO_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}/ompl/demos"
CACHE STRING "Relative path to directory where demos will be installed")
include_directories("${OMPL_INCLUDE_DIRS}")
if(MSVC)
add_definitions(-DBOOST_ALL_NO_LIB)
add_definitions(-DBOOST_PROGRAM_OPTIONS_DYN_LINK)
endif(MSVC)
# Ensure dynamic linking with boost unit_test_framework
add_definitions(-DBOOST_TEST_DYN_LINK)
# Avoid valgrind error due to overflow error, cf. https://github.com/ompl/ompl/issues/664
add_definitions(-DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS)
set_package_properties(Boost PROPERTIES
URL "https://www.boost.org"
PURPOSE "Used throughout OMPL for data serialization, graphs, etc.")
set(Boost_USE_MULTITHREADED ON)
set(Boost_NO_BOOST_CMAKE ON)
find_package(Boost 1.58 QUIET REQUIRED COMPONENTS serialization filesystem system program_options)
include_directories(SYSTEM ${Boost_INCLUDE_DIR})
# on macOS we need to check whether to use libc++ or libstdc++ with clang++
if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
include(GetPrerequisites)
get_prerequisites("${Boost_SYSTEM_LIBRARY}" _libs 0 0 "/" "")
set(CXXSTDLIB "")
foreach(_lib ${_libs})
if(_lib MATCHES "libc\\+\\+")
set(CXXSTDLIB "libc++")
elseif(_lib MATCHES "libstdc\\+\\+")
set(CXXSTDLIB "libstdc++")
endif()
endforeach()
if(CXXSTDLIB)
add_definitions(-stdlib=${CXXSTDLIB})
endif()
endif()
set_package_properties(Threads PROPERTIES
URL "https://en.wikipedia.org/wiki/POSIX_Threads"
PURPOSE "Pthreads is sometimes needed, depending on OS / compiler.")
find_package(Threads QUIET)
set_package_properties(Eigen3 PROPERTIES
URL "http://eigen.tuxfamily.org"
PURPOSE "A linear algebra library used throughout OMPL.")
find_package(Eigen3 REQUIRED)
include_directories("${EIGEN3_INCLUDE_DIR}")
set_package_properties(Triangle PROPERTIES
URL "http://www.cs.cmu.edu/~quake/triangle.html"
PURPOSE "Used to create triangular decompositions of polygonal 2D environments.")
find_package(Triangle QUIET)
set(OMPL_EXTENSION_TRIANGLE ${TRIANGLE_FOUND})
if (OMPL_EXTENSION_TRIANGLE)
include_directories(${TRIANGLE_INCLUDE_DIR})
endif()
set_package_properties(flann PROPERTIES
URL "https://github.com/mariusmuja/flann"
PURPOSE "If detetected, FLANN can be used for nearest neighbor queries by OMPL.")
find_package(flann 1.8.3 QUIET)
if (FLANN_FOUND)
set(OMPL_HAVE_FLANN 1)
include_directories("${FLANN_INCLUDE_DIRS}")
link_directories(${FLANN_LIBRARY_DIRS})
endif()
set_package_properties(Doxygen PROPERTIES
URL "http://doxygen.org"
PURPOSE "Used to create the OMPL documentation (i.e., https://ompl.kavrakilab.org).")
find_package(Doxygen)
add_subdirectory(src)
add_subdirectory(demos)
add_subdirectory(doc)
if(NOT MSVC)
target_link_flags(ompl)
set(PKG_NAME "ompl")
set(PKG_DESC "The Open Motion Planning Library")
set(PKG_EXTERNAL_DEPS "eigen3 ${ompl_PKG_DEPS}")
set(PKG_OMPL_LIBS "-lompl ${ompl_LINK_FLAGS}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/ompl.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/ompl.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ompl.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
COMPONENT ompl)
endif()
include(CMakePackageConfigHelpers)
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR})
configure_package_config_file(omplConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/omplConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ompl/cmake
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR
NO_CHECK_REQUIRED_COMPONENTS_MACRO)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/omplConfigVersion.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/omplConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/omplConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/ompl/cmake
COMPONENT ompl)
# uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/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")
include(CPackSettings)
# install catkin package.xml (needed for ROS installation)
install(FILES package.xml
DESTINATION share/${PROJECT_NAME})
# Allows Colcon to find non-Ament packages when using workspace underlays
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME} "")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/share/ament_index/resource_index/packages/${PROJECT_NAME} DESTINATION share/ament_index/resource_index/packages)
set_package_properties(PkgConfig PROPERTIES
URL "https://www.freedesktop.org/wiki/Software/pkg-config/"
PURPOSE "Used to find (compilation flags for) dependencies.")
feature_summary(DESCRIPTION INCLUDE_QUIET_PACKAGES WHAT ALL)