From ca1e8e4d403b38cc200a1c8ff7ad4ebb1515efbe Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 12 Jan 2024 19:14:30 +0200 Subject: [PATCH 01/16] cimg: configure `cimg_display` define, add Xorg dependency --- recipes/cimg/all/conanfile.py | 75 +++++++++++++------ .../cimg/all/test_package/test_package.cpp | 3 - 2 files changed, 52 insertions(+), 26 deletions(-) diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index b626bca664ae6..55b0e8ba079c7 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -26,6 +26,7 @@ class CImgConan(ConanFile): "enable_ffmpeg": [True, False], "enable_opencv": [True, False], "enable_magick": [True, False], + "enable_display": [True, False], "enable_xrandr": [True, False], "enable_xshm": [True, False], } @@ -38,6 +39,7 @@ class CImgConan(ConanFile): "enable_ffmpeg": False, "enable_opencv": False, "enable_magick": False, + "enable_display": False, "enable_xrandr": False, "enable_xshm": False, } @@ -46,18 +48,42 @@ class CImgConan(ConanFile): @property def _cimg_defines(self): - return [ - ("enable_fftw", "cimg_use_fftw"), - ("enable_jpeg", "cimg_use_jpeg"), + defines = [] + for option, define in [ + ("enable_fftw", "cimg_use_fftw"), + ("enable_jpeg", "cimg_use_jpeg"), ("enable_openexr", "cimg_use_openexr"), - ("enable_png", "cimg_use_png"), - ("enable_tiff", "cimg_use_tiff"), - ("enable_ffmpeg", "cimg_use_ffmpeg"), - ("enable_opencv", "cimg_use_opencv"), - ("enable_magick", "cimg_use_magick"), - ("enable_xrandr", "cimg_use_xrandr"), - ("enable_xshm", "cimg_use_xshm"), - ] + ("enable_png", "cimg_use_png"), + ("enable_tiff", "cimg_use_tiff"), + ("enable_ffmpeg", "cimg_use_ffmpeg"), + ("enable_opencv", "cimg_use_opencv"), + ("enable_magick", "cimg_use_magick"), + ("enable_xrandr", "cimg_use_xrandr"), + ("enable_xshm", "cimg_use_xshm"), + ]: + if getattr(self.options, option): + defines.append(define) + + if not self.options.get_safe("enable_display"): + # disable display capabilities + defines.append("cimg_display=0") + elif self.settings.os == "Windows": + # use the Microsoft GDI32 framework + defines.append("cimg_display=2") + else: + # use the X-Window framework (X11) + defines.append("cimg_display=1") + + return defines + + def config_options(self): + if self.settings.os not in ["Linux", "FreeBSD"]: + # Requires Xorg + del self.options.enable_xrandr + del self.options.enable_xshm + if self.settings.os not in ["Linux", "FreeBSD", "Windows"]: + # Must support either X11 or GDI32 + del self.options.enable_display def layout(self): basic_layout(self, src_folder="src") @@ -69,19 +95,22 @@ def requirements(self): self.requires("libjpeg/9e") if self.options.enable_openexr: self.requires("openexr/3.2.1") + self.requires("imath/3.1.9") if self.options.enable_png: self.requires("libpng/1.6.40") if self.options.enable_tiff: self.requires("libtiff/4.6.0") if self.options.enable_ffmpeg: if self.options.enable_opencv: - self.requires("ffmpeg/4.4") + self.requires("ffmpeg/4.4.4") else: - self.requires("ffmpeg/5.1") + self.requires("ffmpeg/6.1") if self.options.enable_opencv: - self.requires("opencv/4.5.5") + self.requires("opencv/4.8.1") if self.options.enable_magick: self.requires("imagemagick/7.0.11-14") + if self.options.enable_display and self.settings.os in ["Linux", "FreeBSD"]: + self.requires("xorg/system") def package_id(self): self.info.clear() @@ -89,11 +118,10 @@ def package_id(self): def validate(self): if self.settings.compiler.get_safe("cppstd"): check_min_cppstd(self, "11") - # TODO: Update requirements when available in CCI - if self.options.enable_xrandr: - raise ConanInvalidConfiguration("xrandr not available in CCI yet") - if self.options.enable_xshm: - raise ConanInvalidConfiguration("xshm not available in CCI yet") + + if not self.options.get_safe("enable_display"): + if self.options.enable_xrandr or self.options.enable_xshm: + raise ConanInvalidConfiguration("X11 options enable_xrandr and enable_xshm require enable_display=True") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -111,11 +139,12 @@ def package_info(self): self.cpp_info.set_property("pkg_config_name", "CImg") self.cpp_info.bindirs = [] self.cpp_info.libdirs = [] - for option, define in self._cimg_defines: - if getattr(self.options, option): - self.cpp_info.defines.append(define) + self.cpp_info.defines = self._cimg_defines + + if self.settings.os == "Windows" and self.options.enable_display: + self.cpp_info.system_libs.append("gdi32") # TODO: to remove in conan v2 once cmake_find_package* generators removed - # do not use this name in CMakeDeps, it was a mistake, there is no offical CMake config file + # do not use this name in CMakeDeps, it was a mistake, there is no official CMake config file self.cpp_info.names["cmake_find_package"] = "CImg" self.cpp_info.names["cmake_find_package_multi"] = "CImg" diff --git a/recipes/cimg/all/test_package/test_package.cpp b/recipes/cimg/all/test_package/test_package.cpp index 119c4760a1373..fb48d89f9880d 100644 --- a/recipes/cimg/all/test_package/test_package.cpp +++ b/recipes/cimg/all/test_package/test_package.cpp @@ -41,9 +41,6 @@ # */ -// Tell CImg not to use display capabilities. -#undef cimg_display -#define cimg_display 0 #include "CImg.h" using namespace cimg_library; From 7fafd9c8004c4a11ea072ab1eaa6a87461b49ab9 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 12 Jan 2024 19:44:08 +0200 Subject: [PATCH 02/16] cimg: enable dependencies in test_package --- recipes/cimg/all/test_package/conanfile.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/recipes/cimg/all/test_package/conanfile.py b/recipes/cimg/all/test_package/conanfile.py index 0a6bc68712d90..e7db77b969cb1 100644 --- a/recipes/cimg/all/test_package/conanfile.py +++ b/recipes/cimg/all/test_package/conanfile.py @@ -9,6 +9,19 @@ class TestPackageConan(ConanFile): generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv" test_type = "explicit" + def configure(self): + self.options["cimg"].enable_fftw = True + self.options["cimg"].enable_jpeg = True + self.options["cimg"].enable_openexr = True + self.options["cimg"].enable_png = True + self.options["cimg"].enable_tiff = True + self.options["cimg"].enable_ffmpeg = True + self.options["cimg"].enable_opencv = False # ffmpeg linking fails when enabled + self.options["cimg"].enable_magick = False # Not yet Conan 2.0 compatible + self.options["cimg"].enable_display = True + self.options["cimg"].enable_xrandr = True + self.options["cimg"].enable_xshm = True + def layout(self): cmake_layout(self) From 8f75fede662e83e1aea2bdf5c4f6d7e2d59482ec Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 10:58:36 +0200 Subject: [PATCH 03/16] cimg: fix fftw define --- recipes/cimg/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index 55b0e8ba079c7..4e0d15a4c727e 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -50,7 +50,7 @@ class CImgConan(ConanFile): def _cimg_defines(self): defines = [] for option, define in [ - ("enable_fftw", "cimg_use_fftw"), + ("enable_fftw", "cimg_use_fftw3"), ("enable_jpeg", "cimg_use_jpeg"), ("enable_openexr", "cimg_use_openexr"), ("enable_png", "cimg_use_png"), From 908d8b64ee2dcf090fbbd42361cefaa617cf5d15 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 11:00:59 +0200 Subject: [PATCH 04/16] cimg: add v3.3.3 --- recipes/cimg/all/conandata.yml | 3 +++ recipes/cimg/config.yml | 2 ++ 2 files changed, 5 insertions(+) diff --git a/recipes/cimg/all/conandata.yml b/recipes/cimg/all/conandata.yml index 96bd683acd199..2dec11891b7ba 100644 --- a/recipes/cimg/all/conandata.yml +++ b/recipes/cimg/all/conandata.yml @@ -1,4 +1,7 @@ sources: + "3.3.3": + url: "https://cimg.eu/files/CImg_3.3.3.zip" + sha256: "6853194cfe1229c946698a397c891a19f4d63240a419245c9b130ec7a67825b9" "3.3.2": url: "https://cimg.eu/files/CImg_3.3.2.zip" sha256: "d49ecd63b46f53ddcee5c7695ddb0fe8b07e033bb81b5ed075cfe352462c5f73" diff --git a/recipes/cimg/config.yml b/recipes/cimg/config.yml index 70cd903d901e9..54464b95b2527 100644 --- a/recipes/cimg/config.yml +++ b/recipes/cimg/config.yml @@ -1,4 +1,6 @@ versions: + "3.3.3": + folder: all "3.3.2": folder: all "3.3.0": From b80f07ac0e940a1ecdd455236e60b7b4b427d512 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 11:06:58 +0200 Subject: [PATCH 05/16] cimg: set cimg_use_fftw3_singlethread --- recipes/cimg/all/conanfile.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index 4e0d15a4c727e..5c7f2670a1c64 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -74,6 +74,10 @@ def _cimg_defines(self): # use the X-Window framework (X11) defines.append("cimg_display=1") + if self.options.enable_fftw: + if not self.dependencies["fftw"].options.threads: + defines.append("cimg_use_fftw3_singlethread") + return defines def config_options(self): From 6f548c9b1629e35bb3cef0b978e55e652e7364ea Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 11:18:42 +0200 Subject: [PATCH 06/16] cimg: expose all available options, add option descriptions --- recipes/cimg/all/conanfile.py | 104 ++++++++++++++++++--- recipes/cimg/all/test_package/conanfile.py | 13 ++- 2 files changed, 101 insertions(+), 16 deletions(-) diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index 5c7f2670a1c64..e15075810c12b 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -3,6 +3,8 @@ from conan.tools.build import check_min_cppstd from conan.tools.files import copy, get from conan.tools.layout import basic_layout +from conan.tools.microsoft import is_msvc +from conan.tools.scm import Version import os required_conan_version = ">=1.51.1" @@ -18,48 +20,88 @@ class CImgConan(ConanFile): package_type = "header-library" settings = "os", "arch", "compiler", "build_type" options = { + "enable_curl": [True, False], + "enable_display": [True, False], + "enable_ffmpeg": [True, False], "enable_fftw": [True, False], + "enable_heif": [True, False], "enable_jpeg": [True, False], + "enable_magick": [True, False], + "enable_opencv": [True, False], "enable_openexr": [True, False], + "enable_openmp": [True, False], "enable_png": [True, False], "enable_tiff": [True, False], - "enable_ffmpeg": [True, False], - "enable_opencv": [True, False], - "enable_magick": [True, False], - "enable_display": [True, False], + "enable_tinyexr": [True, False], "enable_xrandr": [True, False], "enable_xshm": [True, False], + "enable_zlib": [True, False], } default_options = { + "enable_curl": False, + "enable_display": False, + "enable_ffmpeg": False, "enable_fftw": False, + "enable_heif": False, "enable_jpeg": False, + "enable_magick": False, + "enable_opencv": False, "enable_openexr": False, + "enable_openmp": False, "enable_png": False, "enable_tiff": False, - "enable_ffmpeg": False, - "enable_opencv": False, - "enable_magick": False, - "enable_display": False, + "enable_tinyexr": False, "enable_xrandr": False, "enable_xshm": False, + "enable_zlib": False, + } + options_description = { + # "enable_board": "Support drawing of 3D objects in a vector-graphics canvas, using libboard", + "enable_curl": "Add support for downloading files from the network, using libcurl", + "enable_display": "Enable display capabilities of CImg, using either X11 or GDI32", + "enable_ffmpeg": "Add support for various video files, using the FFMPEG library", + "enable_fftw": "Enable faster Discrete Fourier Transform computation, using the FFTW3 library", + "enable_heif": "Support HEIF (.heic and .avif) image files, using libheif", + "enable_jpeg": "Support JPEG (.jpg) image files, using the JPEG library", + # "enable_lapack": "Enable the use of LAPACK routines for matrix computations", + "enable_magick": "Add support of most classical image file formats, using the Magick++ library", + # "enable_minc2": "Support MINC2 (.mnc) image files, using the MINC2 library", + "enable_opencv": "Enable OpenCV support", + "enable_openexr": "Add support for EXR (.exr) image files, using the OpenEXR library", + "enable_openmp": "Enable OpenMP support", + "enable_png": "Support PNG (.png) image files, using the PNG library", + "enable_tiff": "Support TIFF (.tiff) image files, using the TIFF library", + "enable_tinyexr": "Support EXR (.exr) image files, using the TinyEXR library", + "enable_xrandr": "Enable screen mode switching, using the XRandr library (when using X11)", + "enable_xshm": "Enable fast image display, using the XSHM library (when using X11)", + "enable_zlib": "Support compressed .cimgz files, using the ZLib library", } no_copy_source = True @property def _cimg_defines(self): + # Based on https://github.com/GreycLab/CImg/blob/master/examples/Makefile defines = [] for option, define in [ + ("enable_curl", "cimg_use_curl"), + ("enable_ffmpeg", "cimg_use_ffmpeg"), ("enable_fftw", "cimg_use_fftw3"), + ("enable_heif", "cimg_use_heif"), ("enable_jpeg", "cimg_use_jpeg"), + ("enable_magick", "cimg_use_magick"), + ("enable_opencv", "cimg_use_opencv"), ("enable_openexr", "cimg_use_openexr"), + ("enable_openmp", "cimg_use_openmp"), ("enable_png", "cimg_use_png"), ("enable_tiff", "cimg_use_tiff"), - ("enable_ffmpeg", "cimg_use_ffmpeg"), - ("enable_opencv", "cimg_use_opencv"), - ("enable_magick", "cimg_use_magick"), + ("enable_tinyexr", "cimg_use_tinyexr"), ("enable_xrandr", "cimg_use_xrandr"), - ("enable_xshm", "cimg_use_xshm"), + ("enable_zlib", "cimg_use_zlib"), + # TODO: + # ("enable_minc2", "cimg_use_minc2"), + # ("enable_lapack", "cimg_use_lapack"), + # ("enable_board", "cimg_use_board"), ]: if getattr(self.options, option): defines.append(define) @@ -83,11 +125,16 @@ def _cimg_defines(self): def config_options(self): if self.settings.os not in ["Linux", "FreeBSD"]: # Requires Xorg + # Also, + # xshm: "Seems to randomly crash when used on MacOS and 64bits systems, so use it only when necessary" + # xrandr: "Not supported by the X11 server on MacOS, so do not use it on MacOS" del self.options.enable_xrandr del self.options.enable_xshm if self.settings.os not in ["Linux", "FreeBSD", "Windows"]: # Must support either X11 or GDI32 del self.options.enable_display + if Version(self.version) < "2.9.7": + del self.options.enable_heif def layout(self): basic_layout(self, src_folder="src") @@ -115,6 +162,16 @@ def requirements(self): self.requires("imagemagick/7.0.11-14") if self.options.enable_display and self.settings.os in ["Linux", "FreeBSD"]: self.requires("xorg/system") + if self.options.enable_openmp and self.settings.compiler in ["clang", "apple-clang"]: + self.requires("llvm-openmp/17.0.6") + if self.options.enable_heif: + self.requires("libheif/1.12.0") + if self.options.enable_zlib: + self.requires("zlib/[>=1.2.11 <2]") + if self.options.enable_curl: + self.requires("libcurl/[>=7.78.0 <9]") + if self.options.enable_tinyexr: + self.requires("tinyexr/1.0.7") def package_id(self): self.info.clear() @@ -127,6 +184,14 @@ def validate(self): if self.options.enable_xrandr or self.options.enable_xshm: raise ConanInvalidConfiguration("X11 options enable_xrandr and enable_xshm require enable_display=True") + if self.options.enable_tinyexr: + if self.options.enable_openexr: + raise ConanInvalidConfiguration("OpenEXR and TinyEXR cannot be enabled simultaneously") + if self.options.enable_zlib: + # The miniz dependency of TinyEXR conflicts with ZLib + # error: conflicting declaration ‘typedef void* const voidpc’ + raise ConanInvalidConfiguration("TinyEXR and ZLib cannot be enabled simultaneously due to conflicting typedefs") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -148,6 +213,21 @@ def package_info(self): if self.settings.os == "Windows" and self.options.enable_display: self.cpp_info.system_libs.append("gdi32") + if self.options.enable_openmp: + openmp_flags = [] + if self.settings.compiler in ("clang", "apple-clang"): + openmp_flags = ["-Xpreprocessor", "-fopenmp"] + elif self.settings.compiler == "gcc": + openmp_flags = ["-fopenmp"] + elif self.settings.compiler == "intel-cc": + openmp_flags = ["/Qopenmp"] if self.settings.os == "Windows" else ["-Qopenmp"] + elif is_msvc(self): + openmp_flags = ["-openmp"] + self.cpp_info.cflags = openmp_flags + self.cpp_info.cxxflags = openmp_flags + self.cpp_info.sharedlinkflags = openmp_flags + self.cpp_info.exelinkflags = openmp_flags + # TODO: to remove in conan v2 once cmake_find_package* generators removed # do not use this name in CMakeDeps, it was a mistake, there is no official CMake config file self.cpp_info.names["cmake_find_package"] = "CImg" diff --git a/recipes/cimg/all/test_package/conanfile.py b/recipes/cimg/all/test_package/conanfile.py index e7db77b969cb1..8058ada171f01 100644 --- a/recipes/cimg/all/test_package/conanfile.py +++ b/recipes/cimg/all/test_package/conanfile.py @@ -10,17 +10,22 @@ class TestPackageConan(ConanFile): test_type = "explicit" def configure(self): + self.options["cimg"].enable_curl = True + self.options["cimg"].enable_display = True + self.options["cimg"].enable_ffmpeg = True self.options["cimg"].enable_fftw = True + self.options["cimg"].enable_heif = True self.options["cimg"].enable_jpeg = True + self.options["cimg"].enable_magick = False # Not yet Conan 2.0 compatible + self.options["cimg"].enable_opencv = False # ffmpeg linking fails when enabled self.options["cimg"].enable_openexr = True + self.options["cimg"].enable_openmp = True self.options["cimg"].enable_png = True self.options["cimg"].enable_tiff = True - self.options["cimg"].enable_ffmpeg = True - self.options["cimg"].enable_opencv = False # ffmpeg linking fails when enabled - self.options["cimg"].enable_magick = False # Not yet Conan 2.0 compatible - self.options["cimg"].enable_display = True + self.options["cimg"].enable_tinyexr = False # Conflicts with OpenEXR and ZLib self.options["cimg"].enable_xrandr = True self.options["cimg"].enable_xshm = True + self.options["cimg"].enable_zlib = True def layout(self): cmake_layout(self) From bbaa1d72a0aa31fb3d205463ac93cadc916d6390 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 11:29:21 +0200 Subject: [PATCH 07/16] cimg: fix topics --- recipes/cimg/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index e15075810c12b..6eedc3f3bdad4 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -16,7 +16,8 @@ class CImgConan(ConanFile): license = "CeCILL V2" url = "https://github.com/conan-io/conan-center-index" homepage = "http://cimg.eu" - topics = ("physics", "simulation", "robotics", "kinematics", "engine") + topics = ("image", "image-processing", "header-only") + package_type = "header-library" settings = "os", "arch", "compiler", "build_type" options = { From 110411f418216d8f2c517e4050b9335e60ed3a7a Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 12:55:08 +0200 Subject: [PATCH 08/16] cimg: downgrade OpenCV As a workaround for linking issues with ffmpeg both as a direct or transitive dependency. --- recipes/cimg/all/conanfile.py | 16 +++++++++++----- recipes/cimg/all/test_package/conanfile.py | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index 6eedc3f3bdad4..95e3c89a7cebe 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -137,6 +137,10 @@ def config_options(self): if Version(self.version) < "2.9.7": del self.options.enable_heif + def configure(self): + # Required component in OpenCV 4.x for cv::VideoCapture and cv::VideoWriter + self.options["opencv"].videoio = True + def layout(self): basic_layout(self, src_folder="src") @@ -153,12 +157,10 @@ def requirements(self): if self.options.enable_tiff: self.requires("libtiff/4.6.0") if self.options.enable_ffmpeg: - if self.options.enable_opencv: - self.requires("ffmpeg/4.4.4") - else: - self.requires("ffmpeg/6.1") + self.requires("ffmpeg/6.1") if self.options.enable_opencv: - self.requires("opencv/4.8.1") + # FIXME: OpenCV 4.x fails to link ffmpeg libraries correctly + self.requires("opencv/3.4.20") if self.options.enable_magick: self.requires("imagemagick/7.0.11-14") if self.options.enable_display and self.settings.os in ["Linux", "FreeBSD"]: @@ -193,6 +195,10 @@ def validate(self): # error: conflicting declaration ‘typedef void* const voidpc’ raise ConanInvalidConfiguration("TinyEXR and ZLib cannot be enabled simultaneously due to conflicting typedefs") + if self.options.enable_opencv and Version(self.dependencies["opencv"].ref.version) >= "4.0": + if not self.dependencies["opencv"].options.videoio: + raise ConanInvalidConfiguration("OpenCV must be built with videoio=True") + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) diff --git a/recipes/cimg/all/test_package/conanfile.py b/recipes/cimg/all/test_package/conanfile.py index 8058ada171f01..8c37f51776b8a 100644 --- a/recipes/cimg/all/test_package/conanfile.py +++ b/recipes/cimg/all/test_package/conanfile.py @@ -17,7 +17,7 @@ def configure(self): self.options["cimg"].enable_heif = True self.options["cimg"].enable_jpeg = True self.options["cimg"].enable_magick = False # Not yet Conan 2.0 compatible - self.options["cimg"].enable_opencv = False # ffmpeg linking fails when enabled + self.options["cimg"].enable_opencv = False # OpenCV v3 Requires OpenEXR v2 self.options["cimg"].enable_openexr = True self.options["cimg"].enable_openmp = True self.options["cimg"].enable_png = True From fc1390f0410cc7adc978b7ad50dc1c90aaa411d8 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 12:55:27 +0200 Subject: [PATCH 09/16] cimg: explicitly list requires to avoid overlinking --- recipes/cimg/all/conanfile.py | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index 95e3c89a7cebe..07a6504ad0179 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -217,6 +217,49 @@ def package_info(self): self.cpp_info.libdirs = [] self.cpp_info.defines = self._cimg_defines + # List specific requirements to avoid overlinking + # Based on https://github.com/GreycLab/CImg/blob/v.3.3.3/examples/Makefile#L166-L310 + requires = [] + if self.options.enable_fftw: + requires.append("fftw::fftw") + if self.options.enable_jpeg: + requires.append("libjpeg::libjpeg") + if self.options.enable_openexr: + requires.append("openexr::openexr_openexr") + requires.append("imath::imath_lib") + if self.options.enable_png: + requires.append("libpng::libpng") + if self.options.enable_tiff: + requires.append("libtiff::libtiff") + if self.options.enable_opencv: + requires.append("opencv::opencv_core") + requires.append("opencv::opencv_highgui") + if Version(self.dependencies["opencv"].ref.version) >= "4.0": + requires.append("opencv::opencv_videoio") + if self.options.enable_ffmpeg: + requires.append("ffmpeg::avcodec") + requires.append("ffmpeg::avformat") + requires.append("ffmpeg::swscale") + if self.options.enable_magick: + requires.append("imagemagick::Magick++") + if self.options.enable_display and self.settings.os in ["Linux", "FreeBSD"]: + requires.append("xorg::x11") + if self.options.enable_xrandr: + requires.append("xorg::xrandr") + if self.options.enable_xshm: + requires.append("xorg::xext") + if self.options.enable_openmp and self.settings.compiler in ["clang", "apple-clang"]: + requires.append("llvm-openmp::llvm-openmp") + if self.options.enable_heif: + requires.append("libheif::libheif") + if self.options.enable_zlib: + requires.append("zlib::zlib") + if self.options.enable_curl: + requires.append("libcurl::libcurl") + if self.options.enable_tinyexr: + requires.append("tinyexr::tinyexr") + self.cpp_info.requires = requires + if self.settings.os == "Windows" and self.options.enable_display: self.cpp_info.system_libs.append("gdi32") From 99ab396ec2742108b8410d74e88c00b343d174ee Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 13:04:17 +0200 Subject: [PATCH 10/16] cimg: add libjpeg alternatives --- recipes/cimg/all/conanfile.py | 18 +++++++++++++----- recipes/cimg/all/test_package/conanfile.py | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index 07a6504ad0179..77c97b9209adb 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -26,7 +26,7 @@ class CImgConan(ConanFile): "enable_ffmpeg": [True, False], "enable_fftw": [True, False], "enable_heif": [True, False], - "enable_jpeg": [True, False], + "enable_jpeg": ["libjpeg", "libjpeg-turbo", "mozjpeg", True, False], "enable_magick": [True, False], "enable_opencv": [True, False], "enable_openexr": [True, False], @@ -44,7 +44,7 @@ class CImgConan(ConanFile): "enable_ffmpeg": False, "enable_fftw": False, "enable_heif": False, - "enable_jpeg": False, + "enable_jpeg": "libjpeg", "enable_magick": False, "enable_opencv": False, "enable_openexr": False, @@ -147,8 +147,12 @@ def layout(self): def requirements(self): if self.options.enable_fftw: self.requires("fftw/3.3.10") - if self.options.enable_jpeg: + if self.options.enable_jpeg == "libjpeg" or self.options.enable_jpeg.value is True: self.requires("libjpeg/9e") + elif self.options.enable_jpeg == "libjpeg-turbo": + self.requires("libjpeg-turbo/3.0.1") + elif self.options.enable_jpeg == "mozjpeg": + self.requires("mozjpeg/4.1.5") if self.options.enable_openexr: self.requires("openexr/3.2.1") self.requires("imath/3.1.9") @@ -168,7 +172,7 @@ def requirements(self): if self.options.enable_openmp and self.settings.compiler in ["clang", "apple-clang"]: self.requires("llvm-openmp/17.0.6") if self.options.enable_heif: - self.requires("libheif/1.12.0") + self.requires("libheif/1.16.2") if self.options.enable_zlib: self.requires("zlib/[>=1.2.11 <2]") if self.options.enable_curl: @@ -222,8 +226,12 @@ def package_info(self): requires = [] if self.options.enable_fftw: requires.append("fftw::fftw") - if self.options.enable_jpeg: + if self.options.enable_jpeg == "libjpeg" or self.options.enable_jpeg.value is True: requires.append("libjpeg::libjpeg") + elif self.options.enable_jpeg == "libjpeg-turbo": + requires.append("libjpeg-turbo::jpeg") + elif self.options.enable_jpeg == "mozjpeg": + requires.append("mozjpeg::libjpeg") if self.options.enable_openexr: requires.append("openexr::openexr_openexr") requires.append("imath::imath_lib") diff --git a/recipes/cimg/all/test_package/conanfile.py b/recipes/cimg/all/test_package/conanfile.py index 8c37f51776b8a..9bed5673637d9 100644 --- a/recipes/cimg/all/test_package/conanfile.py +++ b/recipes/cimg/all/test_package/conanfile.py @@ -15,7 +15,7 @@ def configure(self): self.options["cimg"].enable_ffmpeg = True self.options["cimg"].enable_fftw = True self.options["cimg"].enable_heif = True - self.options["cimg"].enable_jpeg = True + self.options["cimg"].enable_jpeg = "libjpeg" self.options["cimg"].enable_magick = False # Not yet Conan 2.0 compatible self.options["cimg"].enable_opencv = False # OpenCV v3 Requires OpenEXR v2 self.options["cimg"].enable_openexr = True From 5179e1ba330ab42b71cbc246daf69d2083f5f630 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 15:09:16 +0200 Subject: [PATCH 11/16] cimg: drop v2.8.3 --- recipes/cimg/all/conandata.yml | 3 --- recipes/cimg/all/conanfile.py | 2 -- recipes/cimg/config.yml | 2 -- 3 files changed, 7 deletions(-) diff --git a/recipes/cimg/all/conandata.yml b/recipes/cimg/all/conandata.yml index 2dec11891b7ba..b3d99aafa4618 100644 --- a/recipes/cimg/all/conandata.yml +++ b/recipes/cimg/all/conandata.yml @@ -17,6 +17,3 @@ sources: "2.9.9": url: "https://cimg.eu/files/CImg_2.9.9.zip" sha256: "c94412f26800ea318fa79410c58da1cf3df71771d07e515c39b16ee743f68e92" - "2.8.3": - url: "https://cimg.eu/files/CImg_2.8.3.zip" - sha256: "8d92e4cc271568c5aeca6e6b1f28f620fcf161ef99ce9d070ed1905d92caec4c" diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index 77c97b9209adb..62152ecc18836 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -134,8 +134,6 @@ def config_options(self): if self.settings.os not in ["Linux", "FreeBSD", "Windows"]: # Must support either X11 or GDI32 del self.options.enable_display - if Version(self.version) < "2.9.7": - del self.options.enable_heif def configure(self): # Required component in OpenCV 4.x for cv::VideoCapture and cv::VideoWriter diff --git a/recipes/cimg/config.yml b/recipes/cimg/config.yml index 54464b95b2527..d498cb1f52d88 100644 --- a/recipes/cimg/config.yml +++ b/recipes/cimg/config.yml @@ -11,5 +11,3 @@ versions: folder: all "2.9.9": folder: all - "2.8.3": - folder: all From 19f2e3188471b3fe8a00d0e6649a1080c8d03bd1 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 15:57:16 +0200 Subject: [PATCH 12/16] cimg: handle deleted option correctly --- recipes/cimg/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index 62152ecc18836..29aa4086f609f 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -165,7 +165,7 @@ def requirements(self): self.requires("opencv/3.4.20") if self.options.enable_magick: self.requires("imagemagick/7.0.11-14") - if self.options.enable_display and self.settings.os in ["Linux", "FreeBSD"]: + if self.settings.os in ["Linux", "FreeBSD"] and self.options.enable_display: self.requires("xorg/system") if self.options.enable_openmp and self.settings.compiler in ["clang", "apple-clang"]: self.requires("llvm-openmp/17.0.6") @@ -186,7 +186,7 @@ def validate(self): check_min_cppstd(self, "11") if not self.options.get_safe("enable_display"): - if self.options.enable_xrandr or self.options.enable_xshm: + if self.options.get_safe("enable_xrandr") or self.options.get_safe("enable_xshm"): raise ConanInvalidConfiguration("X11 options enable_xrandr and enable_xshm require enable_display=True") if self.options.enable_tinyexr: @@ -248,7 +248,7 @@ def package_info(self): requires.append("ffmpeg::swscale") if self.options.enable_magick: requires.append("imagemagick::Magick++") - if self.options.enable_display and self.settings.os in ["Linux", "FreeBSD"]: + if self.settings.os in ["Linux", "FreeBSD"] and self.options.enable_display: requires.append("xorg::x11") if self.options.enable_xrandr: requires.append("xorg::xrandr") From 18a096454dafa8fb2a6c6410b2b1e3b15febda20 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 19:58:41 +0200 Subject: [PATCH 13/16] cimg: use options.get_safe() --- recipes/cimg/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index 29aa4086f609f..ee9818394967f 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -7,7 +7,7 @@ from conan.tools.scm import Version import os -required_conan_version = ">=1.51.1" +required_conan_version = ">=1.53" class CImgConan(ConanFile): @@ -104,7 +104,7 @@ def _cimg_defines(self): # ("enable_lapack", "cimg_use_lapack"), # ("enable_board", "cimg_use_board"), ]: - if getattr(self.options, option): + if self.options.get_safe(option): defines.append(define) if not self.options.get_safe("enable_display"): From 7aac4c263ece40ed49a11e02314de80550266f42 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 13 Jan 2024 20:34:56 +0200 Subject: [PATCH 14/16] cimg: do not set deleted options in test_package for v1 --- recipes/cimg/all/test_package/conanfile.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/cimg/all/test_package/conanfile.py b/recipes/cimg/all/test_package/conanfile.py index 9bed5673637d9..3cc11b0f64c14 100644 --- a/recipes/cimg/all/test_package/conanfile.py +++ b/recipes/cimg/all/test_package/conanfile.py @@ -11,7 +11,6 @@ class TestPackageConan(ConanFile): def configure(self): self.options["cimg"].enable_curl = True - self.options["cimg"].enable_display = True self.options["cimg"].enable_ffmpeg = True self.options["cimg"].enable_fftw = True self.options["cimg"].enable_heif = True @@ -23,9 +22,12 @@ def configure(self): self.options["cimg"].enable_png = True self.options["cimg"].enable_tiff = True self.options["cimg"].enable_tinyexr = False # Conflicts with OpenEXR and ZLib - self.options["cimg"].enable_xrandr = True - self.options["cimg"].enable_xshm = True self.options["cimg"].enable_zlib = True + if self.settings.os in ["Linux", "FreeBSD", "Windows"]: + self.options["cimg"].enable_display = True + if self.settings.os in ["Linux", "FreeBSD"]: + self.options["cimg"].enable_xrandr = True + self.options["cimg"].enable_xshm = True def layout(self): cmake_layout(self) From 3f0967ae33bcc1488dc5d5bb09e3ea075e8a3389 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 25 Mar 2024 14:43:48 +0200 Subject: [PATCH 15/16] cimg: bump to v3.3.5, drop a vulnerable version --- recipes/cimg/all/conandata.yml | 9 +++------ recipes/cimg/config.yml | 4 +--- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/recipes/cimg/all/conandata.yml b/recipes/cimg/all/conandata.yml index b3d99aafa4618..92dd59ed485a3 100644 --- a/recipes/cimg/all/conandata.yml +++ b/recipes/cimg/all/conandata.yml @@ -1,7 +1,7 @@ sources: - "3.3.3": - url: "https://cimg.eu/files/CImg_3.3.3.zip" - sha256: "6853194cfe1229c946698a397c891a19f4d63240a419245c9b130ec7a67825b9" + "3.3.5": + url: "https://cimg.eu/files/CImg_3.3.5.zip" + sha256: "c7268c270e3b93730a3eaf5738250a1b1efb0866bd57409786d750f7f4be7705" "3.3.2": url: "https://cimg.eu/files/CImg_3.3.2.zip" sha256: "d49ecd63b46f53ddcee5c7695ddb0fe8b07e033bb81b5ed075cfe352462c5f73" @@ -11,9 +11,6 @@ sources: "3.2.6": url: "https://cimg.eu/files/CImg_3.2.6.zip" sha256: "8da3aa995027231bb18f97bb986e12788ef464b3ab8a34151650bf1217baeda7" - "3.0.2": - url: "https://cimg.eu/files/CImg_3.0.2.zip" - sha256: "ee55a37c33d503a64ff264b53952e502ba7c2887b59ded47c47c86ea52ac5c31" "2.9.9": url: "https://cimg.eu/files/CImg_2.9.9.zip" sha256: "c94412f26800ea318fa79410c58da1cf3df71771d07e515c39b16ee743f68e92" diff --git a/recipes/cimg/config.yml b/recipes/cimg/config.yml index d498cb1f52d88..d191c6f8bf931 100644 --- a/recipes/cimg/config.yml +++ b/recipes/cimg/config.yml @@ -1,5 +1,5 @@ versions: - "3.3.3": + "3.3.5": folder: all "3.3.2": folder: all @@ -7,7 +7,5 @@ versions: folder: all "3.2.6": folder: all - "3.0.2": - folder: all "2.9.9": folder: all From 01155d745ec4ce0cfddc62986183098f38a2a2cb Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 25 Mar 2024 14:44:19 +0200 Subject: [PATCH 16/16] cimg: bump deps --- recipes/cimg/all/conanfile.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/cimg/all/conanfile.py b/recipes/cimg/all/conanfile.py index cc0735bf2101e..f3b0a8d1e93c9 100644 --- a/recipes/cimg/all/conanfile.py +++ b/recipes/cimg/all/conanfile.py @@ -148,11 +148,11 @@ def requirements(self): if self.options.enable_jpeg == "libjpeg" or self.options.enable_jpeg.value is True: self.requires("libjpeg/9e") elif self.options.enable_jpeg == "libjpeg-turbo": - self.requires("libjpeg-turbo/3.0.1") + self.requires("libjpeg-turbo/3.0.2") elif self.options.enable_jpeg == "mozjpeg": self.requires("mozjpeg/4.1.5") if self.options.enable_openexr: - self.requires("openexr/3.2.1") + self.requires("openexr/3.2.3") self.requires("imath/3.1.9") if self.options.enable_png: self.requires("libpng/[>=1.6 <2]")