Skip to content

Commit

Permalink
(#9070) openjpeg: relocatable shared lib macos
Browse files Browse the repository at this point in the history
* cleanup

* relocatable shared lib on macOS
  • Loading branch information
SpaceIm authored Feb 1, 2022
1 parent 9e650a4 commit cb185c0
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
4 changes: 2 additions & 2 deletions recipes/openjpeg/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
7 changes: 7 additions & 0 deletions recipes/openjpeg/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
18 changes: 10 additions & 8 deletions recipes/openjpeg/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@ class OpenjpegConan(ConanFile):
"build_codec": False,
}

exports_sources = "CMakeLists.txt"
generators = "cmake"
_cmake = None

@property
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
Expand Down Expand Up @@ -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()

Expand All @@ -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"}
Expand All @@ -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):
Expand All @@ -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"
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit cb185c0

Please sign in to comment.