From 0987413588684a4a4d7e5a4ef7815a23bd51ff20 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 7 May 2024 10:29:32 +0300 Subject: [PATCH] stella-cv-fbow: more accurate handling of OpenCV deps --- recipes/stella-cv-fbow/all/conandata.yml | 5 +++++ recipes/stella-cv-fbow/all/conanfile.py | 14 ++++++++++++-- .../patches/001-avoid-opencv-overlinking.patch | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 recipes/stella-cv-fbow/all/patches/001-avoid-opencv-overlinking.patch diff --git a/recipes/stella-cv-fbow/all/conandata.yml b/recipes/stella-cv-fbow/all/conandata.yml index 6641b47ea900ff..3c8aca70311368 100644 --- a/recipes/stella-cv-fbow/all/conandata.yml +++ b/recipes/stella-cv-fbow/all/conandata.yml @@ -2,3 +2,8 @@ sources: "cci.20240107": url: "https://github.com/stella-cv/FBoW/archive/c925ef9d444c39d2967791b8c08bf3dfda9c4e1c.zip" sha256: "6f91982b049e0e297f9621b221d9a02eb389cf401ca3620730a19a2c20fff5a4" +patches: + "cci.20240107": + - patch_file: "patches/001-avoid-opencv-overlinking.patch" + patch_description: "Avoid overlinking of OpenCV libraries" + patch_type: "conan" diff --git a/recipes/stella-cv-fbow/all/conanfile.py b/recipes/stella-cv-fbow/all/conanfile.py index 23e73c27b1dc00..0eab558ee517fa 100644 --- a/recipes/stella-cv-fbow/all/conanfile.py +++ b/recipes/stella-cv-fbow/all/conanfile.py @@ -3,7 +3,7 @@ from conan import ConanFile from conan.tools.build import check_min_cppstd from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.files import copy, get, rm, rmdir +from conan.tools.files import copy, get, rm, rmdir, export_conandata_patches, apply_conandata_patches required_conan_version = ">=1.53.0" @@ -41,6 +41,9 @@ class StellaCvFbowConan(ConanFile): "sse4": True, } + def export_sources(self): + export_conandata_patches(self) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -82,7 +85,7 @@ def generate(self): tc.variables["USE_SSE4"] = self.options.get_safe("sse4", False) tc.variables["BUILD_UTILS"] = False tc.variables["BUILD_TESTS"] = False - tc.variables["USE_CONTRIB"] = True + tc.variables["USE_CONTRIB"] = self.dependencies["opencv"].options.xfeatures2d tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" tc.generate() @@ -90,6 +93,7 @@ def generate(self): tc.generate() def build(self): + apply_conandata_patches(self) cmake = CMake(self) cmake.configure() cmake.build() @@ -104,12 +108,18 @@ def package(self): def package_info(self): self.cpp_info.set_property("cmake_file_name", "fbow") self.cpp_info.set_property("cmake_target_name", "fbow::fbow") + # unofficial + self.cpp_info.set_property("pkg_config_name", "fbow") self.cpp_info.libs = ["fbow"] self.cpp_info.requires = [ "opencv::opencv_core", + "opencv::opencv_features2d", + "opencv::opencv_highgui", "llvm-openmp::llvm-openmp", ] + if self.dependencies["opencv"].options.xfeatures2d: + self.cpp_info.requires.append("opencv::opencv_xfeatures2d") if self.settings.os in ["Linux", "FreeBSD"]: self.cpp_info.system_libs.extend(["m", "pthread"]) diff --git a/recipes/stella-cv-fbow/all/patches/001-avoid-opencv-overlinking.patch b/recipes/stella-cv-fbow/all/patches/001-avoid-opencv-overlinking.patch new file mode 100644 index 00000000000000..3ee56a8258359a --- /dev/null +++ b/recipes/stella-cv-fbow/all/patches/001-avoid-opencv-overlinking.patch @@ -0,0 +1,16 @@ +--- CMakeLists.txt ++++ CMakeLists.txt +@@ -95,7 +95,12 @@ + add_definitions(-DUSE_CONTRIB) + endif() + +-set(REQUIRED_LIBRARIES "${OpenCV_LIBS}") ++set(REQUIRED_LIBRARIES ++ opencv_core ++ opencv_features2d ++ opencv_highgui ++ "$<$:opencv_xfeatures2d>>" ++) + + # ------------------------------------------------------ + # PROJECT CONFIGURATION