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

vilib: new recipe #23743

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
9 changes: 9 additions & 0 deletions recipes/vilib/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sources:
"cci.20210625":
url: "https://github.com/uzh-rpg/vilib/archive/7a12fe1db78ca755876469979394076f10fe577c.zip"
sha256: "431e19fdb85ed99b5508b7409699ea30ea121578e660116351a57d71474bf01a"
patches:
"cci.20210625":
- patch_file: "patches/001-fix-opencv-linked-libs.patch"
patch_type: "bugfix"

Check warning on line 8 in recipes/vilib/all/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

'patch_type' should have 'patch_source' as per https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patch_type it is expected to have a source (e.g. a URL) to where it originates from to help with reviewing and consumers to evaluate patches
patch_description: "Add missing required OpenCV linked libraries"
100 changes: 100 additions & 0 deletions recipes/vilib/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
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, rmdir, rm, export_conandata_patches, apply_conandata_patches
from conans.errors import ConanInvalidConfiguration

Check failure on line 7 in recipes/vilib/all/conanfile.py

View workflow job for this annotation

GitHub Actions / Lint changed conanfile.py (v2 migration)

Import ConanInvalidConfiguration from new module: `from conan.errors import ConanInvalidConfiguration`. Old import is deprecated in Conan v2.

required_conan_version = ">=1.53.0"


class VilibConan(ConanFile):
name = "vilib"
description = "CUDA Visual Library by RPG. GPU-Accelerated Frontend for High-Speed VIO."
license = "BSD-3-Clause"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/uzh-rpg/vilib"
topics = ("computer-vision", "visual-odometry", "visual-features", "cuda")

package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}

def export_sources(self):
export_conandata_patches(self)
copy(self, "*.cmake", self.recipe_folder, self.export_sources_folder)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
self.requires("eigen/3.4.0", transitive_headers=True)
self.requires("opencv/4.9.0", transitive_headers=True, transitive_libs=True)

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, 11)
if self.settings.os == "Windows" and self.options.shared:
raise ConanInvalidConfiguration("Shared builds on Windows are not supported")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)
rmdir(self, "assets")
rmdir(self, "ros")
rmdir(self, os.path.join("visual_lib", "test"))

def generate(self):
tc = CMakeToolchain(self)
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()

def package(self):
copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rm(self, "*.pdb", self.package_folder, recursive=True)
copy(self, "vilib-cuda-dep.cmake", self.export_sources_folder, os.path.join(self.package_folder, "lib", "cmake", "vilib"))

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "vilib")
self.cpp_info.set_property("cmake_target_name", "vilib::vilib")

self.cpp_info.builddirs.append(os.path.join("lib", "cmake", "vilib"))
self.cpp_info.set_property("cmake_build_modules", [os.path.join("lib", "cmake", "vilib", "vilib-cuda-dep.cmake")])

self.cpp_info.libs = ["vilib"]
self.cpp_info.requires = [
"eigen::eigen",
"opencv::opencv_core",
"opencv::opencv_imgproc",
"opencv::opencv_features2d",
"opencv::opencv_highgui",
]

if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.extend(["pthread", "dl", "m", "rt"])
20 changes: 20 additions & 0 deletions recipes/vilib/all/patches/001-fix-opencv-linked-libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -56,7 +56,7 @@
endif()


-find_package(OpenCV REQUIRED COMPONENTS core)
+find_package(OpenCV REQUIRED COMPONENTS core imgproc features2d highgui)
find_package(Eigen3 REQUIRED)

option(BUILD_SHARED_LIBS "build shared libraries" ON)
@@ -102,7 +102,7 @@
)

target_link_libraries(vilib PUBLIC
- opencv_core Eigen3::Eigen ${CUDA_LIBRARIES})
+ opencv_core opencv_imgproc opencv_features2d opencv_highgui Eigen3::Eigen ${CUDA_LIBRARIES})

# Set different compiler options for cxx and nvcc

8 changes: 8 additions & 0 deletions recipes/vilib/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.15)
project(test_package LANGUAGES CXX)

find_package(vilib REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE vilib::vilib)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
26 changes: 26 additions & 0 deletions recipes/vilib/all/test_package/conanfile.py
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")
23 changes: 23 additions & 0 deletions recipes/vilib/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <vilib/feature_detection/fast/fast_common.h>
#include <vilib/feature_detection/fast/fast_gpu.h>

using namespace vilib;

#define PYRAMID_LEVELS 1
#define PYRAMID_MIN_LEVEL 0
#define PYRAMID_MAX_LEVEL PYRAMID_LEVELS
#define FAST_EPSILON 10.0f
#define FAST_MIN_ARC_LENGTH 10
#define FAST_SCORE SUM_OF_ABS_DIFF_ON_ARC
#define HORIZONTAL_BORDER 0
#define VERTICAL_BORDER 0
#define CELL_SIZE_WIDTH 32
#define CELL_SIZE_HEIGHT 32

int main() {
int width = 512;
int height = 512;
FASTGPU(width, height, CELL_SIZE_WIDTH, CELL_SIZE_HEIGHT, PYRAMID_MIN_LEVEL,
PYRAMID_MAX_LEVEL, HORIZONTAL_BORDER, VERTICAL_BORDER, FAST_EPSILON,
FAST_MIN_ARC_LENGTH, FAST_SCORE);
}
4 changes: 4 additions & 0 deletions recipes/vilib/all/vilib-cuda-dep.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

find_dependency(CUDAToolkit REQUIRED)

set_property(TARGET ${${CMAKE_FIND_PACKAGE_NAME}_LIBRARIES} PROPERTY INTERFACE_LINK_LIBRARIES CUDA::cudart APPEND)
3 changes: 3 additions & 0 deletions recipes/vilib/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"cci.20210625":
folder: all
Loading