-
Notifications
You must be signed in to change notification settings - Fork 2k
stella-cv-fbow: new recipe #23889
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
Merged
Merged
stella-cv-fbow: new recipe #23889
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5da6ee3
stella-cv-fbow: new recipe
valgur 15f1e44
stella-cv-fbow: more accurate handling of OpenCV deps
valgur 9f0fbf6
stella-cv-fbow: SIMD options are not available for MSVC
valgur 76ad052
stella-cv-fbow: update
valgur 273425e
stella-cv-fbow: let Conan set the C++ standard
valgur f26c1a8
Fix error in test_package/CMakeLists.txt
valgur 1ee9bd1
Print fbow output on test_package avoiding possible compiler optimiza…
perseoGI File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"cci.20240508": | ||
url: "https://github.com/stella-cv/FBoW/archive/c6e3c29e3332a0b0834021797e2aa4e8eb66a3c1.zip" | ||
sha256: "23d866d86eaca6a85da8fe3e542b94324d5f6be4b37691cf82cd74a6cfd838bd" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import os | ||
|
||
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, replace_in_file | ||
|
||
required_conan_version = ">=1.53.0" | ||
|
||
|
||
class StellaCvFbowConan(ConanFile): | ||
name = "stella-cv-fbow" | ||
description = "FBoW (Fast Bag of Words) is an extremely optimized version of the DBoW2/DBoW3 libraries." | ||
license = "MIT" | ||
url = "https://github.com/conan-io/conan-center-index" | ||
homepage = "https://github.com/stella-cv/FBoW" | ||
topics = ("bag-of-words", "computer-vision", "visual-slam", "dbow") | ||
|
||
package_type = "library" | ||
settings = "os", "arch", "compiler", "build_type" | ||
options = { | ||
"shared": [True, False], | ||
"fPIC": [True, False], | ||
"fast_math": [True, False], | ||
"avx": [True, False], | ||
"mmx": [True, False], | ||
"sse": [True, False], | ||
"sse2": [True, False], | ||
"sse3": [True, False], | ||
"sse4": [True, False], | ||
} | ||
default_options = { | ||
"shared": False, | ||
"fPIC": True, | ||
"fast_math": True, | ||
"avx": True, | ||
"mmx": True, | ||
"sse": True, | ||
"sse2": True, | ||
"sse3": True, | ||
"sse4": True, | ||
} | ||
|
||
def config_options(self): | ||
if self.settings.os == "Windows": | ||
del self.options.fPIC | ||
if self.settings.arch not in ["x86", "x86_64"] or self.settings.compiler not in ["gcc", "clang", "apple-clang"]: | ||
del self.options.avx | ||
del self.options.mmx | ||
del self.options.sse | ||
del self.options.sse2 | ||
del self.options.sse3 | ||
del self.options.sse4 | ||
|
||
def configure(self): | ||
if self.options.shared: | ||
self.options.rm_safe("fPIC") | ||
|
||
def layout(self): | ||
cmake_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
# https://github.com/stella-cv/FBoW/blob/master/include/fbow/vocabulary.h#L35 | ||
self.requires("opencv/4.9.0", transitive_headers=True, transitive_libs=True) | ||
self.requires("llvm-openmp/17.0.6") | ||
|
||
def validate(self): | ||
if self.settings.compiler.cppstd: | ||
check_min_cppstd(self, 11) | ||
|
||
def source(self): | ||
get(self, **self.conan_data["sources"][self.version], strip_root=True) | ||
|
||
def generate(self): | ||
tc = CMakeToolchain(self) | ||
tc.variables["USE_FAST_MATH"] = self.options.fast_math | ||
tc.variables["USE_AVX"] = self.options.get_safe("avx", False) | ||
tc.variables["USE_MMX"] = self.options.get_safe("mmx", False) | ||
tc.variables["USE_SSE"] = self.options.get_safe("sse", False) | ||
tc.variables["USE_SSE2"] = self.options.get_safe("sse2", False) | ||
tc.variables["USE_SSE3"] = self.options.get_safe("sse3", False) | ||
tc.variables["USE_SSE4"] = self.options.get_safe("sse4", False) | ||
tc.variables["BUILD_UTILS"] = False | ||
tc.variables["BUILD_TESTS"] = False | ||
tc.variables["USE_CONTRIB"] = self.dependencies["opencv"].options.xfeatures2d | ||
tc.generate() | ||
|
||
tc = CMakeDeps(self) | ||
tc.generate() | ||
|
||
def _patch_sources(self): | ||
# Let Conan set the C++ standard | ||
if self.settings.compiler.cppstd: | ||
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), | ||
"set(CMAKE_CXX_STANDARD 11)", "") | ||
|
||
def build(self): | ||
self._patch_sources() | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def package(self): | ||
copy(self, "LICENSE", self.source_folder, os.path.join(self.package_folder, "licenses")) | ||
cmake = CMake(self) | ||
cmake.install() | ||
rmdir(self, os.path.join(self.package_folder, "share")) | ||
rm(self, "*.pdb", self.package_folder, recursive=True) | ||
|
||
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"]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
project(test_package LANGUAGES C) | ||
project(test_package LANGUAGES CXX) | ||
valgur marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
find_package(fbow REQUIRED CONFIG) | ||
|
||
add_executable(${PROJECT_NAME} test_package.cpp) | ||
target_link_libraries(${PROJECT_NAME} PRIVATE fbow::fbow) | ||
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
class TestPackageConan(ConanFile): | ||
settings = "os", "arch", "compiler", "build_type" | ||
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" | ||
test_type = "explicit" | ||
|
||
def requirements(self): | ||
self.requires(self.tested_reference_str) | ||
|
||
def layout(self): | ||
cmake_layout(self) | ||
|
||
def build(self): | ||
cmake = CMake(self) | ||
cmake.configure() | ||
cmake.build() | ||
|
||
def test(self): | ||
if can_run(self): | ||
bin_path = os.path.join(self.cpp.build.bindir, "test_package") | ||
self.run(bin_path, env="conanrun") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include <fbow/fbow.h> | ||
|
||
int main() { | ||
fbow::cpu().detect_host(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"cci.20240508": | ||
folder: all |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.