-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
163 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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.20240107": | ||
url: "https://github.com/stella-cv/FBoW/archive/c925ef9d444c39d2967791b8c08bf3dfda9c4e1c.zip" | ||
sha256: "6f91982b049e0e297f9621b221d9a02eb389cf401ca3620730a19a2c20fff5a4" |
This file contains 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,115 @@ | ||
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 | ||
|
||
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"]: | ||
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"] = True | ||
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" | ||
tc.generate() | ||
|
||
tc = CMakeDeps(self) | ||
tc.generate() | ||
|
||
def build(self): | ||
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") | ||
|
||
self.cpp_info.libs = ["fbow"] | ||
self.cpp_info.requires = [ | ||
"opencv::opencv_core", | ||
"llvm-openmp::llvm-openmp", | ||
] | ||
|
||
if self.settings.os in ["Linux", "FreeBSD"]: | ||
self.cpp_info.system_libs.extend(["m", "pthread"]) |
This file contains 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) | ||
|
||
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 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,27 @@ | ||
from conan import ConanFile | ||
from conan.tools.build import can_run | ||
from conan.tools.cmake import cmake_layout, CMake | ||
import os | ||
|
||
|
||
# It will become the standard on Conan 2.x | ||
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 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 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.20240107": | ||
folder: all |