Repository: conan-io/conan-center-index

Issue:
[package] xerces-c/ALL: Option to disable the network stack is missing
### Description

The xerces-c library allows to disable its network stack completely, but this option is missing in the conanfile.

### Package and Environment Details

This applies to all versions on all compilers and operating systems.

* Package Name/Version: **xerces-c/ALL**

### Conan profile

[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
build_type=Release
compiler.cppstd=17
[options]
[conf]
[build_requires]
[env]

### Steps to reproduce

Not relevant.

### Logs

Not relevant.


Discussion:

Resolving patch:
diff --git a/recipes/xerces-c/all/conanfile.py b/recipes/xerces-c/all/conanfile.py
--- a/recipes/xerces-c/all/conanfile.py
+++ b/recipes/xerces-c/all/conanfile.py
@@ -26,6 +26,7 @@ class XercesCConan(ConanFile):
         "fPIC": [True, False],
         # https://xerces.apache.org/xerces-c/build-3.html
         "char_type": ["uint16_t", "char16_t", "wchar_t"],
+        "network": [True, False],
         "network_accessor": ["curl", "socket", "cfurl", "winsock"],
         "transcoder": ["gnuiconv", "iconv", "icu", "macosunicodeconverter", "windows"],
         "message_loader": ["inmemory", "icu", "iconv"],
@@ -35,6 +36,7 @@ class XercesCConan(ConanFile):
         "shared": False,
         "fPIC": True,
         "char_type": "uint16_t",
+        "network": True,
         "network_accessor": "socket",
         "transcoder": "gnuiconv",
         "message_loader": "inmemory",
@@ -64,6 +66,8 @@ def config_options(self):
     def configure(self):
         if self.options.shared:
             self.options.rm_safe("fPIC")
+        if not self.options.network:
+            self.options.rm_safe("network_accessor")
 
     def layout(self):
         cmake_layout(self, src_folder="src")
@@ -71,7 +75,7 @@ def layout(self):
     def requirements(self):
         if "icu" in (self.options.transcoder, self.options.message_loader):
             self.requires("icu/74.2")
-        if self.options.network_accessor == "curl":
+        if self.options.get_safe("network_accessor") == "curl":
             self.requires("libcurl/[>=7.78.0 <9]")
 
     def _validate(self, option, value, host_os):
@@ -84,7 +88,7 @@ def _validate(self, option, value, host_os):
         :param os: either a single string or a tuple of strings containing the
                    OS(es) that `value` is valid on
         """
-        if self.settings.os not in host_os and getattr(self.options, option) == value:
+        if self.settings.os not in host_os and self.options.get_safe(option) == value:
             raise ConanInvalidConfiguration(f"Option '{option}={value}' is only supported on {host_os}")
 
     def validate(self):
@@ -117,13 +121,15 @@ def generate(self):
         # Because upstream overrides BUILD_SHARED_LIBS as a CACHE variable
         tc.cache_variables["BUILD_SHARED_LIBS"] = "ON" if self.options.shared else "OFF"
         # https://xerces.apache.org/xerces-c/build-3.html
-        tc.variables["network-accessor"] = self.options.network_accessor
+        tc.variables["network"] =  self.options.network
+        if self.options.network:
+            tc.variables["network-accessor"] = self.options.network_accessor
         tc.variables["transcoder"] = self.options.transcoder
         tc.variables["message-loader"] = self.options.message_loader
         tc.variables["xmlch-type"] = self.options.char_type
         tc.variables["mutex-manager"] = self.options.mutex_manager
         # avoid picking up system dependency
-        tc.variables["CMAKE_DISABLE_FIND_PACKAGE_CURL"] = self.options.network_accessor != "curl"
+        tc.variables["CMAKE_DISABLE_FIND_PACKAGE_CURL"] = self.options.get_safe("network_accessor") != "curl"
         tc.variables["CMAKE_DISABLE_FIND_PACKAGE_ICU"] = "icu" not in (self.options.transcoder, self.options.message_loader)
         tc.generate()
         deps = CMakeDeps(self)


Test patch: