Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

octomap: add 1.9.6 + fix build with ninja generator #4370

Merged
merged 4 commits into from
Feb 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions recipes/octomap/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
sources:
"1.9.6":
url: "https://github.com/OctoMap/octomap/archive/v1.9.6.tar.gz"
sha256: "0f88c1c024f0d29ab74c7fb9f6ebfdddc8be725087372c6c4d8878be95831eb6"
"1.9.5":
url: "https://github.com/OctoMap/octomap/archive/v1.9.5.tar.gz"
sha256: "adf87320c4c830c0fd85fe8d913d8aa174e2f72d0ea64c917599a50a561092b6"
"1.9.3":
url: "https://github.com/OctoMap/octomap/archive/v1.9.3.tar.gz"
sha256: "8488de97ed2c8f4757bfbaf3225e82a9e36783dce1f573b3bde1cf968aa89696"
patches:
"1.9.6":
- patch_file: "patches/targets-outputname-collision-1.9.5.patch"
base_path: "source_subfolder"
"1.9.5":
url: "https://github.com/OctoMap/octomap/archive/v1.9.5.tar.gz"
sha256: "adf87320c4c830c0fd85fe8d913d8aa174e2f72d0ea64c917599a50a561092b6"
- patch_file: "patches/targets-outputname-collision-1.9.5.patch"
base_path: "source_subfolder"
"1.9.3":
- patch_file: "patches/targets-outputname-collision-1.9.3.patch"
base_path: "source_subfolder"
52 changes: 30 additions & 22 deletions recipes/octomap/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os

from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration

class OctomapConan(ConanFile):
name = "octomap"
Expand All @@ -9,8 +10,7 @@ class OctomapConan(ConanFile):
topics = ("conan", "octomap", "octree", "3d", "robotics")
homepage = "https://github.com/OctoMap/octomap"
url = "https://github.com/conan-io/conan-center-index"
exports_sources = "CMakeLists.txt"
generators = "cmake"

settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
Expand All @@ -23,53 +23,61 @@ class OctomapConan(ConanFile):
"openmp": False
}

exports_sources = ["CMakeLists.txt", "patches/**"]
generators = "cmake"
_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
del self.options.fPIC
if self.options.shared and self.settings.compiler.get_safe("runtime") == "MTd":
raise ConanInvalidConfiguration("shared octomap doesn't support MTd runtime")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
os.rename(self.name + "-" + self.version, self._source_subfolder)

def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.definitions["OCTOMAP_OMP"] = self.options.openmp
cmake.configure(build_folder=self._build_subfolder)
cmake.build(target="octomap" if self.options.shared else "octomap-static")
cmake = self._configure_cmake()
cmake.build()

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["OCTOMAP_OMP"] = self.options.openmp
self._cmake.definitions["BUILD_TESTING"] = False
self._cmake.configure()
return self._cmake

def _patch_sources(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
tools.replace_in_file(os.path.join(self._source_subfolder, "octomap", "CMakeLists.txt"),
"SET( BASE_DIR ${CMAKE_SOURCE_DIR} )",
"SET( BASE_DIR ${CMAKE_BINARY_DIR} )")
compiler_settings = os.path.join(self._source_subfolder, "octomap", "CMakeModules", "CompilerSettings.cmake")
# Do not force PIC
tools.replace_in_file(os.path.join(self._source_subfolder, "octomap", "CMakeModules", "CompilerSettings.cmake"),
"ADD_DEFINITIONS(-fPIC)", "")
tools.replace_in_file(compiler_settings, "ADD_DEFINITIONS(-fPIC)", "")
# No -Werror
if tools.Version(self.version) >= "1.9.6":
tools.replace_in_file(compiler_settings, "-Werror", "")

def package(self):
self.copy("LICENSE.txt", dst="licenses", src=os.path.join(self._source_subfolder, "octomap"))
source_include_dir = os.path.join(self._source_subfolder, "octomap", "include")
build_lib_dir = os.path.join(self._build_subfolder, "lib")
build_bin_dir = os.path.join(self._build_subfolder, "bin")
self.copy(pattern="*.h", dst="include", src=source_include_dir)
self.copy(pattern="*.hxx", dst="include", src=source_include_dir)
self.copy(pattern="*.a", dst="lib", src=build_lib_dir, keep_path=False)
self.copy(pattern="*.lib", dst="lib", src=build_lib_dir, keep_path=False)
self.copy(pattern="*.dylib", dst="lib", src=build_lib_dir, keep_path=False)
self.copy(pattern="*.so*", dst="lib", src=build_lib_dir, keep_path=False, symlinks=True)
self.copy(pattern="*.dll", dst="bin", src=build_bin_dir, keep_path=False)
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))

