Repository: conan-io/conan-center-index

Issue:
[package] xerces-c/3.2.3: xmlch-type should be a package option
<!-- 
  Please don't forget to update the issue title.
  Include all applicable information to help us reproduce your problem.
-->

### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **xerces-c/3.2.3**
  * Operating System+version: **Windows 10**
  * Compiler+version: **Visual Studio 2019**
  * Conan version: **conan 1.37.0**
  * Python version: **Python 3.9**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
build_type=Release
[options]
[build_requires]
*: cmake/3.19.6
[env]
```

According to the library [cmake-files](https://github.com/apache/xerces-c/blob/v3.2.3/cmake/XercesXMLCh.cmake) `xerces-c` supports `uint16_t`, `char16_t` and `wchar_t`, while the current [recipe supports only `uint16_t`](https://github.com/conan-io/conan-center-index/blob/c4f06bca2cf69dd5429f4867bced49872e4300a2/recipes/xerces-c/all/conanfile.py#L54).

The library, I am working on, uses `char16_t` for the `xmlch-type` and the build fails because the `xerces-c` recipe provides only `uint16_t` for `xmlch-type`:
`error C2440: '<function-style-cast>': cannot convert from 'const XMLCh *' to 'std::u16string'`

We need `xmlch-type` as an option so that the user could choose any of the types supported by `xerces-c`.


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
@@ -5,7 +5,9 @@
 
 class XercesCConan(ConanFile):
     name = "xerces-c"
-    description = "Xerces-C++ is a validating XML parser written in a portable subset of C++"
+    description = (
+        "Xerces-C++ is a validating XML parser written in a portable subset of C++"
+    )
     topics = ("conan", "xerces", "XML", "validation", "DOM", "SAX", "SAX2")
     url = "https://github.com/conan-io/conan-center-index"
     homepage = "http://xerces.apache.org/xerces-c/index.html"
@@ -13,7 +15,11 @@ class XercesCConan(ConanFile):
     exports_sources = ["CMakeLists.txt"]
     generators = "cmake"
     settings = "os", "arch", "compiler", "build_type"
-    options = {"shared": [True, False], "fPIC": [True, False], "char_type": ["uint16_t", "wchar_t"]}
+    options = {
+        "shared": [True, False],
+        "fPIC": [True, False],
+        "char_type": ["uint16_t", "char16_t", "wchar_t"],
+    }
     default_options = {"shared": False, "fPIC": True, "char_type": "uint16_t"}
 
     _cmake = None
@@ -25,11 +31,12 @@ def _source_subfolder(self):
     @property
     def _build_subfolder(self):
         return "build_subfolder"
-    
+
     def validate(self):
         if self.options.char_type == "wchar_t" and self.settings.os != "Windows":
-            raise ConanInvalidConfiguration("Option 'char_type=wchar_t' is only supported in Windows")
-
+            raise ConanInvalidConfiguration(
+                "Option 'char_type=wchar_t' is only supported in Windows"
+            )
 
     def config_options(self):
         if self.settings.os == "Windows":
@@ -51,19 +58,25 @@ def _configure_cmake(self):
             return self._cmake
         self._cmake = CMake(self)
         # https://xerces.apache.org/xerces-c/build-3.html
-        self._cmake.definitions["network-accessor"] = {"Windows": "winsock",
-                                                       "Macos": "cfurl",
-                                                       "Linux": "socket"}.get(str(self.settings.os))
-        self._cmake.definitions["transcoder"] = {"Windows": "windows",
-                                                 "Macos": "macosunicodeconverter",
-                                                 "Linux": "gnuiconv"}.get(str(self.settings.os))
+        self._cmake.definitions["network-accessor"] = {
+            "Windows": "winsock",
+            "Macos": "cfurl",
+            "Linux": "socket",
+        }.get(str(self.settings.os))
+        self._cmake.definitions["transcoder"] = {
+            "Windows": "windows",
+            "Macos": "macosunicodeconverter",
+            "Linux": "gnuiconv",
+        }.get(str(self.settings.os))
         self._cmake.definitions["message-loader"] = "inmemory"
 
         self._cmake.definitions["xmlch-type"] = self.options.char_type
 
-        self._cmake.definitions["mutex-manager"] = {"Windows": "windows",
-                                                    "Macos": "posix",
-                                                    "Linux": "posix"}.get(str(self.settings.os))
+        self._cmake.definitions["mutex-manager"] = {
+            "Windows": "windows",
+            "Macos": "posix",
+            "Linux": "posix",
+        }.get(str(self.settings.os))
         # avoid picking up system dependency
         self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_CURL"] = True
         self._cmake.definitions["CMAKE_DISABLE_FIND_PACKAGE_ICU"] = True


Test patch: