Repository: conan-io/conan-center-index

Issue:
[request] openjpeg's dependencies should be optional or removed
<!-- What is your question? Please be as specific as possible! -->

Package: **openjpeg/2.3.1**

openjpeg is declared to depend on lcms, libpng, libtiff, and zlib, but from my understanding the library itself doesn't depend on them, only the encoder/decoder. I would hazard to guess that many (most?) people getting it from conan are only interested in linking with openjpeg, which makes these dependencies unnecessary.

Namely, from the readme:

> Note 3 : OpenJPEG encoder and decoder (not the library itself !) depends on several libraries: png, tiff, lcms, z.

Ergo, if you only want the library, this has no dependencies!

I'm in the process of moving our submodule/CMake target-based dependency behemoth to conan, and this is something of a blocker for me because some of these dependencies are based on autotools and I've been unable to build them for the iOS simulator (namely lcms, but maybe more). Maybe that's a bug or maybe it's a problem with my setup, but I think I should be able to sidestep the whole issue if I could tell openjpeg to not depend on it at all, which is what our current (pre-conan) build process does. Openjpeg itself is a dependency of a dependency of my project, so while I can simply write my own recipe, I'd rather not introduce too many overrides. Plus, I think this is reasonable to have upstream, but I'm not privy on how configurable conan-center-index is supposed to be.


Discussion:
There was no "package change request" option, and this isn't a bug really nor a new version nor a new package so I just filed as a question as a request is kind of a question? 😉 
I see, you are right. The problem is that package contains both library and executable. We can split this package by two (openjpeg and libopenjpeg), or create an option to package the library.

/cc @danimtb @SSE4 
Do people really care about the executable? Are we using that as a tool/build requirement in any other recipe? If the answer is no and the library can be built without the executable, IMO we should drop the executable and its dependencies
I would like to drop. I've checked VCPKG, they only distribute the library. However, Conda distribute both. As you know, distributing executable requires arch_build, os_build and all stuff for cross-building.

I gonna open a PR dropping the executables

Resolving patch:
diff --git a/recipes/openjpeg/all/conanfile.py b/recipes/openjpeg/all/conanfile.py
--- a/recipes/openjpeg/all/conanfile.py
+++ b/recipes/openjpeg/all/conanfile.py
@@ -18,16 +18,9 @@ class OpenjpegConan(ConanFile):
 
     _source_subfolder = "source_subfolder"
 
-    requires = (
-        "zlib/1.2.11",
-        "lcms/2.9",
-        "libpng/1.6.37",
-        "libtiff/4.0.9"
-    )
-
     def config_options(self):
         if self.settings.os == "Windows":
-            self.options.remove("fPIC")
+            del self.options.fPIC
 
     def configure(self):
         del self.settings.compiler.libcxx
@@ -44,6 +37,7 @@ def _configure_cmake(self):
         cmake.definitions['BUILD_STATIC_LIBS'] = not self.options.shared
         cmake.definitions['BUILD_PKGCONFIG_FILES'] = False
         cmake.definitions['CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP'] = True
+        cmake.definitions['BUILD_CODEC'] = False
 
         cmake.configure()
         return cmake
@@ -107,5 +101,5 @@ def package_info(self):
         if not self.options.shared:
             self.cpp_info.defines.append('OPJ_STATIC')
         if self.settings.os == "Linux":
-            self.cpp_info.libs.append("pthread")
+            self.cpp_info.system_libs = ["pthread", "m"]
         self.cpp_info.name = 'OpenJPEG'


Test patch: