Repository: conan-io/conan-center-index

Issue:
[package] libxml/2.9.12: can't be built with ICU on Windows
### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **libxml/2.9.12**
  * Operating System+version: **Windows 10**
  * Compiler+version: **Visual Studio 2019**
  * Conan version: **conan 1.43.0**
  * Python version: **Python 3.9.1**


### 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]
[conf]
[build_requires]
[env]
```


### Steps to reproduce (Include if Applicable)
....conan-center-index\recipes\libxml2\all>conan create . 2.9.12@ -o *:icu=True -o *:iconv=False


### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
[HOOK - conan-center.py] pre_export(): [DEPRECATED GLOBAL CPPSTD (KB-H001)] OK
[HOOK - conan-center.py] pre_export(): [REFERENCE LOWERCASE (KB-H002)] OK
[HOOK - conan-center.py] pre_export(): [RECIPE METADATA (KB-H003)] OK
[HOOK - conan-center.py] pre_export(): [HEADER_ONLY, NO COPY SOURCE (KB-H005)] OK
[HOOK - conan-center.py] pre_export(): [FPIC OPTION (KB-H006)] OK
[HOOK - conan-center.py] pre_export(): [VERSION RANGES (KB-H008)] OK
[HOOK - conan-center.py] pre_export(): [RECIPE FOLDER SIZE (KB-H009)] Total recipe size: 22.7021484375 KB
[HOOK - conan-center.py] pre_export(): [RECIPE FOLDER SIZE (KB-H009)] OK
[HOOK - conan-center.py] pre_export(): [EXPORT LICENSE (KB-H023)] exports: None
[HOOK - conan-center.py] pre_export(): [EXPORT LICENSE (KB-H023)] exports: None
[HOOK - conan-center.py] pre_export(): [EXPORT LICENSE (KB-H023)] OK
[HOOK - conan-center.py] pre_export(): [TEST PACKAGE FOLDER (KB-H024)] OK
[HOOK - conan-center.py] pre_export(): [META LINES (KB-H025)] OK
[HOOK - conan-center.py] pre_export(): [CONAN CENTER INDEX URL (KB-H027)] OK
[HOOK - conan-center.py] pre_export(): [CMAKE MINIMUM VERSION (KB-H028)] OK
[HOOK - conan-center.py] pre_export(): [TEST PACKAGE - RUN ENVIRONMENT (KB-H029)] OK
[HOOK - conan-center.py] pre_export(): [SYSTEM REQUIREMENTS (KB-H032)] OK
[HOOK - conan-center.py] pre_export(): [CONANDATA.YML FORMAT (KB-H030)] OK
[HOOK - conan-center.py] pre_export(): [TEST PACKAGE - NO IMPORTS() (KB-H034)] OK
[HOOK - conan-center.py] pre_export(): [NO AUTHOR (KB-H037)] OK
[HOOK - conan-center.py] pre_export(): [NO TARGET NAME (KB-H040)] OK
[HOOK - conan-center.py] pre_export(): [NO FINAL ENDLINE (KB-H041)] OK
[HOOK - conan-center.py] pre_export(): [NO REQUIRES.ADD() (KB-H044)] OK
[HOOK - conan-center.py] pre_export(): [DELETE OPTIONS (KB-H045)] OK
[HOOK - conan-center.py] pre_export(): [NO ASCII CHARACTERS (KB-H047)] OK
[HOOK - conan-center.py] pre_export(): [CMAKE VERBOSE MAKEFILE (KB-H046)] OK
[HOOK - conan-center.py] pre_export(): [CMAKE VERSION REQUIRED (KB-H048)] OK
[HOOK - conan-center.py] pre_export(): [CMAKE WINDOWS EXPORT ALL SYMBOLS (KB-H049)] OK
[HOOK - conan-center.py] pre_export(): [DEFAULT OPTIONS AS DICTIONARY (KB-H051)] OK
[HOOK - conan-center.py] pre_export(): [CONFIG.YML HAS NEW VERSION (KB-H052)] OK
[HOOK - conan-center.py] pre_export(): [PRIVATE IMPORTS (KB-H053)] OK
[HOOK - conan-center.py] pre_export(): [SINGLE REQUIRES (KB-H055)] OK
Exporting package recipe
libxml2/2.9.12 exports: File 'conandata.yml' found. Exporting it...
libxml2/2.9.12 exports: Copied 1 '.yml' file: conandata.yml
[HOOK - conan-center.py] post_export(): [CONANDATA.YML REDUCE (KB-H031)] Saving conandata.yml: {'sources': {'2.9.12': {'sha256': 'c8d6681e38c56f172892c85ddc0852e1fd4b53b4209e7f4ebf17f7e2eae71d92', 'url': 'http://xmlsoft.org/sources/libxml2-2.9.12.tar.gz'}}}
[HOOK - conan-center.py] post_export(): [CONANDATA.YML REDUCE (KB-H031)] New conandata.yml contents: sources:
  2.9.12:
    sha256: c8d6681e38c56f172892c85ddc0852e1fd4b53b4209e7f4ebf17f7e2eae71d92
    url: http://xmlsoft.org/sources/libxml2-2.9.12.tar.gz

[HOOK - conan-center.py] post_export(): [CONANDATA.YML REDUCE (KB-H031)] OK
[HOOK - conan-center.py] post_export(): [DEFAULT SHARED OPTION VALUE (KB-H050)] OK
[HOOK - conan-center.py] post_export(): [LICENSE PUBLIC DOMAIN (KB-H056)] OK
libxml2/2.9.12: A new conanfile.py version was exported
libxml2/2.9.12: Folder: C:\Users\Nekto\.conan\data\libxml2\2.9.12\_\_\export
libxml2/2.9.12: Exported revision: 66e51d2b651de2a1f9511ca62f467534
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=16
os=Windows
os_build=Windows
[options]
*:iconv=False
*:icu=True
[build_requires]
[env]

libxml2/2.9.12: Forced build from source
libxml2/2.9.12 (test package): Installing package
Requirements
    icu/69.1 from 'conan-center' - Cache
    libxml2/2.9.12 from local cache - Cache
    zlib/1.2.11 from 'conan-center' - Cache
Packages
    icu/69.1:58b8d8ffb1d460eb92d3f938d6adbc4116ffeeae - Cache
    libxml2/2.9.12:99789c3494eb53433d30bac8f0d05e3a8d71d234 - Build
    zlib/1.2.11:3fb49604f9c2f729b85ba3115852006824e72cab - Cache

Installing (downloading, building) binaries...
icu/69.1: Already installed!
icu/69.1: Appending PATH environment variable: C:\Users\Nekto\.conan\data\icu\69.1\_\_\package\58b8d8ffb1d460eb92d3f938d6adbc4116ffeeae\bin
[HOOK - conan-center.py] post_package_info(): [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)] OK
[HOOK - conan-center.py] post_package_info(): [LIBRARY DOES NOT EXIST (KB-H054)] OK
zlib/1.2.11: Already installed!
[HOOK - conan-center.py] post_package_info(): [CMAKE FILE NOT IN BUILD FOLDERS (KB-H019)] OK
[HOOK - conan-center.py] post_package_info(): [LIBRARY DOES NOT EXIST (KB-H054)] OK
[HOOK - conan-center.py] pre_source(): [IMMUTABLE SOURCES (KB-H010)] OK
libxml2/2.9.12: Configuring sources in C:\Users\Nekto\.conan\data\libxml2\2.9.12\_\_\source
Downloading libxml2-2.9.12.tar.gz completed [5548.47k]

[HOOK - conan-center.py] post_source(): [LIBCXX MANAGEMENT (KB-H011)] OK
[HOOK - conan-center.py] post_source(): [CPPSTD MANAGEMENT (KB-H022)] OK
libxml2/2.9.12: Copying sources to build folder
libxml2/2.9.12: Building your package in C:\Users\Nekto\.conan\data\libxml2\2.9.12\_\_\build\99789c3494eb53433d30bac8f0d05e3a8d71d234
libxml2/2.9.12: Generator pkg_config created zlib.pc
libxml2/2.9.12: Generator pkg_config created icu-data.pc
libxml2/2.9.12: Generator pkg_config created icu-uc.pc
libxml2/2.9.12: Generator pkg_config created icu-i18n.pc
libxml2/2.9.12: Generator pkg_config created icu-tu.pc
libxml2/2.9.12: Generator pkg_config created icu-test.pc
libxml2/2.9.12: Generator pkg_config created icu-io.pc
libxml2/2.9.12: Generator pkg_config created icu-i18n-alias.pc
libxml2/2.9.12: Generator pkg_config created icu-data-alias.pc
libxml2/2.9.12: Generator pkg_config created icu.pc
libxml2/2.9.12: Aggregating env generators
[HOOK - conan-center.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] 'fPIC' option not found
[HOOK - conan-center.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] OK
libxml2/2.9.12: Calling build()
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.11.7
** Copyright (c) 2021 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
libxml2/2.9.12: cscript configure.js compiler=msvc prefix=C:\Users\Nekto\.conan\data\libxml2\2.9.12\_\_\package\99789c3494eb53433d30bac8f0d05e3a8d71d234 cruntime=/MD debug=no static=yes include="C:\Users\Nekto\.conan\data\zlib\1.2.11\_\_\package\3fb49604f9c2f729b85ba3115852006824e72cab\include;C:\Users\Nekto\.conan\data\icu\69.1\_\_\package\58b8d8ffb1d460eb92d3f938d6adbc4116ffeeae\include" lib="C:\Users\Nekto\.conan\data\zlib\1.2.11\_\_\package\3fb49604f9c2f729b85ba3115852006824e72cab\lib;C:\Users\Nekto\.conan\data\icu\69.1\_\_\package\58b8d8ffb1d460eb92d3f938d6adbc4116ffeeae\lib" c14n=yes catalog=yes docb=yes ftp=yes http=yes html=yes iconv=no icu=yes iso8859x=yes legacy=yes mem_debug=no output=yes pattern=yes push=yes python=no reader=yes regexps=yes run_debug=no sax1=yes schemas=yes schematron=yes threads=yes tree=yes valid=yes writer=yes xinclude=yes xpath=yes xptr=yes zlib=yes lzma=no
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.

libxml2 version: 2.9.12
Created Makefile.
Created config.h.

XML processor configuration
---------------------------
              Trio: no
     Thread safety: yes
        FTP client: yes
       HTTP client: yes
    HTML processor: yes
      C14N support: yes
   Catalog support: yes
   DocBook support: yes
     XPath support: yes
  XPointer support: yes
  XInclude support: yes
     iconv support: no
     icu   support: yes
  iso8859x support: yes
      zlib support: yes
      lzma support: no
  Debugging module: yes
  Memory debugging: no
 Runtime debugging: no
    Regexp support: yes
    Module support: yes
      Tree support: yes
    Reader support: yes
    Writer support: yes
    Walker support: yes
   Pattern support: yes
      Push support: yes
Validation support: yes
      SAX1 support: yes
    Legacy support: yes
    Output support: yes
XML Schema support: yes
Schematron support: yes
   Python bindings: no

Win32 build configuration
-------------------------
          Compiler: msvc
  C-Runtime option: /MD
    Embed Manifest: no
     Debug symbols: no
    Static xmllint: yes
    Install prefix: C:\Users\Nekto\.conan\data\libxml2\2.9.12\_\_\package\99789c3494eb53433d30bac8f0d05e3a8d71d234
      Put tools in: $(PREFIX)\bin
    Put headers in: $(PREFIX)\include
Put static libs in: $(PREFIX)\lib
Put shared libs in: $(PREFIX)\bin
      Include path: C:\Users\Nekto\.conan\data\zlib\1.2.11\_\_\package\3fb49604f9c2f729b85ba3115852006824e72cab\include;C:\Users\Nekto\.conan\data\icu\69.1\_\_\package\58b8d8ffb1d460eb92d3f938d6adbc4116ffeeae\include
          Lib path: C:\Users\Nekto\.conan\data\zlib\1.2.11\_\_\package\3fb49604f9c2f729b85ba3115852006824e72cab\lib;C:\Users\Nekto\.conan\data\icu\69.1\_\_\package\58b8d8ffb1d460eb92d3f938d6adbc4116ffeeae\lib


Microsoft (R) Program Maintenance Utility Version 14.29.30137.0
Copyright (C) Microsoft Corporation.  All rights reserved.

        if not exist bin.msvc mkdir bin.msvc
        if not exist int.msvc mkdir int.msvc
        cl.exe /EP /nologo /I..\include /D "NOLIBTOOL" /D "_REENTRANT"  libxml2.def.src > int.msvc\libxml2.def
libxml2.def.src
        rc -Fo int.msvc\libxml2.res libxml2.rc
Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Copyright (C) Microsoft Corporation.  All rights reserved.

        cl.exe /nologo /D "_WINDOWS" /D "_MBCS" /D "NOLIBTOOL" /W3 /wd4244 /wd4267 /MD /I.. /I..\include /IC:\Users\Nekto\.conan\data\libxml2\2.9.12\_\_\package\99789c3494eb53433d30bac8f0d05e3a8d71d234\include /D "_REENTRANT" /D "HAVE_WIN32_THREADS" /D "HAVE_COMPILER_TLS" /D_CRT_SECURE_NO_DEPRECATE /D_CRT_NONSTDC_NO_DEPRECATE /D "NDEBUG" /O2  /Foint.msvc\ /c ..\buf.c ..\c14n.c ..\catalog.c ..\chvalid.c ..\debugXML.c ..\dict.c ..\DOCBparser.c ..\encoding.c ..\entities.c ..\error.c ..\globals.c ..\hash.c ..\HTMLparser.c ..\HTMLtree.c ..\legacy.c ..\list.c ..\nanoftp.c ..\nanohttp.c ..\parser.c ..\parserInternals.c ..\pattern.c ..\relaxng.c ..\SAX2.c ..\SAX.c ..\schematron.c ..\threads.c ..\tree.c ..\uri.c ..\valid.c ..\xinclude.c ..\xlink.c ..\xmlIO.c ..\xmlmemory.c ..\xmlreader.c ..\xmlregexp.c ..\xmlmodule.c ..\xmlsave.c ..\xmlschemas.c ..\xmlschemastypes.c ..\xmlunicode.c ..\xmlwriter.c ..\xpath.c ..\xpointer.c ..\xmlstring.c
buf.c
c14n.c
catalog.c
chvalid.c
debugXML.c
dict.c
DOCBparser.c
encoding.c
entities.c
error.c
globals.c
hash.c
HTMLparser.c
HTMLtree.c
legacy.c
list.c
nanoftp.c
..\nanoftp.c(927): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
..\nanoftp.c(929): warning C4996: 'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
nanohttp.c
parser.c
parserInternals.c
Generating Code...
Compiling...
pattern.c
relaxng.c
SAX2.c
SAX.c
schematron.c
threads.c
tree.c
uri.c
valid.c
xinclude.c
xlink.c
xmlIO.c
xmlmemory.c
xmlreader.c
xmlregexp.c
xmlmodule.c
xmlsave.c
xmlschemas.c
xmlschemastypes.c
xmlunicode.c
Generating Code...
Compiling...
xmlwriter.c
xpath.c
xpointer.c
xmlstring.c
Generating Code...
C:\Users\Nekto\.conan\data\libxml2\2.9.12\_\_\build\99789c3494eb53433d30bac8f0d05e3a8d71d234\source_subfolder\xpath.c(506) : warning C4723: potential divide by 0
C:\Users\Nekto\.conan\data\libxml2\2.9.12\_\_\build\99789c3494eb53433d30bac8f0d05e3a8d71d234\source_subfolder\xpath.c(505) : warning C4723: potential divide by 0
        link.exe /nologo /VERSION:2.9 /LIBPATH:bin.msvc /LIBPATH:C:\Users\Nekto\.conan\data\libxml2\2.9.12\_\_\package\99789c3494eb53433d30bac8f0d05e3a8d71d234\lib  /DLL  /IMPLIB:bin.msvc\libxml2.lib /OUT:bin.msvc\libxml2.dll int.msvc\buf.obj int.msvc\c14n.obj int.msvc\catalog.obj int.msvc\chvalid.obj int.msvc\debugXML.obj int.msvc\dict.obj int.msvc\DOCBparser.obj int.msvc\encoding.obj int.msvc\entities.obj int.msvc\error.obj int.msvc\globals.obj int.msvc\hash.obj int.msvc\HTMLparser.obj int.msvc\HTMLtree.obj int.msvc\legacy.obj int.msvc\list.obj int.msvc\nanoftp.obj int.msvc\nanohttp.obj int.msvc\parser.obj int.msvc\parserInternals.obj int.msvc\pattern.obj int.msvc\relaxng.obj int.msvc\SAX2.obj int.msvc\SAX.obj int.msvc\schematron.obj int.msvc\threads.obj int.msvc\tree.obj int.msvc\uri.obj int.msvc\valid.obj int.msvc\xinclude.obj int.msvc\xlink.obj int.msvc\xmlIO.obj int.msvc\xmlmemory.obj int.msvc\xmlreader.obj int.msvc\xmlregexp.obj int.msvc\xmlmodule.obj int.msvc\xmlsave.obj int.msvc\xmlschemas.obj int.msvc\xmlschemastypes.obj int.msvc\xmlunicode.obj int.msvc\xmlwriter.obj int.msvc\xpath.obj int.msvc\xpointer.obj int.msvc\xmlstring.obj int.msvc\libxml2.res  wsock32.lib ws2_32.lib sicuio.lib sicutest.lib sicutu.lib sicuin.lib sicuuc.lib sicudt.lib zlib.lib kernel32.lib
   Creating library bin.msvc\libxml2.lib and object bin.msvc\libxml2.exp
sicuuc.lib(wintz.ao) : error LNK2019: unresolved external symbol __imp_RegCloseKey referenced in function uprv_detectWindowsTimeZone
sicuuc.lib(wintz.ao) : error LNK2019: unresolved external symbol __imp_RegEnumKeyExW referenced in function uprv_detectWindowsTimeZone
sicuuc.lib(wintz.ao) : error LNK2019: unresolved external symbol __imp_RegOpenKeyExW referenced in function uprv_detectWindowsTimeZone
sicuuc.lib(wintz.ao) : error LNK2019: unresolved external symbol __imp_RegQueryInfoKeyW referenced in function uprv_detectWindowsTimeZone
sicuuc.lib(wintz.ao) : error LNK2019: unresolved external symbol __imp_RegQueryValueExW referenced in function uprv_detectWindowsTimeZone
bin.msvc\libxml2.dll : fatal error LNK1120: 5 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\link.exe"' : return code '0x460'
Stop.
libxml2/2.9.12:
libxml2/2.9.12: ERROR: Package '99789c3494eb53433d30bac8f0d05e3a8d71d234' build failed
libxml2/2.9.12: WARN: Build folder C:\Users\Nekto\.conan\data\libxml2\2.9.12\_\_\build\99789c3494eb53433d30bac8f0d05e3a8d71d234
ERROR: libxml2/2.9.12: Error in build() method, line 271
        self._build_msvc()
while calling '_build_msvc', line 167
        self.run("nmake /f Makefile.msvc libxml libxmla libxmladll")
        ConanException: Error 2 while executing nmake /f Makefile.msvc libxml libxmla libxmladll

```

</details>



Discussion:

Resolving patch:
diff --git a/recipes/libxml2/all/conanfile.py b/recipes/libxml2/all/conanfile.py
--- a/recipes/libxml2/all/conanfile.py
+++ b/recipes/libxml2/all/conanfile.py
@@ -1,5 +1,6 @@
 from conans import ConanFile, tools, AutoToolsBuildEnvironment, VisualStudioBuildEnvironment
 from contextlib import contextmanager
+import itertools
 import os
 import textwrap
 
@@ -149,7 +150,7 @@ def _build_msvc(self):
             def fix_library(option, package, old_libname):
                 if option:
                     libs = []
-                    for lib in self.deps_cpp_info[package].libs:
+                    for lib in itertools.chain(self.deps_cpp_info[package].libs, self.deps_cpp_info[package].system_libs):
                         libname = lib
                         if not libname.endswith('.lib'):
                             libname += '.lib'


Test patch: