Repository: conan-io/conan-center-index

Issue:
[package]libarchive/3.6.2: install failed when libarchive:with_lzma=True
### Description

conan fail to install when libarchive:with_lzma=True


### Package and Environment Details

* Package Name/Version: **libarchive/3.6.2**
* Operating System+version: **Windows 10**
* Compiler+version: **Visual Studio 2019 community**
* Docker image: **-**
* Conan version: **conan 1.58.0**
* Python version: **Python 3.11.2**


### Conan profile

[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

conanfile.txt
```
[requires]
libarchive/3.6.2

[generators]
cmake

[options]
libarchive:with_lzma=True
```

```
conan install .
```

### Logs

<details><summary>Click to expand log</summary>

```
libarchive/3.6.2: Aggregating env generators
libarchive/3.6.2: Calling build()
libarchive/3.6.2: Apply patch (portability): Remove broken ZLIB WINAPI check
libarchive/3.6.2: Apply patch (conan): Make CMake build-system compatible with Conan
libarchive/3.6.2: Apply patch (conan): Patch try_compile check to work with imported CMake targets from Conan packages
libarchive/3.6.2: CMake command: cmake -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="C:/Users/Administrator/.conan/data/libarchive/3.6.2/_/_/build/49afe400141ef1a7f97d87714584ed5fbdc0e018/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/Administrator/.conan/data/libarchive/3.6.2/_/_/package/49afe400141ef1a7f97d87714584ed5fbdc0e018" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "C:\Users\Administrator\.conan\data\libarchive\3.6.2\_\_\build\49afe400141ef1a7f97d87714584ed5fbdc0e018\src"
-- Using Conan toolchain: C:/Users/Administrator/.conan/data/libarchive/3.6.2/_/_/build/49afe400141ef1a7f97d87714584ed5fbdc0e018/build/generators/conan_toolchain.cmake
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.17763.
-- The C compiler identification is MSVC 19.29.30147.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Conan: Target declared 'ZLIB::ZLIB'
-- Conan: Target declared 'LibLZMA::LibLZMA'
-- Conan: Including build module from 'C:/Users/Administrator/.conan/data/xz_utils/5.4.0/_/_/package/3fb49604f9c2f729b85ba3115852006824e72cab/lib/cmake/conan-official-xz_utils-variables.cmake'
-- Performing Test WITHOUT_LZMA_API_STATIC
CMake Error at C:/Users/Administrator/.conan/data/libarchive/3.6.2/_/_/build/49afe400141ef1a7f97d87714584ed5fbdc0e018/build/CMakeFiles/CMakeTmp/CMakeLists.txt:18 (add_executable):
  Target "cmTC_4d530" links to target "CONAN_LIB::xz_utils_lzma_RELEASE" but
  the target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?


CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/CheckCSourceCompiles.cmake:109 (try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  CMakeLists.txt:370 (CHECK_C_SOURCE_COMPILES)
  CMakeLists.txt:498 (TRY_MACRO_FOR_LIBRARY)


-- Configuring incomplete, errors occurred!
See also "C:/Users/Administrator/.conan/data/libarchive/3.6.2/_/_/build/49afe400141ef1a7f97d87714584ed5fbdc0e018/build/CMakeFiles/CMakeOutput.log".
libarchive/3.6.2:
libarchive/3.6.2: ERROR: Package '49afe400141ef1a7f97d87714584ed5fbdc0e018' build failed
libarchive/3.6.2: WARN: Build folder C:\Users\Administrator\.conan\data\libarchive\3.6.2\_\_\build\49afe400141ef1a7f97d87714584ed5fbdc0e018\build
ERROR: libarchive/3.6.2: Error in build() method, line 162
        cmake.configure()
        ConanException: Error 1 while executing cmake -G "Visual Studio 16 2019" -DCMAKE_TOOLCHAIN_FILE="C:/Users/Administrator/.conan/data/libarchive/3.6.2/_/_/build/49afe400141ef1a7f97d87714584ed5fbdc0e018/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/Administrator/.conan/data/libarchive/3.6.2/_/_/package/49afe400141ef1a7f97d87714584ed5fbdc0e018" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "C:\Users\Administrator\.conan\data\libarchive\3.6.2\_\_\build\49afe400141ef1a7f97d87714584ed5fbdc0e018\src"
```

</details>



Discussion:

Resolving patch:
diff --git a/recipes/libarchive/all/conanfile.py b/recipes/libarchive/all/conanfile.py
--- a/recipes/libarchive/all/conanfile.py
+++ b/recipes/libarchive/all/conanfile.py
@@ -85,13 +85,13 @@ def requirements(self):
         if self.options.with_bzip2:
             self.requires("bzip2/1.0.8")
         if self.options.with_libxml2:
-            self.requires("libxml2/2.10.4")
+            self.requires("libxml2/2.11.4")
         if self.options.with_expat:
             self.requires("expat/2.5.0")
         if self.options.with_iconv:
             self.requires("libiconv/1.17")
         if self.options.with_pcreposix:
-            self.requires("pcre/8.45")
+            self.requires("pcre/10.42")
         if self.options.with_nettle:
             self.requires("nettle/3.8.1")
         if self.options.with_openssl:
@@ -154,6 +154,9 @@ def generate(self):
         if Version(self.version) >= "3.4.2":
             tc.variables["ENABLE_MBEDTLS"] = self.options.with_mbedtls
         tc.variables["ENABLE_XATTR"] = self.options.with_xattr
+        # TODO: Remove after fixing https://github.com/conan-io/conan/issues/12012
+        if is_msvc(self):
+            tc.cache_variables["CMAKE_TRY_COMPILE_CONFIGURATION"] = str(self.settings.build_type)
         tc.generate()
 
     def build(self):


Test patch: