From 3f1c68d18abd016ad150ea93f7f3e999145766c5 Mon Sep 17 00:00:00 2001 From: Samuel Martin Date: Thu, 13 Mar 2014 14:04:24 +0100 Subject: [PATCH] octomap: new package An efficient probabilistic 3D mapping framework based on octrees. Patching the build-system is required because the current upstream CMake modules installed hard-code the headers and libraries, which badly breaks the cross-compilation. Note that these patches are in the path to get merged upstream [1]. [1] https://github.com/OctoMap/octomap/pull/57 Signed-off-by: Samuel Martin --- package/Config.in | 1 + package/octomap/Config.in | 16 ++ ...tall-CMake-module-under-share-dynami.patch | 32 +++ ...EDT3D-rename-CMake-module-file-names.patch | 79 +++++++ ...Make-modules-with-no-hard-coded-path.patch | 209 ++++++++++++++++++ package/octomap/octomap.mk | 31 +++ 6 files changed, 368 insertions(+) create mode 100644 package/octomap/Config.in create mode 100644 package/octomap/octomap-0001-dynamicEDT3D-install-CMake-module-under-share-dynami.patch create mode 100644 package/octomap/octomap-0002-dynamicEDT3D-rename-CMake-module-file-names.patch create mode 100644 package/octomap/octomap-0003-cmake-offer-CMake-modules-with-no-hard-coded-path.patch create mode 100644 package/octomap/octomap.mk diff --git a/package/Config.in b/package/Config.in index c0a1c8bf2..a286e1432 100644 --- a/package/Config.in +++ b/package/Config.in @@ -707,6 +707,7 @@ menu "Maths and sciences" source "package/gsl/Config.in" source "package/mpc/Config.in" source "package/mpfr/Config.in" + source "package/octomap/Config.in" source "package/qhull/Config.in" endmenu diff --git a/package/octomap/Config.in b/package/octomap/Config.in new file mode 100644 index 000000000..7fbdb0278 --- /dev/null +++ b/package/octomap/Config.in @@ -0,0 +1,16 @@ +config BR2_PACKAGE_OCTOMAP + bool "octomap" + depends on BR2_INSTALL_LIBSTDCPP + help + The OctoMap library implements a 3D occupancy grid mapping + approach, providing data structures and mapping algorithms in + C++ particularly suited for robotics. + + http://octomap.github.io/ + +config BR2_PACKAGE_OCTOMAP_INSTALL_PROGRAMS + bool "Install octomap programs in the target" + depends on BR2_PACKAGE_OCTOMAP + +comment "octomap needs a toolchain w/ C++" + depends on !BR2_INSTALL_LIBSTDCPP diff --git a/package/octomap/octomap-0001-dynamicEDT3D-install-CMake-module-under-share-dynami.patch b/package/octomap/octomap-0001-dynamicEDT3D-install-CMake-module-under-share-dynami.patch new file mode 100644 index 000000000..034e2625b --- /dev/null +++ b/package/octomap/octomap-0001-dynamicEDT3D-install-CMake-module-under-share-dynami.patch @@ -0,0 +1,32 @@ +From 6e28f75e7dd4c9136060158f38c6c8d8ec1bca7d Mon Sep 17 00:00:00 2001 +From: Samuel Martin +Date: Mon, 5 May 2014 14:02:18 +0200 +Subject: [PATCH 1/3] dynamicEDT3D: install CMake module under + share/dynamicEDT3D/ + +dynamicEDT3D was the only subproject installing its CMake module files +under lib/cmake/. +This patch cleans this up, making dynamicEDT3D installation consistent with +the octomap and octovis ones. + +Signed-off-by: Samuel Martin +--- + dynamicEDT3D/CMakeLists.txt | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dynamicEDT3D/CMakeLists.txt b/dynamicEDT3D/CMakeLists.txt +index ac24b80..4e7d96a 100644 +--- a/dynamicEDT3D/CMakeLists.txt ++++ b/dynamicEDT3D/CMakeLists.txt +@@ -94,7 +94,7 @@ configure_file(dynamicEDT3DConfig-version.cmake.in + install(FILES + "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig.cmake" + "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig-version.cmake" +- DESTINATION lib/cmake/dynamicEDT3D/) ++ DESTINATION share/dynamicEDT3D/) + + # Write pkgconfig-file: + include(InstallPkgConfigFile) +-- +1.9.2 + diff --git a/package/octomap/octomap-0002-dynamicEDT3D-rename-CMake-module-file-names.patch b/package/octomap/octomap-0002-dynamicEDT3D-rename-CMake-module-file-names.patch new file mode 100644 index 000000000..925d502a0 --- /dev/null +++ b/package/octomap/octomap-0002-dynamicEDT3D-rename-CMake-module-file-names.patch @@ -0,0 +1,79 @@ +From 0a2f1b258032acf84938f2128788d80d90680167 Mon Sep 17 00:00:00 2001 +From: Samuel Martin +Date: Mon, 5 May 2014 14:19:04 +0200 +Subject: [PATCH 2/3] dynamicEDT3D: rename CMake module file names + +dynamicEDT3D was the only subproject naming its CMake module files +Config.cmake. +This patch cleans this up, using the -config.cmake pattern; +so make dynamicEDT3D consistent with what is done for octomap and octovis. + +Signed-off-by: Samuel Martin +--- + dynamicEDT3D/CMakeLists.txt | 22 +++++++++++----------- + ...ake.in => dynamicEDT3D-config-version.cmake.in} | 0 + ...onfig.cmake.in => dynamicEDT3D-config.cmake.in} | 0 + 3 files changed, 11 insertions(+), 11 deletions(-) + rename dynamicEDT3D/{dynamicEDT3DConfig-version.cmake.in => dynamicEDT3D-config-version.cmake.in} (100%) + rename dynamicEDT3D/{dynamicEDT3DConfig.cmake.in => dynamicEDT3D-config.cmake.in} (100%) + +diff --git a/dynamicEDT3D/CMakeLists.txt b/dynamicEDT3D/CMakeLists.txt +index 4e7d96a..f9e77cf 100644 +--- a/dynamicEDT3D/CMakeLists.txt ++++ b/dynamicEDT3D/CMakeLists.txt +@@ -67,33 +67,33 @@ install(FILES ${dynamicEDT3D_HDRS} DESTINATION include/dynamicEDT3D) + # (this registers the build-tree with a global CMake-registry) + export(PACKAGE dynamicEDT3D) + +-# Create a dynamicEDT3DConfig.cmake file for the use from the build tree ++# Create a dynamicEDT3D-config.cmake file for the use from the build tree + set(DYNAMICEDT3D_INCLUDE_DIRS "${INCLUDE_DIRS}") + set(DYNAMICEDT3D_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") + # not used right now (export depends?) + #set(DYNEDT3D_CMAKE_DIR "${PROJECT_BINARY_DIR}") +-configure_file(dynamicEDT3DConfig.cmake.in +- "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3DConfig.cmake" @ONLY) +-configure_file(dynamicEDT3DConfig-version.cmake.in +- "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3DConfig-version.cmake" @ONLY) ++configure_file(dynamicEDT3D-config.cmake.in ++ "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3D-config.cmake" @ONLY) ++configure_file(dynamicEDT3D-config-version.cmake.in ++ "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3D-config-version.cmake" @ONLY) + + # Install the export set for use with the install-tree + #install(EXPORT FooBarLibraryDepends DESTINATION + # "${INSTALL_DATA_DIR}/FooBar/CMake" + # COMPONENT dev) + +-# Create a dynamicEDT3DConfig.cmake file for the use from the install tree ++# Create a dynamicEDT3D-config.cmake file for the use from the install tree + # and install it + set(DYNAMICEDT3D_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include") + set(DYNAMICEDT3D_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") + #set(DYNAMICEDT3D_CMAKE_DIR "${INSTALL_DATA_DIR}/FooBar/CMake") +-configure_file(dynamicEDT3DConfig.cmake.in +- "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig.cmake" @ONLY) +-configure_file(dynamicEDT3DConfig-version.cmake.in +- "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig-version.cmake" @ONLY) ++configure_file(dynamicEDT3D-config.cmake.in ++ "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3D-config.cmake" @ONLY) ++configure_file(dynamicEDT3D-config-version.cmake.in ++ "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3D-config-version.cmake" @ONLY) + install(FILES + "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig.cmake" +- "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig-version.cmake" ++ "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig-version.cmake" + DESTINATION share/dynamicEDT3D/) + + # Write pkgconfig-file: +diff --git a/dynamicEDT3D/dynamicEDT3DConfig-version.cmake.in b/dynamicEDT3D/dynamicEDT3D-config-version.cmake.in +similarity index 100% +rename from dynamicEDT3D/dynamicEDT3DConfig-version.cmake.in +rename to dynamicEDT3D/dynamicEDT3D-config-version.cmake.in +diff --git a/dynamicEDT3D/dynamicEDT3DConfig.cmake.in b/dynamicEDT3D/dynamicEDT3D-config.cmake.in +similarity index 100% +rename from dynamicEDT3D/dynamicEDT3DConfig.cmake.in +rename to dynamicEDT3D/dynamicEDT3D-config.cmake.in +-- +1.9.2 + diff --git a/package/octomap/octomap-0003-cmake-offer-CMake-modules-with-no-hard-coded-path.patch b/package/octomap/octomap-0003-cmake-offer-CMake-modules-with-no-hard-coded-path.patch new file mode 100644 index 000000000..23476a233 --- /dev/null +++ b/package/octomap/octomap-0003-cmake-offer-CMake-modules-with-no-hard-coded-path.patch @@ -0,0 +1,209 @@ +From 52a285d0279d9704d7506bc65c76e858ddbb93ab Mon Sep 17 00:00:00 2001 +From: Samuel Martin +Date: Tue, 18 Mar 2014 21:51:20 +0100 +Subject: [PATCH 3/3] cmake: offer CMake modules with no hard-coded path + +Hardcoding absolute install paths in the CMake module files totally +breaks the cross-compilation: it makes impossible to be used in a +sysroot because the hardcoded paths are the ones of the target, whereas +they should point to the sysroot location. This tootally breaks the +CMake FIND_ROOT_PATH mechanism designed to handle cross-compilation. + +This patch introduces a new CMake variable: NO_ABSOLUTE_PATH_IN_MODULE, +which, when set on the cmake command-line, will enable the installation +of the CMake module files using the CMake primitives find_library and +find_path to set the libraries and headers' locations, instead of +hard-coding them. + +Thus, this patch adds non-templated CMake module files for octomap, +dynamicEDT3D and octovis for the non hard-coded path version of the +modules. + +In any way, only the installed CMake module files are changed. The +templated ones are still needed for combined package build. + +The non hard-coded path version of the modules are only installed when +NO_ABSOLUTE_PATH_IN_MODULE is set; by default the existing behavior +remains unchanged to keep honoring the behavior described in [1]. + +[1] https://github.com/OctoMap/octomap/pull/57#issuecomment-38161187 + +Signed-off-by: Samuel Martin +--- + dynamicEDT3D/CMakeLists.txt | 9 ++++++-- + dynamicEDT3D/dynamicEDT3D-config.cmake | 19 ++++++++++++++++ + octomap/CMakeLists.txt | 7 +++++- + octomap/octomap-config.cmake | 41 ++++++++++++++++++++++++++++++++++ + octovis/CMakeLists.txt | 7 +++++- + octovis/octovis-config.cmake | 24 ++++++++++++++++++++ + 6 files changed, 103 insertions(+), 4 deletions(-) + create mode 100644 dynamicEDT3D/dynamicEDT3D-config.cmake + create mode 100644 octomap/octomap-config.cmake + create mode 100644 octovis/octovis-config.cmake + +diff --git a/dynamicEDT3D/CMakeLists.txt b/dynamicEDT3D/CMakeLists.txt +index f9e77cf..2f5ca21 100644 +--- a/dynamicEDT3D/CMakeLists.txt ++++ b/dynamicEDT3D/CMakeLists.txt +@@ -91,9 +91,14 @@ configure_file(dynamicEDT3D-config.cmake.in + "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3D-config.cmake" @ONLY) + configure_file(dynamicEDT3D-config-version.cmake.in + "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3D-config-version.cmake" @ONLY) ++IF(DEFINED NO_ABSOLUTE_PATH_IN_MODULE AND NO_ABSOLUTE_PATH_IN_MODULE) ++ set(DYNAMICEDT3D_MODULE_FILE "dynamicEDT3D-config.cmake") ++ELSE() ++ set(DYNAMICEDT3D_MODULE_FILE "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3D-config.cmake" ) ++ENDIF() + install(FILES +- "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig.cmake" +- "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig-version.cmake" ++ "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3D-config-version.cmake" ++ "${DYNAMICEDT3D_MODULE_FILE}" + DESTINATION share/dynamicEDT3D/) + + # Write pkgconfig-file: +diff --git a/dynamicEDT3D/dynamicEDT3D-config.cmake b/dynamicEDT3D/dynamicEDT3D-config.cmake +new file mode 100644 +index 0000000..c21a9ae +--- /dev/null ++++ b/dynamicEDT3D/dynamicEDT3D-config.cmake +@@ -0,0 +1,19 @@ ++# - Config file for the OctoMap package ++# (example from http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file) ++# It defines the following variables ++# OCTOMAP_INCLUDE_DIRS - include directories for OctoMap ++# OCTOMAP_LIBRARIES - libraries to link against ++ ++set(DYNAMICEDT3D_INCLUDE_DIRS) ++set(DYNAMICEDT3D_INCLUDE DYNAMICEDT3D_INCLUDE-NOTFOUND) ++find_path(DYNAMICEDT3D_INCLUDE dynamicEDT3D/dynamicEDT3D.h) ++if(DYNAMICEDT3D_INCLUDE) ++ list(APPEND DYNAMICEDT3D_INCLUDE_DIRS ${DYNAMICEDT3D_INCLUDE}) ++endif() ++ ++set(DYNAMICEDT3D_LIBRARIES) ++set(DYNAMICEDT3D_LIB DYNAMICEDT3D_LIB-NOTFOUND) ++find_library(DYNAMICEDT3D_LIB dynamicedt3d) ++if(DYNAMICEDT3D_LIB) ++ list(APPEND DYNAMICEDT3D_LIBRARIES ${DYNAMICEDT3D_LIB}) ++endif() +diff --git a/octomap/CMakeLists.txt b/octomap/CMakeLists.txt +index 9c9f674..71099a3 100644 +--- a/octomap/CMakeLists.txt ++++ b/octomap/CMakeLists.txt +@@ -98,9 +98,14 @@ configure_file(octomap-config.cmake.in + "${PROJECT_BINARY_DIR}/InstallFiles/octomap-config.cmake" @ONLY) + configure_file(octomap-config-version.cmake.in + "${PROJECT_BINARY_DIR}/InstallFiles/octomap-config-version.cmake" @ONLY) ++IF(DEFINED NO_ABSOLUTE_PATH_IN_MODULE AND NO_ABSOLUTE_PATH_IN_MODULE) ++ set(OCTOMAP_MODULE_FILE "octomap-config.cmake") ++ELSE() ++ set(OCTOMAP_MODULE_FILE "${PROJECT_BINARY_DIR}/InstallFiles/octomap-config.cmake" ) ++ENDIF() + install(FILES +- "${PROJECT_BINARY_DIR}/InstallFiles/octomap-config.cmake" + "${PROJECT_BINARY_DIR}/InstallFiles/octomap-config-version.cmake" ++ "${OCTOMAP_MODULE_FILE}" + DESTINATION share/octomap/) + + # Write pkgconfig-file: +diff --git a/octomap/octomap-config.cmake b/octomap/octomap-config.cmake +new file mode 100644 +index 0000000..5572b89 +--- /dev/null ++++ b/octomap/octomap-config.cmake +@@ -0,0 +1,41 @@ ++# =================================================================================== ++# The OctoMap CMake configuration file ++# ++# ** File generated automatically, do not modify ** ++# ++# Usage from an external project: ++# In your CMakeLists.txt, add these lines: ++# ++# FIND_PACKAGE(octomap REQUIRED ) ++# TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${OCTOMAP_LIBRARIES}) ++# ++# This file will define the following variables: ++# - OCTOMAP_LIBRARIES : The list of libraries to links against. ++# - OCTOMAP_LIBRARY_DIRS : The directory where lib files are. Calling ++# LINK_DIRECTORIES with this path is NOT needed. ++# - OCTOMAP_INCLUDE_DIRS : The OpenCV include directories. ++# ++# Based on the example CMake Tutorial ++# http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file ++# and OpenCVConfig.cmake.in from OpenCV ++# =================================================================================== ++ ++set(OCTOMAP_INCLUDE_DIRS) ++set(OCTOMAP_INCLUDE OCTOMAP_INCLUDE-NOTFOUND) ++find_path(OCTOMAP_INCLUDE octomap/octomap.h) ++if(OCTOMAP_INCLUDE) ++ list(APPEND OCTOMAP_INCLUDE_DIRS ${OCTOMAP_INCLUDE}) ++endif() ++ ++set(OCTOMAP_LIBRARIES) ++set(OCTOMAP_LIB OCTOMAP_LIB-NOTFOUND) ++find_library(OCTOMAP_LIB octomap) ++if(OCTOMAP_LIB) ++ list(APPEND OCTOMAP_LIBRARIES ${OCTOMAP_LIB}) ++endif() ++ ++set(OCTOMATH_LIB OCTOMATH_LIB-NOTFOUND) ++find_library(OCTOMATH_LIB octomath) ++if(OCTOMATH_LIB) ++ list(APPEND OCTOMAP_LIBRARIES ${OCTOMATH_LIB}) ++endif() +diff --git a/octovis/CMakeLists.txt b/octovis/CMakeLists.txt +index edfca27..c62b6bc 100644 +--- a/octovis/CMakeLists.txt ++++ b/octovis/CMakeLists.txt +@@ -95,9 +95,14 @@ IF(BUILD_VIEWER) + "${PROJECT_BINARY_DIR}/InstallFiles/octovis-config.cmake" @ONLY) + configure_file(octovis-config-version.cmake.in + "${PROJECT_BINARY_DIR}/InstallFiles/octovis-config-version.cmake" @ONLY) ++ IF(DEFINED NO_ABSOLUTE_PATH_IN_MODULE AND NO_ABSOLUTE_PATH_IN_MODULE) ++ set(OCTOVIS_MODULE_FILE "octovis-config.cmake") ++ ELSE() ++ set(OCTOVIS_MODULE_FILE "${PROJECT_BINARY_DIR}/InstallFiles/octovis-config.cmake" ) ++ ENDIF() + install(FILES +- "${PROJECT_BINARY_DIR}/InstallFiles/octovis-config.cmake" + "${PROJECT_BINARY_DIR}/InstallFiles/octovis-config-version.cmake" ++ "${OCTOVIS_MODULE_FILE}" + DESTINATION share/octovis/) + + +diff --git a/octovis/octovis-config.cmake b/octovis/octovis-config.cmake +new file mode 100644 +index 0000000..99d9798 +--- /dev/null ++++ b/octovis/octovis-config.cmake +@@ -0,0 +1,24 @@ ++# - Config file for the OctoMap package ++# (example from http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file) ++# It defines the following variables ++# OCTOVIS_INCLUDE_DIRS - include directories for OctoMap viewer ++# OCTOVIS_LIBRARIES - libraries to link against ++ ++find_package(OCTOMAP) ++ ++set(QGLViewer_LIB QGLViewer_LIB-NOTFOUND) ++find_library(QGLViewer_LIB QGLViewer) ++if(NOT QGLViewer_LIB) ++ message(FATAL "Could not find QGLViewer") ++endif() ++ ++find_package(Qt4 COMPONENTS QTCORE QTGUI QTOPENGL) ++ ++set(OCTOVIS_INCLUDE_DIRS) ++set(OCTOVIS_LIBRARIES) ++ ++list(APPEND OCTOVIS_INCLUDE_DIRS ${OCTOMAP_INCLUDE} ++ ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTOPENGL_INCLUDE_DIR}) ++ ++list(APPEND OCTOVIS_LIBRARIES ${OCTOMAP_LIB} ${QGLViewer_LIB} ++ ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY}) +-- +1.9.2 + diff --git a/package/octomap/octomap.mk b/package/octomap/octomap.mk new file mode 100644 index 000000000..0a98ad9b9 --- /dev/null +++ b/package/octomap/octomap.mk @@ -0,0 +1,31 @@ +################################################################################ +# +# octomap +# +################################################################################ + +OCTOMAP_VERSION = v1.6.4 +# Octomap is licensed under BSD-3c, except octovis which is under GPLv2. +# Since octovis is not built, do not mention its license in the legal infra. +OCTOMAP_LICENSE = BSD-3c +OCTOMAP_LICENSE_FILES = octomap/LICENSE.txt +OCTOMAP_SITE = $(call github,OctoMap,octomap,$(OCTOMAP_VERSION)) +OCTOMAP_INSTALL_STAGING = YES +OCTOMAP_SUBDIR = octomap + +# disable the documentation +OCTOMAP_CONF_OPT += \ + -DDOXYGEN_EXECUTABLE=DOXYGEN_EXECUTABLE-NOTFOUND \ + -DNO_ABSOLUTE_PATH_IN_MODULE=ON + +ifeq ($(BR2_PACKAGE_OCTOMAP_INSTALL_PROGRAMS),) +define OCTOMAP_TARGET_INSTALL_REMOVE_PROGRAMS + -rm -f $(addprefix $(TARGET_DIR)/usr/bin/,\ + graph2tree log2graph binvox2bt bt2vrml edit_octree \ + convert_octree eval_octree_accuracy compare_octrees) +endef + +OCTOMAP_POST_INSTALL_TARGET_HOOKS += OCTOMAP_TARGET_INSTALL_REMOVE_PROGRAMS +endif + +$(eval $(cmake-package))