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

fcl: modernize + simplify cmake patch #8873

Merged
merged 5 commits into from
Jan 25, 2022
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: 11 additions & 6 deletions recipes/fcl/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
sources:
"0.6.1":
url: "https://github.com/flexible-collision-library/fcl/archive/v0.6.1.tar.gz"
sha256: "c8a68de8d35a4a5cd563411e7577c0dc2c626aba1eef288cb1ca88561f8d8019"
"0.7.0":
url: "https://github.com/flexible-collision-library/fcl/archive/refs/tags/0.7.0.tar.gz"
sha256: "90409e940b24045987506a6b239424a4222e2daf648c86dd146cbcb692ebdcbc"
"0.6.1":
url: "https://github.com/flexible-collision-library/fcl/archive/v0.6.1.tar.gz"
sha256: "c8a68de8d35a4a5cd563411e7577c0dc2c626aba1eef288cb1ca88561f8d8019"
patches:
"0.7.0":
- patch_file: "patches/0001-fix-cmake-0.7.0.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-fix-mingw-bigobj.patch"
base_path: "source_subfolder"
"0.6.1":
- patch_file: "patches/conanize-cmake-0.6.1.patch"
- patch_file: "patches/0001-fix-cmake-0.6.1.patch"
base_path: "source_subfolder"
- patch_file: "patches/fix-mingw-bigobj.patch"
- patch_file: "patches/0002-fix-mingw-bigobj.patch"
base_path: "source_subfolder"
- patch_file: "patches/fix-alias-type-msvc2015.patch"
- patch_file: "patches/0003-fix-alias-type-msvc2015.patch"
base_path: "source_subfolder"
57 changes: 32 additions & 25 deletions recipes/fcl/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
import os
import textwrap

required_conan_version = ">=1.33.0"
required_conan_version = ">=1.43.0"


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")
topics = ("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]
"with_octomap": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_octomap": True
"with_octomap": True,
}

generators = "cmake", "cmake_find_package_multi"
_cmake = None

@property
Expand All @@ -38,24 +38,32 @@ def _source_subfolder(self):
def _build_subfolder(self):
return "build_subfolder"

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])

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.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("eigen/3.3.9")
self.requires("eigen/3.4.0")
self.requires("libccd/2.1")
if self.options.with_octomap:
self.requires("octomap/1.9.6")
self.requires("octomap/1.9.7")

def validate(self):
if self.settings.compiler.get_safe("cppstd"):
tools.check_min_cppstd(self, 11)
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration(
"fcl {} doesn't properly support shared lib on Windows".format(self.version)
)

def source(self):
tools.get(**self.conan_data["sources"][self.version],
Expand All @@ -75,13 +83,14 @@ def _configure_cmake(self):
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_X64_SSE"] = False # Let consumer decide to add relevant compile options, fcl 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:
self._cmake.definitions["OCTOMAP_VERSION"] = self.deps_cpp_info["octomap"].version
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
Expand All @@ -98,6 +107,8 @@ def package(self):
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"))

# TODO: to remove in conan v2 once cmake_find_package* generators removed
self._create_cmake_module_alias_targets(
os.path.join(self.package_folder, self._module_file_rel_path),
{"fcl": "fcl::fcl"}
Expand All @@ -115,20 +126,16 @@ def _create_cmake_module_alias_targets(module_file, targets):
""".format(alias=alias, aliased=aliased))
tools.save(module_file, content)

@property
def _module_subfolder(self):
return os.path.join("lib", "cmake")

@property
def _module_file_rel_path(self):
return os.path.join(self._module_subfolder,
"conan-official-{}-targets.cmake".format(self.name))
return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name))

def package_info(self):
self.cpp_info.names["cmake_find_package"] = "fcl"
self.cpp_info.names["cmake_find_package_multi"] = "fcl"
self.cpp_info.builddirs.append(self._module_subfolder)
self.cpp_info.set_property("cmake_file_name", "fcl")
self.cpp_info.set_property("cmake_target_name", "fcl")
self.cpp_info.set_property("pkg_config_name", "fcl")
self.cpp_info.libs = ["fcl"]

# TODO: to remove in conan v2 once cmake_find_package* generators removed
self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
self.cpp_info.names["pkg_config"] = "fcl"
self.cpp_info.libs = tools.collect_libs(self)
22 changes: 22 additions & 0 deletions recipes/fcl/all/patches/0001-fix-cmake-0.6.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -72,7 +72,7 @@ if(MSVC OR MSVC90 OR MSVC10)
endif (MSVC OR MSVC90 OR MSVC10)

set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
include(CMakePackageConfigHelpers)
include(GenerateExportHeader)
include(GNUInstallDirs)
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -103,6 +103,8 @@ if(FCL_HAVE_OCTOMAP)
# available, otherwise fall back to OCTOMAP_INCLUDE_DIRS and OCTOMAP_LIBRARIES
if(TARGET octomap)
target_link_libraries(${PROJECT_NAME} PUBLIC octomap)
+ elseif(TARGET octomap-static)
+ target_link_libraries(${PROJECT_NAME} PUBLIC octomap-static)
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}")
22 changes: 22 additions & 0 deletions recipes/fcl/all/patches/0001-fix-cmake-0.7.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,7 +66,7 @@ if(MSVC OR MSVC90 OR MSVC10)
endif (MSVC OR MSVC90 OR MSVC10)

set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
-set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
include(CMakePackageConfigHelpers)
include(GenerateExportHeader)
include(GNUInstallDirs)
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -103,6 +103,8 @@ if(FCL_HAVE_OCTOMAP)
# available, otherwise fall back to OCTOMAP_INCLUDE_DIRS and OCTOMAP_LIBRARIES
if(TARGET octomap)
target_link_libraries(${PROJECT_NAME} PUBLIC octomap)
+ elseif(TARGET octomap-static)
+ target_link_libraries(${PROJECT_NAME} PUBLIC octomap-static)
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}")
169 changes: 0 additions & 169 deletions recipes/fcl/all/patches/conanize-cmake-0.6.1.patch

This file was deleted.

2 changes: 1 addition & 1 deletion recipes/fcl/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ def build(self):
cmake.build()

def test(self):
if not tools.cross_building(self.settings):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
4 changes: 2 additions & 2 deletions recipes/fcl/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
versions:
"0.6.1":
folder: all
"0.7.0":
folder: all
"0.6.1":
folder: all