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

ompl/1.5.2 recipe #6542

Closed
wants to merge 4 commits into from
Closed
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
4 changes: 4 additions & 0 deletions recipes/ompl/1.5.2/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.5.2":
url: "https://github.com/ompl/ompl/archive/refs/tags/1.5.2.zip"
sha256: "1b9f25339e014c448334cb8bd5d7d52d1dcf457227cc2dde4c2210d1d494258d"
104 changes: 104 additions & 0 deletions recipes/ompl/1.5.2/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from conans import ConanFile, tools, CMake
import os
import glob

BOOST_MODULES = ["system", "filesystem",
"program_options", "serialization", "test"]
BOOST_UNUSED_MODULES = ["atomic", "chrono", "container", "context", "contract", "coroutine", "date_time", "exception",
"fiber", "graph", "graph_parallel", "iostreams", "locale", "log", "math", "mpi", "python", "random",
"regex", "stacktrace", "thread", "timer", "type_erasure", "wave"]


class ConanOmpl(ConanFile):
name = "ompl"
version = "1.5.2"
license = "BSD"
homepage = "https://ompl.kavrakilab.org/"
description = "OMPL, the Open Motion Planning Library, consists of many state-of-the-art sampling-based motion planning algorithms."
url = "https://github.com/conan-io/conan-center-index"
topics = ("ompl", "motion-planning", "robotics", "collision")
generators = "cmake_find_package", "cmake_paths", "cmake"
BOOST_VERSION = "1.72.0"
requires = "boost/{}".format(BOOST_VERSION), "eigen/3.3.9"

settings = 'os', 'compiler', 'build_type', 'arch'
options = {"shared": [True, False], "run_tests": [
True, False], "fPIC": [True, False]}
default_options = {"shared": False, "run_tests": False, "fPIC": True}

def configure(self):
if self.options.shared:
del self.options.fPIC

boost_options = self.options["boost"]
for module in BOOST_MODULES:
setattr(boost_options, "without_{}".format(module), False)
for module in BOOST_UNUSED_MODULES:
setattr(boost_options, "without_{}".format(module), True)

@property
def _source_subfolder(self):
return "ompl-{}".format(self.version)

def source(self):
tools.get(**self.conan_data["sources"][self.version],
destination=self._source_subfolder, strip_root=True)

tools.replace_in_file("{}/CMakeLists.txt".format(self._source_subfolder),
"project(ompl VERSION {} LANGUAGES CXX)".format(
self.version),
'project(ompl VERSION {} LANGUAGES CXX)\n'.format(self.version) +
'include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)\n' +
'conan_basic_setup(KEEP_RPATHS)\n' +
'include(${CMAKE_BINARY_DIR}/conan_paths.cmake)\n')

tools.replace_in_file("{}/CMakeLists.txt".format(self._source_subfolder),
"find_package(Boost 1.58 QUIET REQUIRED COMPONENTS serialization filesystem system program_options)",
'find_package(Boost {} REQUIRED)\n'.format(self.BOOST_VERSION) +
'set(Boost_SERIALIZATION_LIBRARY "${Boost_LIBRARIES_TARGETS}")\n' +
'set(Boost_FILESYSTEM_LIBRARY "${Boost_LIBRARIES_TARGETS}")\n' +
'set(Boost_SYSTEM_LIBRARY "${Boost_LIBRARIES_TARGETS}")\n' +
'set(Boost_LIBRARY_DIRS " ")')

tools.replace_in_file("{}/CMakeLists.txt".format(self._source_subfolder),
"find_package(Eigen3 REQUIRED)",
'find_package(Eigen3 REQUIRED)\n' +
'set(EIGEN3_INCLUDE_DIR ${Eigen3_INCLUDE_DIR})')

def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["BUILD_SHARED_LIBS"] = self.options.shared
cmake.definitions["OMPL_BUILD_TESTS"] = self.options.run_tests
cmake.definitions["OMPL_BUILD_DEMOS"] = self.options.run_tests

ignored_packages = ["pypy", "flann",
"ODE", "spot", "MORSE", "Triangle"]
for pkg in ignored_packages:
cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_{}".format(
pkg)] = "ON"

disabled_options = ["BUILD_PYBINDINGS",
"BUILD_PYTESTS", "REGISTRATION", "VERSIONED_INSTALL"]
for opt in disabled_options:
cmake.definitions["OMPL_{}".format(opt)] = "OFF"

cmake.configure(source_folder=os.path.join(
self.build_folder, self._source_subfolder))
return cmake

def build(self):
cmake = self._configure_cmake()
if self.options.run_tests:
cmake.build()
cmake.test()
else:
cmake.build(target="ompl")

def package(self):
cmake = self._configure_cmake()
cmake.install()

def package_info(self):
self.cpp_info.includedirs = ["include"]
self.cpp_info.libs = ["ompl"]
self.cpp_info.libdirs = ['lib']
16 changes: 16 additions & 0 deletions recipes/ompl/1.5.2/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.1)
project(PackageTest CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(KEEP_RPATHS)
find_package(OMPL REQUIRED)

if (APPLE)
set(CMAKE_INSTALL_RPATH "@executable_path" "@executable_path/../lib")
elseif(NOT WIN32) # Linux
set(CMAKE_INSTALL_RPATH "$ORIGIN" "$ORIGIN/../lib")
endif() # windows, the library stays in bin folder with the executables
set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)

add_executable(example example.cpp)
target_link_libraries(example ompl::ompl)
19 changes: 19 additions & 0 deletions recipes/ompl/1.5.2/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import os
import shutil

from conans import ConanFile, CMake, tools


class PackageTest(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake_find_package", "cmake"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "example")
self.run(bin_path, run_environment=True)
13 changes: 13 additions & 0 deletions recipes/ompl/1.5.2/test_package/example.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <iostream>
#include <memory>

#include <ompl/base/spaces/RealVectorStateSpace.h>
#include <ompl/geometric/SimpleSetup.h>

int main() {
auto stateSpace = std::make_shared<ompl::base::RealVectorStateSpace>(5);
auto setup = std::make_shared <ompl::geometric::SimpleSetup>(stateSpace);
std::cout << "ompl objects constructed successfully" << std::endl;

return 0;
}
3 changes: 3 additions & 0 deletions recipes/ompl/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.5.2":
folder: 1.5.2