Skip to content

Commit

Permalink
(#18149) exiv2: add version 0.28.0, add win_unicode option for 0.27.x
Browse files Browse the repository at this point in the history
* init

* fix

* get_safe

* fix sig

* fix the fix

* exiv2-xmp is an object library in 0.28

* fix linkage

* component requires

* indent

* min std, min compiler version, extend fix

* bump inih, better cppstd and compiler version check

* fix

* add c++17 compiler feature to test_package

* endline

* check max cppstd for versions older than 0.28.0

* linter

linter again

conan_version

* fix build

* Update recipes/exiv2/all/conanfile.py

Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com>

* bump libpng version

* add win_unicode option

---------

Co-authored-by: Matthieu Darbois <mayeut@users.noreply.github.com>
  • Loading branch information
maksim-petukhov and mayeut authored Sep 11, 2023
1 parent c57bf4b commit 3aeb2ae
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 9 deletions.
8 changes: 8 additions & 0 deletions recipes/exiv2/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
sources:
"0.28.0":
url: "https://github.com/Exiv2/exiv2/releases/download/v0.28.0/exiv2-0.28.0-Source.tar.gz"
sha256: "89af3b5ef7277753ef7a7b5374ae017c6b9e304db3b688f1948e73e103491f3d"
"0.27.5":
url: "https://github.com/Exiv2/exiv2/releases/download/v0.27.5/exiv2-0.27.5-Source.tar.gz"
sha256: "35a58618ab236a901ca4928b0ad8b31007ebdc0386d904409d825024e45ea6e2"
"0.27.4":
url: "https://github.com/Exiv2/exiv2/releases/download/v0.27.4/exiv2-0.27.4-Source.tar.gz"
sha256: "84366dba7c162af9a7603bcd6c16f40fe0e9af294ba2fd2f66ffffb9fbec904e"
patches:
"0.28.0":
- patch_file: "patches/0001-link-0.28.0.patch"
- patch_file: "patches/0004-find-expat-0.28.0.patch"
patch_description: "enforce usage of FindEXPAT.cmake"
patch_type: "conan"
"0.27.5":
- patch_file: "patches/0001-link-0.27.5.patch"
- patch_file: "patches/0003-fix-ios.patch"
Expand Down
77 changes: 68 additions & 9 deletions recipes/exiv2/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
from conan import ConanFile
from conan import ConanFile, conan_version
from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps
from conan.tools.files import get, copy, rmdir, save, export_conandata_patches, apply_conandata_patches
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime
from conan.tools.microsoft import is_msvc, is_msvc_static_runtime, check_min_vs
from conan.tools.scm import Version
import os
import sys
import textwrap

required_conan_version = ">=1.53.0"
Expand All @@ -26,13 +29,19 @@ class Exiv2Conan(ConanFile):
"with_png": [True, False],
"with_xmp": [False, "bundled", "external"],
"with_curl": [True, False],
"with_brotli": [True, False],
"with_inih": [True, False],
"win_unicode": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_png": True,
"with_xmp": "bundled",
"with_curl": False,
"with_brotli": True,
"with_inih": True,
"win_unicode": False,
}

provides = []
Expand All @@ -43,6 +52,14 @@ def export_sources(self):
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if Version(self.version) >= "0.28.0":
del self.options.win_unicode
else:
del self.options.with_brotli
del self.options.with_inih

if self.settings.os == "Windows":
self.options.win_unicode = True

def configure(self):
if self.options.shared:
Expand All @@ -58,14 +75,43 @@ def layout(self):
def requirements(self):
self.requires("libiconv/1.17")
if self.options.with_png:
self.requires("libpng/1.6.39")
self.requires("libpng/1.6.40")
self.requires("zlib/1.2.13")
if self.options.with_xmp == "bundled":
self.requires("expat/2.5.0")
if self.options.with_curl:
self.requires("libcurl/7.87.0")
self.requires("libcurl/8.2.1")
if self.options.get_safe("with_brotli"):
self.requires("brotli/1.0.9")
if self.options.get_safe("with_inih"):
self.requires("inih/57")

def validate(self):
if Version(self.version) >= "0.28.0":
min_cppstd = 17

if self.settings.compiler.cppstd:
check_min_cppstd(self, min_cppstd)
check_min_vs(self, 191)

compilers_minimum_version = {
"gcc": "8",
"clang": "5",
"apple-clang": "10",
}
if not is_msvc(self):
minimum_version = compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.info.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{min_cppstd}, which your compiler does not fully support."
)
elif conan_version.major == 2:
# FIXME: linter complains, but function is there
# https://docs.conan.io/2.0/reference/tools/build.html?highlight=check_min_cppstd#conan-tools-build-check-max-cppstd
check_max_cppstd = getattr(sys.modules['conan.tools.build'], 'check_max_cppstd')
# https://github.com/Exiv2/exiv2/tree/v0.27.7#217-building-with-c11-and-other-compilers
check_max_cppstd(self, 14)

if self.options.with_xmp == "external":
raise ConanInvalidConfiguration("adobe-xmp-toolkit is not available on cci (yet)")

