diff --git a/recipes/ompl/1.5.2/conandata.yml b/recipes/ompl/1.5.2/conandata.yml new file mode 100644 index 0000000000000..668840e61f9f4 --- /dev/null +++ b/recipes/ompl/1.5.2/conandata.yml @@ -0,0 +1,4 @@ +sources: + "1.5.2": + url: "https://github.com/ompl/ompl/archive/refs/tags/1.5.2.zip" + sha256: "1b9f25339e014c448334cb8bd5d7d52d1dcf457227cc2dde4c2210d1d494258d" diff --git a/recipes/ompl/1.5.2/conanfile.py b/recipes/ompl/1.5.2/conanfile.py new file mode 100644 index 0000000000000..8e77149235579 --- /dev/null +++ b/recipes/ompl/1.5.2/conanfile.py @@ -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'] diff --git a/recipes/ompl/1.5.2/test_package/CMakeLists.txt b/recipes/ompl/1.5.2/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..51a08787e0cdb --- /dev/null +++ b/recipes/ompl/1.5.2/test_package/CMakeLists.txt @@ -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) diff --git a/recipes/ompl/1.5.2/test_package/conanfile.py b/recipes/ompl/1.5.2/test_package/conanfile.py new file mode 100644 index 0000000000000..f3b80b5b79d91 --- /dev/null +++ b/recipes/ompl/1.5.2/test_package/conanfile.py @@ -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) diff --git a/recipes/ompl/1.5.2/test_package/example.cpp b/recipes/ompl/1.5.2/test_package/example.cpp new file mode 100644 index 0000000000000..0e704c481f795 --- /dev/null +++ b/recipes/ompl/1.5.2/test_package/example.cpp @@ -0,0 +1,13 @@ +#include +#include + +#include +#include + +int main() { + auto stateSpace = std::make_shared(5); + auto setup = std::make_shared (stateSpace); + std::cout << "ompl objects constructed successfully" << std::endl; + + return 0; +} diff --git a/recipes/ompl/config.yml b/recipes/ompl/config.yml new file mode 100644 index 0000000000000..1cb587e2a9ff1 --- /dev/null +++ b/recipes/ompl/config.yml @@ -0,0 +1,3 @@ +versions: + "1.5.2": + folder: 1.5.2