def package_info(self):
# TODO: no namespace for CMake imported targets
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
--- a/octomap/src/CMakeLists.txt
+++ b/octomap/src/CMakeLists.txt
@@ -11,26 +11,34 @@ SET (octomap_SRCS
)

# dynamic and static libs, see CMake FAQ:
+if(BUILD_SHARED_LIBS)
+set(OCTOMAP_TARGET "octomap")
ADD_LIBRARY( octomap SHARED ${octomap_SRCS})
set_target_properties( octomap PROPERTIES
VERSION ${OCTOMAP_VERSION}
SOVERSION ${OCTOMAP_SOVERSION}
)
+else()
+set(OCTOMAP_TARGET "octomap-static")
ADD_LIBRARY( octomap-static STATIC ${octomap_SRCS})
SET_TARGET_PROPERTIES(octomap-static PROPERTIES OUTPUT_NAME "octomap")
add_dependencies(octomap-static octomath-static)
+endif()

+if(BUILD_SHARED_LIBS)
TARGET_LINK_LIBRARIES(octomap octomath)
+endif()

if(NOT EXISTS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap")
file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap")
endif()

-export(TARGETS octomap octomap-static
+export(TARGETS ${OCTOMAP_TARGET}
APPEND FILE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap/octomap-targets.cmake")

ADD_SUBDIRECTORY( testing )

+if(FALSE)
ADD_EXECUTABLE(graph2tree graph2tree.cpp)
TARGET_LINK_LIBRARIES(graph2tree octomap)

@@ -66,14 +74,16 @@ TARGET_LINK_LIBRARIES(intersection_example octomap)

ADD_EXECUTABLE(octree2pointcloud octree2pointcloud.cpp)
TARGET_LINK_LIBRARIES(octree2pointcloud octomap)
+endif()

-install(TARGETS octomap octomap-static
+install(TARGETS ${OCTOMAP_TARGET}
EXPORT octomap-targets
INCLUDES DESTINATION include
${INSTALL_TARGETS_DEFAULT_ARGS}
)
install(EXPORT octomap-targets DESTINATION share/octomap/)

+if(FALSE)
install(TARGETS
graph2tree
log2graph
@@ -85,4 +95,5 @@ install(TARGETS
compare_octrees
${INSTALL_TARGETS_DEFAULT_ARGS}
)
+endif()

--- a/octomap/src/math/CMakeLists.txt
+++ b/octomap/src/math/CMakeLists.txt
@@ -5,12 +5,16 @@ SET (octomath_SRCS
)


+if(BUILD_SHARED_LIBS)
+set(OCTOMATH_TARGET "octomath")
ADD_LIBRARY( octomath SHARED ${octomath_SRCS})

SET_TARGET_PROPERTIES( octomath PROPERTIES
VERSION ${OCTOMAP_VERSION}
SOVERSION ${OCTOMAP_SOVERSION}
)
+else()
+set(OCTOMATH_TARGET "octomath-static")

ADD_LIBRARY( octomath-static STATIC ${octomath_SRCS})
SET_TARGET_PROPERTIES(octomath-static PROPERTIES OUTPUT_NAME "octomath")
@@ -18,11 +22,12 @@ SET_TARGET_PROPERTIES(octomath-static PROPERTIES OUTPUT_NAME "octomath")
if(NOT EXISTS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap")
file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap")
endif()
+endif()

-export(TARGETS octomath octomath-static
+export(TARGETS ${OCTOMATH_TARGET}
APPEND FILE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap/octomap-targets.cmake")

-install(TARGETS octomath octomath-static
+install(TARGETS ${OCTOMATH_TARGET}
EXPORT octomap-targets
INCLUDES DESTINATION include
${INSTALL_TARGETS_DEFAULT_ARGS}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
--- a/octomap/src/CMakeLists.txt
+++ b/octomap/src/CMakeLists.txt
@@ -11,26 +11,34 @@ SET (octomap_SRCS
)

# dynamic and static libs, see CMake FAQ:
+if(BUILD_SHARED_LIBS)
+set(OCTOMAP_TARGET "octomap")
ADD_LIBRARY( octomap SHARED ${octomap_SRCS})
set_target_properties( octomap PROPERTIES
VERSION ${OCTOMAP_VERSION}
SOVERSION ${OCTOMAP_SOVERSION}
)
+else()
+set(OCTOMAP_TARGET "octomap-static")
ADD_LIBRARY( octomap-static STATIC ${octomap_SRCS})
SET_TARGET_PROPERTIES(octomap-static PROPERTIES OUTPUT_NAME "octomap")
add_dependencies(octomap-static octomath-static)
+endif()

+if(BUILD_SHARED_LIBS)
TARGET_LINK_LIBRARIES(octomap octomath)
+endif()

if(NOT EXISTS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap")
file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap")
endif()

-export(TARGETS octomap octomap-static
+export(TARGETS ${OCTOMAP_TARGET}
APPEND FILE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap/octomap-targets.cmake")

ADD_SUBDIRECTORY( testing )

+if(FALSE)
ADD_EXECUTABLE(graph2tree graph2tree.cpp)
TARGET_LINK_LIBRARIES(graph2tree octomap)

@@ -66,14 +74,16 @@ TARGET_LINK_LIBRARIES(intersection_example octomap)

ADD_EXECUTABLE(octree2pointcloud octree2pointcloud.cpp)
TARGET_LINK_LIBRARIES(octree2pointcloud octomap)
+endif()

-install(TARGETS octomap octomap-static
+install(TARGETS ${OCTOMAP_TARGET}
EXPORT octomap-targets
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
${INSTALL_TARGETS_DEFAULT_ARGS}
)
install(EXPORT octomap-targets DESTINATION "${CMAKE_INSTALL_DATADIR}/octomap")

+if(FALSE)
install(TARGETS
graph2tree
log2graph
@@ -85,4 +95,5 @@ install(TARGETS
compare_octrees
${INSTALL_TARGETS_DEFAULT_ARGS}
)
+endif()

--- a/octomap/src/math/CMakeLists.txt
+++ b/octomap/src/math/CMakeLists.txt
@@ -5,12 +5,16 @@ SET (octomath_SRCS
)


+if(BUILD_SHARED_LIBS)
+set(OCTOMATH_TARGET "octomath")
ADD_LIBRARY( octomath SHARED ${octomath_SRCS})

SET_TARGET_PROPERTIES( octomath PROPERTIES
VERSION ${OCTOMAP_VERSION}
SOVERSION ${OCTOMAP_SOVERSION}
)
+else()
+set(OCTOMATH_TARGET "octomath-static")

ADD_LIBRARY( octomath-static STATIC ${octomath_SRCS})
SET_TARGET_PROPERTIES(octomath-static PROPERTIES OUTPUT_NAME "octomath")
@@ -18,11 +22,12 @@ SET_TARGET_PROPERTIES(octomath-static PROPERTIES OUTPUT_NAME "octomath")
if(NOT EXISTS "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap")
file(MAKE_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap")
endif()
+endif()

-export(TARGETS octomath octomath-static
+export(TARGETS ${OCTOMATH_TARGET}
APPEND FILE "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap/octomap-targets.cmake")

-install(TARGETS octomath octomath-static
+install(TARGETS ${OCTOMATH_TARGET}
EXPORT octomap-targets
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
${INSTALL_TARGETS_DEFAULT_ARGS}
4 changes: 3 additions & 1 deletion recipes/octomap/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
versions:
"1.9.3":
"1.9.6":
folder: all
"1.9.5":
folder: all
"1.9.3":
folder: all