Repository: conan-io/conan-center-index

Issue:
[package] libmysqlclient: build fails on Windows when zlib:shared=True
### Package and Environment Details (include every applicable attribute)
  * Package Name/Version: **libmysqlclient**
  * Operating System+version: **Windows 21H1**
  * Compiler+version: **VS 16.11**
  * Conan version: **conan 1.40.3**
  * Python version: **Python 3.9.2**


### Conan profile (output of `conan profile show default` or `conan profile show <profile>` if custom profile is in use)
```
[settings]
arch=x86_64
build_type=Debug
compiler=Visual Studio
compiler.runtime=MDd
compiler.version=16
os=Windows
[options]
zlib:shared=True
[build_requires]
[env]
```


### Steps to reproduce (Include if Applicable)

``conan install  libmysqlclient/8.0.25@ -pr=windows-msvc-debug-x86_64 -b=libmysqlclient -o zlib:shared=True``

### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
build	30-Oct-2021 00:47:14	  comp_client_err.cc
build	30-Oct-2021 00:47:14	  errmsg.cc
build	30-Oct-2021 00:47:16	  comp_client_err.vcxproj -> C:\conan_tmp\.conan\data\libmysqlclient\8.0.25\_\_\build\b56dc90bfc420d5879d3c22e6aea2b9d78711b1d\runtime_output_directory\Debug\comp_client_err.exe
build	30-Oct-2021 00:47:16	  Generating ../include/mysqlclient_ername.h
build	30-Oct-2021 00:47:16	  Building Custom Rule C:/conan_tmp/.conan/data/libmysqlclient/8.0.25/_/_/build/b56dc90bfc420d5879d3c22e6aea2b9d78711b1d/source_subfolder/utilities/CMakeLists.txt
build	30-Oct-2021 00:47:16	  comp_err.vcxproj -> C:\conan_tmp\.conan\data\libmysqlclient\8.0.25\_\_\build\b56dc90bfc420d5879d3c22e6aea2b9d78711b1d\runtime_output_directory\Debug\comp_err.exe
build	30-Oct-2021 00:47:16	  Generating ../include/mysqld_error.h, ../include/mysqld_ername.h, ../include/mysqld_errmsg.h, ../share/english/errmsg.sys
build	30-Oct-2021 00:47:16	C:\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(241,5): error MSB8066: Custom build for 'C:\conan_tmp\.conan\data\libmysqlclient\8.0.25\_\_\build\b56dc90bfc420d5879d3c22e6aea2b9d78711b1d\CMakeFiles\28761cee53b45760a3c28f2a7ef783af\mysqld_error.h.rule;C:\conan_tmp\.conan\data\libmysqlclient\8.0.25\_\_\build\b56dc90bfc420d5879d3c22e6aea2b9d78711b1d\CMakeFiles\05891cb44278daea00ef6ec5c1c9948d\GenError.rule;C:\conan_tmp\.conan\data\libmysqlclient\8.0.25\_\_\build\b56dc90bfc420d5879d3c22e6aea2b9d78711b1d\source_subfolder\utilities\CMakeLists.txt' exited with code -1073741515. [C:\conan_tmp\.conan\data\libmysqlclient\8.0.25\_\_\build\b56dc90bfc420d5879d3c22e6aea2b9d78711b1d\utilities\GenError.vcxproj]
build	30-Oct-2021 00:47:16	libmysqlclient/8.0.25: 
error	30-Oct-2021 00:47:16	libmysqlclient/8.0.25: ERROR: Package 'b56dc90bfc420d5879d3c22e6aea2b9d78711b1d' build failed
error	30-Oct-2021 00:47:16	libmysqlclient/8.0.25: WARN: Build folder C:\conan_tmp\.conan\data\libmysqlclient\8.0.25\_\_\build\b56dc90bfc420d5879d3c22e6aea2b9d78711b1d
error	30-Oct-2021 00:47:16	ERROR: libmysqlclient/8.0.25: Error in build() method, line 154
error	30-Oct-2021 00:47:16		cmake.build()
error	30-Oct-2021 00:47:16		ConanException: Error 1 while executing cmake --build C:\conan_tmp\.conan\data\libmysqlclient\8.0.25\_\_\build\b56dc90bfc420d5879d3c22e6aea2b9d78711b1d --config Debug -- /m:12 /verbosity:minimal
```

</details>



Discussion:

Resolving patch:
diff --git a/recipes/libmysqlclient/all/conanfile.py b/recipes/libmysqlclient/all/conanfile.py
--- a/recipes/libmysqlclient/all/conanfile.py
+++ b/recipes/libmysqlclient/all/conanfile.py
@@ -151,11 +151,13 @@ def _configure_cmake(self):
     def build(self):
         self._patch_files()
         cmake = self._configure_cmake()
-        cmake.build()
+        with tools.run_environment(self):
+            cmake.build()
 
     def package(self):
         cmake = self._configure_cmake()
-        cmake.install()
+        with tools.run_environment(self):
+            cmake.install()
         os.mkdir(os.path.join(self.package_folder, "licenses"))
         tools.rename(os.path.join(self.package_folder, "LICENSE"), os.path.join(self.package_folder, "licenses", "LICENSE"))
         os.remove(os.path.join(self.package_folder, "README"))


Test patch: