Skip to content

Commit

Permalink
(#23235) new library: Vigra
Browse files Browse the repository at this point in the history
* start skeleton data for vigra

* start on conanfile for vigra

* now seems to build locally

* fix yaml lint error

* remove trailing line in yaml

* add option for LEMON

* silence some lint errors

* fix linter error on cmake

* remove override stuff

* fix url to point to CCI

* fix test to actually display impex formats

* some fixes

* more fixes

* Update recipes/vigra/all/test_package/conanfile.py

* add min cppstd, improve test package

* add imath requirement

* fix folder

* propagate definition to consumers

* clean

* Update recipes/vigra/all/conanfile.py

Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>

* add windows system_libs

* fix relocatable libs

---------

Co-authored-by: czoido <mrgalleta@gmail.com>
Co-authored-by: Rubén Rincón Blanco <git@rinconblanco.es>
  • Loading branch information
3 people authored Jun 17, 2024
1 parent 4e5bf6e commit 5e5100c
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 0 deletions.
9 changes: 9 additions & 0 deletions recipes/vigra/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
sources:
"1.11.2":
url: "https://github.com/ukoethe/vigra/archive/refs/tags/Version-1-11-2.tar.gz"
sha256: "4841936f5c3c137611ec782e293d961df29d3b5b70ade8cb711374de0f4cb5d3"
patches:
"1.11.2":
- patch_file: "patches/1.11.2-001-disable_doc_build.patch"
patch_description: "enable build to proceed when documentation is disabled"
patch_type: "conan"
123 changes: 123 additions & 0 deletions recipes/vigra/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import os
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMakeDeps, CMakeToolchain, CMake, cmake_layout
from conan.tools.files import get, export_conandata_patches, apply_conandata_patches, rm, copy, replace_in_file


class VigraConan(ConanFile):
name = "vigra"
description = "A generic C++ library for image analysis"
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "http://ukoethe.github.io/vigra/"
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
topics = "image-processing", "computer-vision"

options = {
"shared": [True, False],
"fPIC": [True, False],
"with_hdf5": [True, False],
"with_openexr": [True, False],
"with_boost_graph": [True, False],
"with_lemon": [True, False],
}

default_options = {
"shared": False,
"fPIC": True,
"with_hdf5": True,
"with_openexr": True,
"with_boost_graph": True,
"with_lemon": True,
}

def export_sources(self):
export_conandata_patches(self)

def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)

apply_conandata_patches(self)
replace_in_file(
self,
os.path.join(self.source_folder, "src", "impex", "CMakeLists.txt"),
'SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}"',
'SOVERSION ${SOVERSION} INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" INSTALL_NAME_DIR "@rpath"'
)

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

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 requirements(self):
self.requires("libtiff/4.6.0")
self.requires("libpng/[>=1.6 <2]")
self.requires("fftw/3.3.10")
self.requires("zlib/[>=1.2.11 <2]")
self.requires("libjpeg/9e")

if self.options.with_hdf5:
self.requires("hdf5/1.14.3")

if self.options.with_openexr:
self.requires("openexr/3.2.4")
self.requires("imath/3.1.9")

if self.options.with_boost_graph:
self.requires("boost/1.85.0")

if self.options.with_lemon:
self.requires("coin-lemon/1.3.1")

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, 11)

def generate(self):
tc = CMakeToolchain(self)
tc.cache_variables["WITH_VIGRANUMPY"] = False
tc.cache_variables["BUILD_DOCS"] = False
tc.cache_variables["BUILD_TESTS"] = False

tc.cache_variables["WITH_OPENEXR"] = self.options.with_openexr
tc.cache_variables["WITH_BOOST_GRAPH"] = self.options.with_boost_graph
tc.cache_variables["WITH_LEMON"] = self.options.with_lemon

tc.cache_variables["VIGRA_STATIC_LIB"] = not self.options.shared
tc.generate()

deps = CMakeDeps(self)
deps.generate()

def build(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"))
cm = CMake(self)
cm.install()
rm(self, "*.cmake", self.package_folder, recursive=True)
#fix_apple_shared_install_name(self)

def package_info(self):
if not self.options.shared:
self.cpp_info.defines = ["VIGRA_STATIC_LIB"]

self.cpp_info.libs = ["vigraimpex"]
self.cpp_info.set_property("cmake_file_name", "Vigra")
self.cpp_info.set_property("cmake_target_name", "vigraimpex")

if self.settings.os == "Windows":
self.cpp_info.system_libs.append("shlwapi")
13 changes: 13 additions & 0 deletions recipes/vigra/all/patches/1.11.2-001-disable_doc_build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -341,7 +341,7 @@ add_custom_target(PACKAGE_SRC_TAR
COMMENT "Creating ${PROJECT_BINARY_DIR}/vigra-${vigra_version}-src.tar.gz")

ADD_DEPENDENCIES(PACKAGE_SRC_TAR check)
-ADD_DEPENDENCIES(PACKAGE_SRC_TAR doc_cpp)
+#ADD_DEPENDENCIES(PACKAGE_SRC_TAR doc_cpp)
IF(WITH_VIGRANUMPY AND PYTHON_SPHINX)
ADD_DEPENDENCIES(PACKAGE_SRC_TAR doc_python)
ENDIF()
8 changes: 8 additions & 0 deletions recipes/vigra/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(Vigra REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE vigraimpex)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
25 changes: 25 additions & 0 deletions recipes/vigra/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"

def layout(self):
cmake_layout(self)

def requirements(self):
self.requires(self.tested_reference_str)

def build(self):
cm = CMake(self)
cm.configure()
cm.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")
18 changes: 18 additions & 0 deletions recipes/vigra/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include <vigra/tinyvector.hxx>
#include <vigra/impex.hxx>
#include <iostream>

using std::cout;
using std::endl;

using namespace vigra;

int main()
{
cout << "creating a fixed size vigra array.." << endl;

vigra::TinyVector<double, 5> arr = {1.1, 2.2, 3.3, 4.4, 5.5};

cout << "formats supported: " << endl;
cout << impexListFormats() << endl;
}
3 changes: 3 additions & 0 deletions recipes/vigra/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.11.2":
folder: all

0 comments on commit 5e5100c

Please sign in to comment.