Expand All @@ -84,6 +130,12 @@ def generate(self):
tc.variables["EXIV2_ENABLE_WEBREADY"] = self.options.with_curl
tc.variables["EXIV2_ENABLE_CURL"] = self.options.with_curl
tc.variables["EXIV2_ENABLE_SSH"] = False
if Version(self.version) >= "0.28.0":
tc.variables["EXIV2_ENABLE_BMFF"] = self.options.with_brotli
tc.variables["EXIV2_ENABLE_BROTLI"] = self.options.with_brotli
tc.variables["EXIV2_ENABLE_INIH"] = self.options.with_inih
else:
tc.variables["EXIV2_ENABLE_WIN_UNICODE"] = self.options.win_unicode
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"

if is_msvc(self):
Expand Down Expand Up @@ -145,6 +197,10 @@ def package_info(self):
self.cpp_info.components["exiv2lib"].requires.extend(["libpng::libpng", "zlib::zlib"])
if self.options.with_curl:
self.cpp_info.components["exiv2lib"].requires.append("libcurl::libcurl")
if self.options.get_safe("with_brotli"):
self.cpp_info.components["exiv2lib"].requires.extend(["brotli::brotlidec", "brotli::brotlienc"])
if self.options.get_safe("with_inih"):
self.cpp_info.components["exiv2lib"].requires.append("inih::inireader")

if self.settings.os in ("FreeBSD", "Linux"):
self.cpp_info.components["exiv2lib"].system_libs.extend(["pthread"])
Expand All @@ -154,14 +210,17 @@ def package_info(self):

# component exiv2-xmp
if self.options.with_xmp == "bundled":
self.cpp_info.components["exiv2-xmp"].set_property("cmake_target_name", "exiv2-xmp")
self.cpp_info.components["exiv2-xmp"].libs = ["exiv2-xmp"]
self.cpp_info.components["exiv2-xmp"].requires = [ "expat::expat" ]
self.cpp_info.components["exiv2lib"].requires.append("exiv2-xmp")
if Version(self.version) < "0.28.0":
self.cpp_info.components["exiv2-xmp"].set_property("cmake_target_name", "exiv2-xmp")
self.cpp_info.components["exiv2-xmp"].libs = ["exiv2-xmp"]
self.cpp_info.components["exiv2-xmp"].requires = [ "expat::expat" ]
self.cpp_info.components["exiv2lib"].requires.append("exiv2-xmp")
else:
self.cpp_info.components["exiv2lib"].requires.append("expat::expat")

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
self.cpp_info.components["exiv2lib"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.components["exiv2lib"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
if self.options.with_xmp == "bundled":
if self.options.with_xmp == "bundled" and Version(self.version) < "0.28.0":
self.cpp_info.components["exiv2-xmp"].build_modules["cmake_find_package"] = [self._module_file_rel_path]
self.cpp_info.components["exiv2-xmp"].build_modules["cmake_find_package_multi"] = [self._module_file_rel_path]
22 changes: 22 additions & 0 deletions recipes/exiv2/all/patches/0001-link-0.28.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 41a672e8..93370b5e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -170,10 +170,10 @@ if (MSVC)
set_target_properties(exiv2lib PROPERTIES LINK_FLAGS "/ignore:4099")
endif()

-set_target_properties( exiv2lib_int PROPERTIES
- POSITION_INDEPENDENT_CODE ON
- COMPILE_DEFINITIONS exiv2lib_EXPORTS
-)
+
+
+
+

# NOTE: Cannot use target_link_libraries on OBJECT libraries with old versions of CMake
target_include_directories(exiv2lib_int PRIVATE ${ZLIB_INCLUDE_DIR})
--
2.33.0.windows.1

16 changes: 16 additions & 0 deletions recipes/exiv2/all/patches/0004-find-expat-0.28.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake
index 1075c303..d8b580d4 100644
--- a/cmake/findDependencies.cmake
+++ b/cmake/findDependencies.cmake
@@ -60,7 +60,7 @@ if (EXIV2_ENABLE_XMP AND EXIV2_ENABLE_EXTERNAL_XMP)
message(FATAL_ERROR "EXIV2_ENABLE_XMP AND EXIV2_ENABLE_EXTERNAL_XMP are mutually exclusive. You can only choose one of them")
else()
if (EXIV2_ENABLE_XMP)
- find_package(EXPAT REQUIRED)
+ find_package(EXPAT REQUIRED MODULE)
elseif (EXIV2_ENABLE_EXTERNAL_XMP)
find_package(XmpSdk REQUIRED)
endif ()
--
2.33.0.windows.1

4 changes: 4 additions & 0 deletions recipes/exiv2/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ find_package(exiv2 REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} exiv2lib)

if(${exiv2_VERSION} VERSION_GREATER_EQUAL "0.28.0")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
endif()
2 changes: 2 additions & 0 deletions recipes/exiv2/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"0.28.0":
folder: all
"0.27.5":
folder: all
"0.27.4":
Expand Down

0 comments on commit 3aeb2ae

Please sign in to comment.