Repository: conan-io/conan-center-index

Issue:
[package] libpq/13.2: needless option "with_zlib"
The recipe for libpq contains the option `with_zlib`, which is then passed as `--with-zlib` to the configure script of PostgreSQL.

However, zlib is not used at all in libpq (it is used in only in other parts of PostgreSQL, e.g. `pg_dump`).
libpq can be built completely without zlib, without any loss in functionality.

Therefore, the option `with_zlib` in the recipe for libpq is redundant. Enabling it, just adds an unnecessary dependency on zlib.
It can be completely removed, and `--without-zlib` always passed to the configure script of PostgreSQL.


Discussion:
related: #5020
@sabelka could you submit a PR with these modifications?
I'll try ;-)

Resolving patch:
diff --git a/recipes/libpq/all/conanfile.py b/recipes/libpq/all/conanfile.py
--- a/recipes/libpq/all/conanfile.py
+++ b/recipes/libpq/all/conanfile.py
@@ -15,14 +15,14 @@ class LibpqConan(ConanFile):
     options = {
         "shared": [True, False],
         "fPIC": [True, False],
-        "with_zlib": [True, False],
+        "with_zlib": [True, False, "deprecated"],
         "with_openssl": [True, False],
         "disable_rpath": [True, False]
     }
     default_options = {
         'shared': False,
         'fPIC': True,
-        'with_zlib': True,
+        'with_zlib': "deprecated",
         'with_openssl': False,
         'disable_rpath': False
     }
@@ -53,13 +53,19 @@ def config_options(self):
     def configure(self):
         del self.settings.compiler.libcxx
         del self.settings.compiler.cppstd
+
+        if self.options.shared:
+            del self.options.fPIC
+
         if self.settings.compiler != "Visual Studio" and self.settings.os == "Windows":
             if self.options.shared:
                 raise ConanInvalidConfiguration("static mingw build is not possible")
+        # Looking into source code, it appears that zlib is not used in libpq
+        if self.options.with_zlib != "deprecated":
+            self.output.warn("with_zlib option is deprecated, do not use anymore")
+        del self.options.with_zlib
 
     def requirements(self):
-        if self.options.with_zlib:
-            self.requires("zlib/1.2.11")
         if self.options.with_openssl:
             self.requires("openssl/1.1.1h")
 
@@ -72,7 +78,7 @@ def _configure_autotools(self):
         if not self._autotools:
             self._autotools = AutoToolsBuildEnvironment(self, win_bash=tools.os_info.is_windows)
             args = ['--without-readline']
-            args.append('--with-zlib' if self.options.with_zlib else '--without-zlib')
+            args.append('--without-zlib')
             args.append('--with-openssl' if self.options.with_openssl else '--without-openssl')
             if tools.cross_building(self.settings) and not self.options.with_openssl:
                 args.append("--disable-strong-random")
@@ -116,12 +122,6 @@ def build(self):
             tools.replace_in_file(msbuild_project_pm, "'MultiThreadedDLL'", "'%s'" % runtime)
             config_default_pl = os.path.join(self._source_subfolder, "src", "tools", "msvc", "config_default.pl")
             solution_pm = os.path.join(self._source_subfolder, "src", "tools", "msvc", "Solution.pm")
-            if self.options.with_zlib:
-                tools.replace_in_file(solution_pm,
-                                      "zdll.lib", "%s.lib" % self.deps_cpp_info["zlib"].libs[0])
-                tools.replace_in_file(config_default_pl,
-                                      "zlib      => undef",
-                                      "zlib      => '%s'" % self.deps_cpp_info["zlib"].rootpath.replace("\\", "/"))
             if self.options.with_openssl:
                 for ssl in ["VC\libssl32", "VC\libssl64", "libssl"]:
                     tools.replace_in_file(solution_pm,
@@ -226,9 +226,6 @@ def package_info(self):
 
         self.cpp_info.components["pq"].libs = [self._construct_library_name("pq")]
 
-        if self.options.with_zlib:
-            self.cpp_info.components["pq"].requires.append("zlib::zlib")
-
         if self.options.with_openssl:
             self.cpp_info.components["pq"].requires.append("openssl::openssl")
 


Test patch: