Skip to content

Commit

Permalink
stella-cv-fbow: more accurate handling of OpenCV deps
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed May 7, 2024
1 parent 5da6ee3 commit 0987413
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
5 changes: 5 additions & 0 deletions recipes/stella-cv-fbow/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
14 changes: 12 additions & 2 deletions recipes/stella-cv-fbow/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -82,14 +85,15 @@ 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()

tc = CMakeDeps(self)
tc.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()
Expand All @@ -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"])
Original file line number Diff line number Diff line change
@@ -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
+ "$<$<BOOL:${USE_CONTRIB}>:opencv_xfeatures2d>>"
+)

# ------------------------------------------------------
# PROJECT CONFIGURATION

0 comments on commit 0987413

Please sign in to comment.