From ea8c956bab1a0c84536a2b906f3830ee6fc232d0 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Fri, 3 Apr 2020 17:55:58 +0200 Subject: [PATCH] add fcl/0.6.1 --- recipes/fcl/all/CMakeLists.txt | 7 + recipes/fcl/all/conandata.yml | 12 ++ recipes/fcl/all/conanfile.py | 98 ++++++++++ .../all/patches/conanize-cmake-0.6.1.patch | 169 ++++++++++++++++++ .../all/patches/fix-alias-type-msvc2015.patch | 47 +++++ .../fcl/all/patches/fix-mingw-bigobj.patch | 17 ++ recipes/fcl/all/test_package/CMakeLists.txt | 9 + recipes/fcl/all/test_package/conanfile.py | 17 ++ recipes/fcl/all/test_package/test_package.cpp | 78 ++++++++ recipes/fcl/config.yml | 3 + 10 files changed, 457 insertions(+) create mode 100644 recipes/fcl/all/CMakeLists.txt create mode 100644 recipes/fcl/all/conandata.yml create mode 100644 recipes/fcl/all/conanfile.py create mode 100644 recipes/fcl/all/patches/conanize-cmake-0.6.1.patch create mode 100644 recipes/fcl/all/patches/fix-alias-type-msvc2015.patch create mode 100644 recipes/fcl/all/patches/fix-mingw-bigobj.patch create mode 100644 recipes/fcl/all/test_package/CMakeLists.txt create mode 100644 recipes/fcl/all/test_package/conanfile.py create mode 100644 recipes/fcl/all/test_package/test_package.cpp create mode 100644 recipes/fcl/config.yml diff --git a/recipes/fcl/all/CMakeLists.txt b/recipes/fcl/all/CMakeLists.txt new file mode 100644 index 0000000000000..4d393c7a86c09 --- /dev/null +++ b/recipes/fcl/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.1.2) +project(cmake_wrapper) + +include(conanbuildinfo.cmake) +conan_basic_setup(TARGETS) + +add_subdirectory("source_subfolder") diff --git a/recipes/fcl/all/conandata.yml b/recipes/fcl/all/conandata.yml new file mode 100644 index 0000000000000..3dab85f3d9323 --- /dev/null +++ b/recipes/fcl/all/conandata.yml @@ -0,0 +1,12 @@ +sources: + "0.6.1": + url: "https://github.com/flexible-collision-library/fcl/archive/v0.6.1.tar.gz" + sha256: "c8a68de8d35a4a5cd563411e7577c0dc2c626aba1eef288cb1ca88561f8d8019" +patches: + "0.6.1": + - patch_file: "patches/conanize-cmake-0.6.1.patch" + base_path: "source_subfolder" + - patch_file: "patches/fix-mingw-bigobj.patch" + base_path: "source_subfolder" + - patch_file: "patches/fix-alias-type-msvc2015.patch" + base_path: "source_subfolder" diff --git a/recipes/fcl/all/conanfile.py b/recipes/fcl/all/conanfile.py new file mode 100644 index 0000000000000..87f5d904006d7 --- /dev/null +++ b/recipes/fcl/all/conanfile.py @@ -0,0 +1,98 @@ +import os + +from conans import ConanFile, CMake, tools +from conans.errors import ConanInvalidConfiguration + +class FclConan(ConanFile): + name = "fcl" + description = "C++11 library for performing three types of proximity " \ + "queries on a pair of geometric models composed of triangles." + license = "BSD-3-Clause" + topics = ("conan", "fcl", "geometry", "collision") + homepage = "https://github.com/flexible-collision-library/fcl" + url = "https://github.com/conan-io/conan-center-index" + exports_sources = ["CMakeLists.txt", "patches/**"] + generators = "cmake" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "with_octomap": [True, False] + } + default_options = { + "shared": False, + "fPIC": True, + "with_octomap": True + } + + _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.settings.compiler.cppstd: + tools.check_min_cppstd(self, 11) + if self.settings.os == "Windows" and self.options.shared: + raise ConanInvalidConfiguration("{0} {1} doesn't properly support shared lib on Windows".format(self.name, + self.version)) + + def requirements(self): + self.requires.add("eigen/3.3.7") + self.requires.add("libccd/2.1") + if self.options.with_octomap: + self.requires.add("octomap/1.9.3") + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + os.rename(self.name + "-" + self.version, self._source_subfolder) + + def build(self): + for patch in self.conan_data["patches"][self.version]: + tools.patch(**patch) + cmake = self._configure_cmake() + cmake.build() + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["FCL_ENABLE_PROFILING"] = False + self._cmake.definitions["FCL_TREAT_WARNINGS_AS_ERRORS"] = False + self._cmake.definitions["FCL_HIDE_ALL_SYMBOLS"] = False + self._cmake.definitions["FCL_STATIC_LIBRARY"] = not self.options.shared + self._cmake.definitions["FCL_USE_X64_SSE"] = False # Let consumer decide to add relevant compile options, ftl doesn't have simd intrinsics + self._cmake.definitions["FCL_USE_HOST_NATIVE_ARCH"] = False + self._cmake.definitions["FCL_USE_SSE"] = False + self._cmake.definitions["FCL_COVERALLS"] = False + self._cmake.definitions["FCL_COVERALLS_UPLOAD"] = False + self._cmake.definitions["FCL_WITH_OCTOMAP"] = self.options.with_octomap + if self.options.with_octomap: + octomap_major, octomap_minor, octomap_patch = self.deps_cpp_info["octomap"].version.split(".") + self._cmake.definitions["OCTOMAP_MAJOR_VERSION"] = octomap_major + self._cmake.definitions["OCTOMAP_MINOR_VERSION"] = octomap_minor + self._cmake.definitions["OCTOMAP_PATCH_VERSION"] = octomap_patch + self._cmake.definitions["BUILD_TESTING"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def package(self): + self.copy("LICENSE", dst="licenses", src=self._source_subfolder) + cmake = self._configure_cmake() + cmake.install() + tools.rmdir(os.path.join(self.package_folder, "CMake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "cmake")) + tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig")) + tools.rmdir(os.path.join(self.package_folder, "share")) + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) diff --git a/recipes/fcl/all/patches/conanize-cmake-0.6.1.patch b/recipes/fcl/all/patches/conanize-cmake-0.6.1.patch new file mode 100644 index 0000000000000..5f650800aa804 --- /dev/null +++ b/recipes/fcl/all/patches/conanize-cmake-0.6.1.patch @@ -0,0 +1,169 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -142,20 +142,6 @@ set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON) + # + # If Eigen3 is not found, manually set the cache variable EIGEN3_INCLUDE_DIR + #=============================================================================== +-find_package(Eigen3 3.0.5 QUIET CONFIG) +- +-# If Eigen3Config.cmake is not found, use the FindEigen3.cmake module +-if(NOT Eigen3_FOUND) +- find_package(Eigen3 3.0.5 QUIET MODULE) +- set(Eigen3_FOUND ON) +-endif() +- +-if(Eigen3_FOUND) +- set(FCL_HAVE_EIGEN TRUE) +-else() +- message(SEND_ERROR "EIGEN3 (>= 3.0.5) is required by FCL") +- set(FCL_HAVE_EIGEN FALSE) +-endif() + + #=============================================================================== + # Find required dependency libccd +@@ -163,41 +149,6 @@ endif() + # If libccd is not found, manually set the cache variables CCD_INCLUDE_DIR and + # CCD_LIBRARY + #=============================================================================== +-find_package(ccd QUIET) +- +-# If ccd-config.cmake is not found, use pkg-config and/or find_path() and +-# find_library() +-if(NOT ccd_FOUND) +- if(PKG_CONFIG_FOUND) +- pkg_check_modules(PC_CCD ccd) +- pkg_check_modules(PC_LIBCCD libccd) +- endif() +- +- find_path(CCD_INCLUDE_DIR ccd/ccd.h +- HINTS "${PC_CCD_INCLUDE_DIRS}" "${PC_LIBCCD_INCLUDE_DIRS}") +- +- # Using find_library() even if pkg-config is available ensures that the full +- # path to the ccd library is available in CCD_LIBRARIES +- find_library(CCD_LIBRARY ccd +- HINTS "${PC_CCD_LIBRARY_DIRS}" "${PC_LIBCCD_LIBRARY_DIRS}") +- +- # libccd links to LibM on UNIX. +- if(CYGWIN OR NOT WIN32) +- find_library(M_LIBRARY m) +- endif() +- +- if(CCD_INCLUDE_DIR AND CCD_LIBRARY) +- set(CCD_INCLUDE_DIRS "${CCD_INCLUDE_DIR}") +- set(CCD_LIBRARIES "${CCD_LIBRARY}" "${M_LIBRARY}") +- set(ccd_FOUND ON) +- +- mark_as_advanced(CCD_INCLUDE_DIR CCD_LIBRARY) +- endif() +-endif() +- +-if(NOT ccd_FOUND) +- message(FATAL_ERROR "CCD is required by FCL") +-endif() + + set(PKG_EXTERNAL_DEPS "ccd eigen3") + +@@ -211,58 +162,9 @@ option(FCL_WITH_OCTOMAP "OctoMap library support" ON) + set(FCL_HAVE_OCTOMAP 0) + + if(FCL_WITH_OCTOMAP) +- find_package(octomap QUIET) +- +- # Older versions of octomap-config.cmake may not define OCTOMAP_VERSION so +- # fall back to pkg-config +- if(NOT octomap_FOUND OR NOT OCTOMAP_VERSION) +- if(PKG_CONFIG_FOUND) +- pkg_check_modules(PC_OCTOMAP octomap) +- endif() +- +- find_path(OCTOMAP_INCLUDE_DIR octomap/octomap.h +- HINTS "${PC_OCTOMAP_INCLUDE_DIRS}") +- +- # Using find_library() even if pkg-config is available ensures that the full +- # paths to the octomap and octomath libraries are set in OCTOMAP_LIBRARIES +- find_library(OCTOMAP_LIBRARY octomap +- HINTS "${PC_OCTOMAP_LIBRARY_DIRS}") +- +- find_library(OCTOMATH_LIBRARY octomath +- HINTS "${PC_OCTOMAP_LIBRARY_DIRS}") +- +- # Use a cache variable so that the version can be manually set if pkg-config +- # is not available +- set(OCTOMAP_VERSION "${PC_OCTOMAP_VERSION}" +- CACHE STRING "octomap version (major.minor.patch)") +- +- if(OCTOMAP_INCLUDE_DIR AND OCTOMAP_LIBRARY AND OCTOMATH_LIBRARY AND OCTOMAP_VERSION) +- set(OCTOMAP_INCLUDE_DIRS "${OCTOMAP_INCLUDE_DIR}") +- set(OCTOMAP_LIBRARIES "${OCTOMAP_LIBRARY}" "${OCTOMATH_LIBRARY}") +- set(octomap_FOUND ON) +- +- mark_as_advanced(OCTOMAP_INCLUDE_DIR OCTOMAP_LIBRARY OCTOMATH_LIBRARY OCTOMAP_VERSION) +- else() +- set(octomap_FOUND OFF) +- endif() +- endif() +- +- if(octomap_FOUND) +- if(NOT OCTOMAP_MAJOR_VERSION AND NOT OCTOMAP_MINOR_VERSION AND NOT OCTOMAP_PATCH_VERSION) +- string(REPLACE "." ";" VERSION_LIST "${OCTOMAP_VERSION}") +- list(GET VERSION_LIST 0 OCTOMAP_MAJOR_VERSION) +- list(GET VERSION_LIST 1 OCTOMAP_MINOR_VERSION) +- list(GET VERSION_LIST 2 OCTOMAP_PATCH_VERSION) +- endif() +- +- set(FCL_HAVE_OCTOMAP 1) +- message(STATUS "FCL uses OctoMap") +- set(PKG_EXTERNAL_DEPS "${PKG_EXTERNAL_DEPS} octomap") +- else() +- message(STATUS "FCL does not use OctoMap") +- endif() +-else() +- message(STATUS "FCL does not use OctoMap (as requested)") ++ set(FCL_HAVE_OCTOMAP 1) ++ message(STATUS "FCL uses OctoMap") ++ set(PKG_EXTERNAL_DEPS "${PKG_EXTERNAL_DEPS} octomap") + endif() + + if(TARGET ccd) +--- a/src/CMakeLists.txt ++++ b/src/CMakeLists.txt +@@ -77,36 +77,17 @@ endif() + + # Use the IMPORTED target from newer versions of ccd-config.cmake if available, + # otherwise fall back to CCD_INCLUDE_DIRS and CCD_LIBRARIES +-if(TARGET ccd) +- target_link_libraries(${PROJECT_NAME} PUBLIC ccd) +-else() +- target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${CCD_INCLUDE_DIRS}") +- target_link_libraries(${PROJECT_NAME} PUBLIC "${CCD_LIBRARIES}") +-endif() ++target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::libccd) + + # Use the IMPORTED target from newer versions of Eigen3Config.cmake if + # available, otherwise fall back to EIGEN3_INCLUDE_DIRS from older versions of + # Eigen3Config.cmake or EIGEN3_INCLUDE_DIR from FindEigen3.cmake +-if(TARGET Eigen3::Eigen) +- # Note that Eigen3::Eigen is an INTERFACE library, so the INCLUDE_DIRECTORIES +- # and INTERFACE_INCLUDE_DIRECTORIES are populated, but nothing is actually +- # linked +- target_link_libraries(${PROJECT_NAME} PUBLIC Eigen3::Eigen) +-elseif(EIGEN3_INCLUDE_DIRS) +- target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${EIGEN3_INCLUDE_DIRS}") +-else() +- target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${EIGEN3_INCLUDE_DIR}") +-endif() ++target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::eigen) + + if(FCL_HAVE_OCTOMAP) + # Use the IMPORTED target from newer versions of octomap-config.cmake if + # available, otherwise fall back to OCTOMAP_INCLUDE_DIRS and OCTOMAP_LIBRARIES +- if(TARGET octomap) +- target_link_libraries(${PROJECT_NAME} PUBLIC octomap) +- elseif(OCTOMAP_INCLUDE_DIRS AND OCTOMAP_LIBRARIES) +- target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "${OCTOMAP_INCLUDE_DIRS}") +- target_link_libraries(${PROJECT_NAME} PUBLIC "${OCTOMAP_LIBRARIES}") +- endif() ++ target_link_libraries(${PROJECT_NAME} PUBLIC CONAN_PKG::octomap) + endif() + + target_include_directories(${PROJECT_NAME} INTERFACE diff --git a/recipes/fcl/all/patches/fix-alias-type-msvc2015.patch b/recipes/fcl/all/patches/fix-alias-type-msvc2015.patch new file mode 100644 index 0000000000000..339514f4a1b95 --- /dev/null +++ b/recipes/fcl/all/patches/fix-alias-type-msvc2015.patch @@ -0,0 +1,47 @@ +--- a/include/fcl/geometry/octree/octree-inl.h ++++ b/include/fcl/geometry/octree/octree-inl.h +@@ -107,7 +107,7 @@ typename OcTree::OcTreeNode* OcTree::getRoot() const + + //============================================================================== + template +-bool OcTree::isNodeOccupied(const OcTree::OcTreeNode* node) const ++bool OcTree::isNodeOccupied(const typename OcTree::OcTreeNode* node) const + { + // return tree->isNodeOccupied(node); + return node->getOccupancy() >= occupancy_threshold; +@@ -115,7 +115,7 @@ bool OcTree::isNodeOccupied(const OcTree::OcTreeNode* node) const + + //============================================================================== + template +-bool OcTree::isNodeFree(const OcTree::OcTreeNode* node) const ++bool OcTree::isNodeFree(const typename OcTree::OcTreeNode* node) const + { + // return false; // default no definitely free node + return node->getOccupancy() <= free_threshold; +@@ -123,7 +123,7 @@ bool OcTree::isNodeFree(const OcTree::OcTreeNode* node) const + + //============================================================================== + template +-bool OcTree::isNodeUncertain(const OcTree::OcTreeNode* node) const ++bool OcTree::isNodeUncertain(const typename OcTree::OcTreeNode* node) const + { + return (!isNodeOccupied(node)) && (!isNodeFree(node)); + } +@@ -197,7 +197,7 @@ const typename OcTree::OcTreeNode* OcTree::getNodeChild( + //============================================================================== + template + bool OcTree::nodeChildExists( +- const OcTree::OcTreeNode* node, unsigned int childIdx) const ++ const typename OcTree::OcTreeNode* node, unsigned int childIdx) const + { + #if OCTOMAP_VERSION_AT_LEAST(1,8,0) + return tree->nodeChildExists(node, childIdx); +@@ -208,7 +208,7 @@ bool OcTree::nodeChildExists( + + //============================================================================== + template +-bool OcTree::nodeHasChildren(const OcTree::OcTreeNode* node) const ++bool OcTree::nodeHasChildren(const typename OcTree::OcTreeNode* node) const + { + #if OCTOMAP_VERSION_AT_LEAST(1,8,0) + return tree->nodeHasChildren(node); diff --git a/recipes/fcl/all/patches/fix-mingw-bigobj.patch b/recipes/fcl/all/patches/fix-mingw-bigobj.patch new file mode 100644 index 0000000000000..d50db01fa43b5 --- /dev/null +++ b/recipes/fcl/all/patches/fix-mingw-bigobj.patch @@ -0,0 +1,17 @@ +--- a/CMakeModules/CompilerSettings.cmake ++++ b/CMakeModules/CompilerSettings.cmake +@@ -104,11 +104,13 @@ endif() + + # MinGW + if((CMAKE_COMPILER_IS_GNUCXX OR IS_ICPC) AND NOT MINGW) +- add_definitions(-fPIC) + if(FCL_TREAT_WARNINGS_AS_ERRORS) + add_definitions(-Werror) + endif() + endif() ++if(MINGW) ++ add_definitions(-Wa,-mbig-obj) ++endif() + + # By default CMake sets RPATH for binaries in the build tree, but clears + # it when installing. Switch this option off if the default behaviour is diff --git a/recipes/fcl/all/test_package/CMakeLists.txt b/recipes/fcl/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e3410dbe322b9 --- /dev/null +++ b/recipes/fcl/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 2.8.11) +project(test_package) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/fcl/all/test_package/conanfile.py b/recipes/fcl/all/test_package/conanfile.py new file mode 100644 index 0000000000000..ea57a464900be --- /dev/null +++ b/recipes/fcl/all/test_package/conanfile.py @@ -0,0 +1,17 @@ +import os + +from conans import ConanFile, CMake, tools + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "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", "test_package") + self.run(bin_path, run_environment=True) diff --git a/recipes/fcl/all/test_package/test_package.cpp b/recipes/fcl/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..0f0651d6aa60c --- /dev/null +++ b/recipes/fcl/all/test_package/test_package.cpp @@ -0,0 +1,78 @@ +/* +From test_broadphase_dynamic_AABB_tree.cpp test in FCL test directory +*/ + +#include "fcl/common/types.h" +#include "fcl/geometry/shape/sphere.h" +#include "fcl/broadphase/broadphase_dynamic_AABB_tree.h" + +#include +#include + +int main() { + auto sphere0 = std::make_shared(0.1); + auto sphere1 = std::make_shared(0.2); + fcl::CollisionObjectd object0(sphere0); + fcl::CollisionObjectd object1(sphere1); + const fcl::Vector3d position0(0.1, 0.2, 0.3); + const fcl::Vector3d position1(0.11, 0.21, 0.31); + + // We will use `objects` to check the order of the two collision objects in + // our callback function. + // + // We use std::vector that contains *pointers* to CollisionObjectd, + // instead of std::vector that contains CollisionObjectd's. + // Previously we used std::vector, and it failed the + // Eigen alignment assertion on Win32. We also tried, without success, the + // custom allocator: + // std::vector>, + // but some platforms failed to build. + std::vector objects = {&object0, &object1}; + std::vector positions = {&position0, &position1}; + + fcl::DynamicAABBTreeCollisionManager dynamic_tree; + for (int i = 0; i < static_cast(objects.size()); ++i) { + objects[i]->setTranslation(*positions[i]); + objects[i]->computeAABB(); + dynamic_tree.registerObject(objects[i]); + } + + // Pack the data for callback function. + struct CallBackData { + bool expect_object0_then_object1; + std::vector* objects; + } data; + data.expect_object0_then_object1 = false; + data.objects = &objects; + + // This callback function tests the order of the two collision objects from + // the dynamic tree against the `data`. We assume that the first two + // parameters are always objects[0] and objects[1] in two possible orders, + // so we can safely ignore the second parameter. We do not use the last + // double& parameter, which specifies the distance beyond which the + // pair of objects will be skipped. + auto distance_callback = [](fcl::CollisionObjectd* a, fcl::CollisionObjectd*, + void* callback_data, double&) -> bool { + // Unpack the data. + auto data = static_cast(callback_data); + const std::vector& objects = *(data->objects); + const bool object0_first = a == objects[0]; + // EXPECT_EQ(data->expect_object0_then_object1, object0_first); + // TODO(DamrongGuoy): Remove the statement below when we solve the + // repeatability problem as mentioned in: + // https://github.com/flexible-collision-library/fcl/issues/368 + // Expect to switch the order next time. + data->expect_object0_then_object1 = !data->expect_object0_then_object1; + // Return true to stop the tree traversal. + return true; + }; + // We repeat update() and distance() many times. Each time, in the + // callback function, we check the order of the two objects. + for (int count = 0; count < 8; ++count) { + dynamic_tree.update(); + dynamic_tree.distance(&data, distance_callback); + } + + return 0; +} diff --git a/recipes/fcl/config.yml b/recipes/fcl/config.yml new file mode 100644 index 0000000000000..b0963ca9332e2 --- /dev/null +++ b/recipes/fcl/config.yml @@ -0,0 +1,3 @@ +versions: + "0.6.1": + folder: all