diff --git a/recipes/vigra/all/conandata.yml b/recipes/vigra/all/conandata.yml new file mode 100644 index 0000000000000..1d74fa25b7f22 --- /dev/null +++ b/recipes/vigra/all/conandata.yml @@ -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" diff --git a/recipes/vigra/all/conanfile.py b/recipes/vigra/all/conanfile.py new file mode 100644 index 0000000000000..0ac9a204a6384 --- /dev/null +++ b/recipes/vigra/all/conanfile.py @@ -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") diff --git a/recipes/vigra/all/patches/1.11.2-001-disable_doc_build.patch b/recipes/vigra/all/patches/1.11.2-001-disable_doc_build.patch new file mode 100644 index 0000000000000..322479285c3dd --- /dev/null +++ b/recipes/vigra/all/patches/1.11.2-001-disable_doc_build.patch @@ -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() diff --git a/recipes/vigra/all/test_package/CMakeLists.txt b/recipes/vigra/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..8063e47f90875 --- /dev/null +++ b/recipes/vigra/all/test_package/CMakeLists.txt @@ -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) diff --git a/recipes/vigra/all/test_package/conanfile.py b/recipes/vigra/all/test_package/conanfile.py new file mode 100644 index 0000000000000..4385dcaa88926 --- /dev/null +++ b/recipes/vigra/all/test_package/conanfile.py @@ -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") diff --git a/recipes/vigra/all/test_package/test_package.cpp b/recipes/vigra/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..84b2dc0869089 --- /dev/null +++ b/recipes/vigra/all/test_package/test_package.cpp @@ -0,0 +1,18 @@ +#include +#include +#include + +using std::cout; +using std::endl; + +using namespace vigra; + +int main() +{ + cout << "creating a fixed size vigra array.." << endl; + + vigra::TinyVector arr = {1.1, 2.2, 3.3, 4.4, 5.5}; + + cout << "formats supported: " << endl; + cout << impexListFormats() << endl; +} diff --git a/recipes/vigra/config.yml b/recipes/vigra/config.yml new file mode 100644 index 0000000000000..68804c58d126a --- /dev/null +++ b/recipes/vigra/config.yml @@ -0,0 +1,3 @@ +versions: + "1.11.2": + folder: all