From cb185c022c5ca5ff0bd0f8343f809f020d4eba40 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Tue, 1 Feb 2022 03:07:05 +0100 Subject: [PATCH] (#9070) openjpeg: relocatable shared lib macos * cleanup * relocatable shared lib on macOS --- recipes/openjpeg/all/CMakeLists.txt | 4 ++-- recipes/openjpeg/all/conandata.yml | 7 +++++++ recipes/openjpeg/all/conanfile.py | 18 ++++++++++-------- .../0001-relocatable-shared-macos-2.3.1.patch | 11 +++++++++++ .../0001-relocatable-shared-macos-2.4.0.patch | 11 +++++++++++ 5 files changed, 41 insertions(+), 10 deletions(-) create mode 100644 recipes/openjpeg/all/patches/0001-relocatable-shared-macos-2.3.1.patch create mode 100644 recipes/openjpeg/all/patches/0001-relocatable-shared-macos-2.4.0.patch diff --git a/recipes/openjpeg/all/CMakeLists.txt b/recipes/openjpeg/all/CMakeLists.txt index 68bfd75fb1882..d2f473cdad7d6 100644 --- a/recipes/openjpeg/all/CMakeLists.txt +++ b/recipes/openjpeg/all/CMakeLists.txt @@ -1,7 +1,7 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.0) project(cmake_wrapper) include("conanbuildinfo.cmake") -conan_basic_setup() +conan_basic_setup(KEEP_RPATHS) add_subdirectory("source_subfolder") diff --git a/recipes/openjpeg/all/conandata.yml b/recipes/openjpeg/all/conandata.yml index a295ca91ddf1d..493a3363ea6e3 100644 --- a/recipes/openjpeg/all/conandata.yml +++ b/recipes/openjpeg/all/conandata.yml @@ -5,3 +5,10 @@ sources: "2.3.1": url: "https://github.com/uclouvain/openjpeg/archive/v2.3.1.tar.gz" sha256: "63f5a4713ecafc86de51bfad89cc07bb788e9bba24ebbf0c4ca637621aadb6a9" +patches: + "2.4.0": + - patch_file: "patches/0001-relocatable-shared-macos-2.4.0.patch" + base_path: "source_subfolder" + "2.3.1": + - patch_file: "patches/0001-relocatable-shared-macos-2.3.1.patch" + base_path: "source_subfolder" diff --git a/recipes/openjpeg/all/conanfile.py b/recipes/openjpeg/all/conanfile.py index b9c3a9241aeb5..afbf21a718a52 100644 --- a/recipes/openjpeg/all/conanfile.py +++ b/recipes/openjpeg/all/conanfile.py @@ -25,7 +25,6 @@ class OpenjpegConan(ConanFile): "build_codec": False, } - exports_sources = "CMakeLists.txt" generators = "cmake" _cmake = None @@ -33,6 +32,11 @@ class OpenjpegConan(ConanFile): def _source_subfolder(self): return "source_subfolder" + def export_sources(self): + self.copy("CMakeLists.txt") + for patch in self.conan_data.get("patches", {}).get(self.version, []): + self.copy(patch["patch_file"]) + def config_options(self): if self.settings.os == "Windows": del self.options.fPIC @@ -73,6 +77,8 @@ def _configure_cmake(self): return self._cmake def build(self): + for patch in self.conan_data.get("patches", {}).get(self.version, []): + tools.patch(**patch) cmake = self._configure_cmake() cmake.build() @@ -81,6 +87,8 @@ def package(self): cmake.install() self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder) tools.rmdir(os.path.join(self.package_folder, "lib", self._openjpeg_subdir)) + + # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed self._create_cmake_module_alias_targets( os.path.join(self.package_folder, self._module_file_rel_path), {"openjp2": "OpenJPEG::OpenJPEG"} @@ -98,14 +106,9 @@ def _create_cmake_module_alias_targets(module_file, targets): """.format(alias=alias, aliased=aliased)) tools.save(module_file, content) - @property - def _module_subfolder(self): - return os.path.join("lib", "cmake") - @property def _module_file_rel_path(self): - return os.path.join(self._module_subfolder, - "conan-official-{}-targets.cmake".format(self.name)) + return os.path.join("lib", "cmake", "conan-official-{}-targets.cmake".format(self.name)) @property def _openjpeg_subdir(self): @@ -128,7 +131,6 @@ def package_info(self): # TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed self.cpp_info.names["cmake_find_package"] = "OpenJPEG" self.cpp_info.names["cmake_find_package_multi"] = "OpenJPEG" - self.cpp_info.builddirs.append(self._module_subfolder) self.cpp_info.build_modules["cmake_find_package"] = [self._module_file_rel_path] self.cpp_info.build_modules["cmake_find_package_multi"] = [self._module_file_rel_path] self.cpp_info.names["pkg_config"] = "libopenjp2" diff --git a/recipes/openjpeg/all/patches/0001-relocatable-shared-macos-2.3.1.patch b/recipes/openjpeg/all/patches/0001-relocatable-shared-macos-2.3.1.patch new file mode 100644 index 0000000000000..4ab5eac8456a1 --- /dev/null +++ b/recipes/openjpeg/all/patches/0001-relocatable-shared-macos-2.3.1.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -154,7 +154,7 @@ if(NOT OPENJPEG_INSTALL_PACKAGE_DIR) + set(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}") + endif() + +-if (APPLE) ++if (0) + list(APPEND OPENJPEG_LIBRARY_PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_LIB_DIR}") + option(OPJ_USE_DSYMUTIL "Call dsymutil on binaries after build." OFF) + endif() diff --git a/recipes/openjpeg/all/patches/0001-relocatable-shared-macos-2.4.0.patch b/recipes/openjpeg/all/patches/0001-relocatable-shared-macos-2.4.0.patch new file mode 100644 index 0000000000000..78732d60a1026 --- /dev/null +++ b/recipes/openjpeg/all/patches/0001-relocatable-shared-macos-2.4.0.patch @@ -0,0 +1,11 @@ +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -155,7 +155,7 @@ if(NOT OPENJPEG_INSTALL_PACKAGE_DIR) + set(OPENJPEG_INSTALL_PACKAGE_DIR "${OPENJPEG_INSTALL_LIB_DIR}/${OPENJPEG_INSTALL_SUBDIR}") + endif() + +-if (APPLE) ++if (0) + list(APPEND OPENJPEG_LIBRARY_PROPERTIES INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${OPENJPEG_INSTALL_LIB_DIR}") + option(OPJ_USE_DSYMUTIL "Call dsymutil on binaries after build." OFF) + endif()