Repository: conan-io/conan-center-index

Issue:
[package] mimalloc/2.0.9: build error MSVC x86 shared=False
### Description

mimalloc fails to build when using option `shared=False` on MSVC x86

### Package and Environment Details

* Package Name/Version: **mimalloc/2.0.9**
* Operating System+version: **Windows 10**
* Compiler+version: **VS2017**
* Conan version: **conan 1.58.0**
* Python version: **Python 3.10.6**


### Conan profile

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

### Steps to reproduce

conan install mimalloc/2.0.9@ --build -s "arch=x86" -o "shared=False"

### Logs

<details><summary>Click to expand log</summary>

```
Configuration:
[settings]
arch=x86
arch_build=x86_64
build_type=Release
compiler=Visual Studio
compiler.runtime=MD
compiler.version=15
os=Windows
os_build=Windows
[options]
shared=False
[build_requires]
[env]

mimalloc/2.0.9: Forced build from source
Installing package: mimalloc/2.0.9
Requirements
    mimalloc/2.0.9 from 'conancenter' - Cache
Packages
    mimalloc/2.0.9:2bb76c9adac7b8cd7c5e3b377ac9f06934aba606 - Build

Cross-build from 'Windows:x86_64' to 'Windows:x86'
Installing (downloading, building) binaries...
mimalloc/2.0.9: Copying sources to build folder
mimalloc/2.0.9: Building your package in C:\Users\robbert.segeren\.conan\data\mimalloc\2.0.9\_\_\build\2bb76c9adac7b8cd7c5e3b377ac9f06934aba606
mimalloc/2.0.9: Generator txt created conanbuildinfo.txt
mimalloc/2.0.9: Calling generate()
mimalloc/2.0.9: WARN: Using the new toolchains and generators without specifying a build profile (e.g: -pr:b=default) is discouraged and might cause failures and unexpected behavior
mimalloc/2.0.9: Preset 'default' added to CMakePresets.json. Invoke it manually using 'cmake --preset default'
mimalloc/2.0.9: If your CMake version is not compatible with CMakePresets (<3.19) call cmake like: 'cmake <path> -G "Visual Studio 15 2017" -DCMAKE_TOOLCHAIN_FILE=C:\Users\robbert.segeren\.conan\data\mimalloc\2.0.9\_\_\build\2bb76c9adac7b8cd7c5e3b377ac9f06934aba606\build\generators\conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW'
mimalloc/2.0.9: Aggregating env generators
mimalloc/2.0.9: Calling build()
mimalloc/2.0.9: Apply patch (conan): fix install paths
mimalloc/2.0.9: Apply patch (portability): fix compilation errors on older compilers
mimalloc/2.0.9: 
mimalloc/2.0.9: ERROR: Package '2bb76c9adac7b8cd7c5e3b377ac9f06934aba606' build failed
mimalloc/2.0.9: WARN: Build folder C:\Users\robbert.segeren\.conan\data\mimalloc\2.0.9\_\_\build\2bb76c9adac7b8cd7c5e3b377ac9f06934aba606\build
ERROR: mimalloc/2.0.9: Error in build() method, line 143
        replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
        ConanException: replace_in_file didn't find pattern 'mimalloc-redirect.lib' in 'C:\Users\robbert.segeren\.conan\data\mimalloc\2.0.9\_\_\build\2bb76c9adac7b8cd7c5e3b377ac9f06934aba606\src\CMakeLists.txt' file.
```
</details>



Discussion:

Resolving patch:
diff --git a/recipes/mimalloc/all/conanfile.py b/recipes/mimalloc/all/conanfile.py
--- a/recipes/mimalloc/all/conanfile.py
+++ b/recipes/mimalloc/all/conanfile.py
@@ -139,7 +139,7 @@ def generate(self):
 
     def build(self):
         apply_conandata_patches(self)
-        if is_msvc(self) and self.settings.arch == "x86":
+        if is_msvc(self) and self.settings.arch == "x86" and self.options.shared:
             replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
                             "mimalloc-redirect.lib",
                             "mimalloc-redirect32.lib")


Test patch: