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

exiv2: add 0.27.5 + conan v2 support #13631

Merged
merged 9 commits into from
Oct 25, 2022
Merged
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
7 changes: 0 additions & 7 deletions recipes/exiv2/all/CMakeLists.txt

This file was deleted.

15 changes: 12 additions & 3 deletions recipes/exiv2/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
sources:
"0.27.5":
url: "https://github.com/Exiv2/exiv2/archive/refs/tags/v0.27.5.tar.gz"
sha256: "1da1721f84809e4d37b3f106adb18b70b1b0441c860746ce6812bb3df184ed6c"
"0.27.4":
url: "https://github.com/Exiv2/exiv2/archive/refs/tags/v0.27.4.tar.gz"
sha256: "9fb2752c92f63c9853e0bef9768f21138eeac046280f40ded5f37d06a34880d9"
patches:
"0.27.5":
- patch_file: "patches/0001-link-0.27.5.patch"
- patch_file: "patches/0003-fix-ios.patch"
- patch_file: "patches/0004-find-expat.patch"
patch_description: "enforce usage of FindEXPAT.cmake"
patch_type: "conan"
"0.27.4":
- patch_file: "patches/0001-link.patch"
base_path: "source_subfolder"
- patch_file: "patches/0002-fpic.patch"
base_path: "source_subfolder"
- patch_file: "patches/0003-fix-ios.patch"
base_path: "source_subfolder"
- patch_file: "patches/0004-find-expat.patch"
patch_description: "enforce usage of FindEXPAT.cmake"
patch_type: "conan"
109 changes: 49 additions & 60 deletions recipes/exiv2/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from conan.tools.microsoft import msvc_runtime_flag
from conans import ConanFile, CMake, tools
from conans.errors import ConanInvalidConfiguration
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps
from conan.errors import ConanInvalidConfiguration
from conan.tools.files import get, copy, rmdir, save, export_conandata_patches, apply_conandata_patches
from conan.tools.microsoft import is_msvc, msvc_runtime_flag
import os
import textwrap

required_conan_version = ">=1.43.0"
required_conan_version = ">=1.52.0"


class Exiv2Conan(ConanFile):
Expand Down Expand Up @@ -34,25 +36,8 @@ class Exiv2Conan(ConanFile):

provides = []

generators = "cmake", "cmake_find_package"
_cmake = None

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

@property
def _is_msvc(self):
return str(self.settings.compiler) in ["Visual Studio", "msvc"]

def export_sources(self):
self.copy("CMakeLists.txt")
for patch in self.conan_data.get("patches", {}).get(self.version, []):
self.copy(patch["patch_file"])
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
Expand All @@ -67,56 +52,61 @@ def configure(self):
self.provides.append("xmp-toolkit-sdk")

def requirements(self):
self.requires("libiconv/1.16")
self.requires("libiconv/1.17")
if self.options.with_png:
self.requires("libpng/1.6.37")
self.requires("libpng/1.6.38")
if self.options.with_xmp == "bundled":
self.requires("expat/2.4.3")
self.requires("expat/2.4.9")
if self.options.with_curl:
self.requires("libcurl/7.80.0")
self.requires("libcurl/7.85.0")

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

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

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

def generate(self):
tc = CMakeToolchain(self)
tc.variables["EXIV2_BUILD_SAMPLES"] = False
tc.variables["EXIV2_BUILD_EXIV2_COMMAND"] = False
tc.variables["EXIV2_ENABLE_PNG"] = self.options.with_png
tc.variables["EXIV2_ENABLE_XMP"] = self.options.with_xmp == "bundled"
tc.variables["EXIV2_ENABLE_EXTERNAL_XMP"] = self.options.with_xmp == "external"
# NLS is used only for tool which is not built
tc.variables["EXIV2_ENABLE_NLS"] = False
tc.variables["EXIV2_ENABLE_WEBREADY"] = self.options.with_curl
tc.variables["EXIV2_ENABLE_CURL"] = self.options.with_curl
tc.variables["EXIV2_ENABLE_SSH"] = False
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"

theirix marked this conversation as resolved.
Show resolved Hide resolved
if is_msvc(self):
tc.variables["EXIV2_ENABLE_DYNAMIC_RUNTIME"] = "MD" in msvc_runtime_flag(self)
# set PIC manually because of object target exiv2_int
tc.cache_variables["CMAKE_POSITION_INDEPENDENT_CODE"] = bool(self.options.get_safe("fPIC", True))
tc.generate()

deps = CMakeDeps(self)
deps.generate()

def build(self):
for patch in self.conan_data.get("patches", {}).get(self.version, []):
tools.patch(**patch)
cmake = self._configure_cmake()
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure()
cmake.build()

def _configure_cmake(self):
if self._cmake:
return self._cmake
self._cmake = CMake(self)
self._cmake.definitions["EXIV2_BUILD_SAMPLES"] = False
self._cmake.definitions["EXIV2_BUILD_EXIV2_COMMAND"] = False
self._cmake.definitions["EXIV2_ENABLE_PNG"] = self.options.with_png
self._cmake.definitions["EXIV2_ENABLE_XMP"] = self.options.with_xmp == "bundled"
self._cmake.definitions["EXIV2_ENABLE_EXTERNAL_XMP"] = self.options.with_xmp == "external"
# NLS is used only for tool which is not built
self._cmake.definitions["EXIV2_ENABLE_NLS"] = False
self._cmake.definitions["EXIV2_ENABLE_WEBREADY"] = self.options.with_curl
self._cmake.definitions["EXIV2_ENABLE_CURL"] = self.options.with_curl
self._cmake.definitions["EXIV2_ENABLE_SSH"] = False
if self._is_msvc:
self._cmake.definitions["EXIV2_ENABLE_DYNAMIC_RUNTIME"] = "MD" in msvc_runtime_flag(self)
# set PIC manually because of object target exiv2_int
self._cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True)
self._cmake.configure(build_folder=self._build_subfolder)
return self._cmake

def package(self):
self.copy("COPYING", dst="licenses", src=self._source_subfolder)
cmake = self._configure_cmake()
copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder, "share"))
rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig"))
rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))

# TODO: to remove in conan v2 once cmake_find_package_* generators removed
targets = {"exiv2lib": "exiv2::exiv2lib"}
Expand All @@ -127,8 +117,7 @@ def package(self):
targets
)

@staticmethod
def _create_cmake_module_alias_targets(module_file, targets):
def _create_cmake_module_alias_targets(self, module_file, targets):
content = ""
for alias, aliased in targets.items():
content += textwrap.dedent("""\
Expand All @@ -137,7 +126,7 @@ def _create_cmake_module_alias_targets(module_file, targets):
set_property(TARGET {alias} PROPERTY INTERFACE_LINK_LIBRARIES {aliased})
endif()
""".format(alias=alias, aliased=aliased))
tools.save(module_file, content)
save(self, module_file, content)

@property
def _module_file_rel_path(self):
Expand Down
29 changes: 29 additions & 0 deletions recipes/exiv2/all/patches/0001-link-0.27.5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 26e5a951..141211ef 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -142,11 +142,6 @@ 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})
target_include_directories(exiv2lib SYSTEM PRIVATE
diff --git a/xmpsdk/CMakeLists.txt b/xmpsdk/CMakeLists.txt
index a22698fb..9ef87970 100644
--- a/xmpsdk/CMakeLists.txt
+++ b/xmpsdk/CMakeLists.txt
@@ -28,7 +28,7 @@ add_library(exiv2-xmp STATIC

target_link_libraries(exiv2-xmp
PRIVATE
- $<BUILD_INTERFACE:${EXPAT_LIBRARY}>
+ EXPAT::EXPAT
)

target_include_directories(exiv2-xmp
15 changes: 15 additions & 0 deletions recipes/exiv2/all/patches/0004-find-expat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Ensure to use FindEXPAT.cmake instead of expat-config.cmake
(side effect of CMAKE_FIND_PACKAGE_PREFER_CONFIG ON, see https://github.com/conan-io/conan/issues/10387)
diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake
index ec3a43f5..27bf42d3 100644
--- a/cmake/findDependencies.cmake
+++ b/cmake/findDependencies.cmake
@@ -42,7 +42,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 ()
3 changes: 0 additions & 3 deletions recipes/exiv2/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(exiv2 REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
Expand Down
20 changes: 14 additions & 6 deletions recipes/exiv2/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
from conan import ConanFile
from conan.tools.build import cross_building
from conan.tools.cmake import CMake, cmake_layout
import os

from conans import ConanFile, CMake, tools

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

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 not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
if not cross_building(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
10 changes: 10 additions & 0 deletions recipes/exiv2/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package CXX)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(exiv2 REQUIRED CONFIG)

add_executable(${PROJECT_NAME} ../test_package/test_package.cpp)
target_link_libraries(${PROJECT_NAME} exiv2lib)
17 changes: 17 additions & 0 deletions recipes/exiv2/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
2 changes: 2 additions & 0 deletions recipes/exiv2/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"0.27.5":
folder: all
"0.27.4":
folder: all