Repository: conan-io/conan-center-index
Issue: [package] libx265/3.2.1 build fail in file INSTALL cannot find x265.pdb mingw64

### Package and Environment Details
  * Package Name/Version: **libx265/3.2.1**
  * Operating System+version: **Windows 10**
  * Compiler+version: **gcc-mingw-w64-8.1.0**
  * Docker image: **conanio/gcc8.1**
  * Conan version: **conan 1.22.2**
  * Python version: **Python 3.7.5/none**


### Conan profile
```
Configuration:
[settings]
arch=x86_64
arch_build=x86_64
build_type=Debug
compiler=gcc
compiler.cppstd=14
compiler.exception=seh
compiler.libcxx=libstdc++11
compiler.threads=posix
compiler.version=8.1
os=Windows
os_build=Windows
[options]
[build_requires]
[env]
CONAN_CMAKE_GENERATOR=MinGW Makefiles
```
```
[requires]
libx265/3.2.1
```

### Steps to reproduce
Add package `libx265/3.2.1` to build in mingw64 windows env (no Visual Studio).
Fail in file INSTALL cannot find bin/x265.pdb:

```
CMake Error at source_subfolder/source/cmake_install.cmake:48 (file):
  file INSTALL cannot find
  "C:/Users/Home/.conan/data/libx265/3.2.1/_/_/build/e82f74c25b82d272dbcd1630371590cd62192d65/build_subfolder/bin/x265.pdb".
Call Stack (most recent call first):
  cmake_install.cmake:37 (include)
```

Same issues as https://github.com/bincrafters/community/issues/1085 problem.

### Fixed method
`.conan\\data\\libx265\\3.2.1\\_\\_\\source\\source_subfolder\\source\\CMakeLists.txt`
line 581 -593
```
if((WIN32 AND ENABLE_CLI) OR (WIN32 AND ENABLE_SHARED))
    if(MSVC_IDE)
        install(FILES "${PROJECT_BINARY_DIR}/Debug/x265.pdb" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug)
        install(FILES "${PROJECT_BINARY_DIR}/RelWithDebInfo/x265.pdb" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS RelWithDebInfo)
        install(FILES "${PROJECT_BINARY_DIR}/Debug/libx265.pdb" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug OPTIONAL NAMELINK_ONLY)
        install(FILES "${PROJECT_BINARY_DIR}/RelWithDebInfo/libx265.pdb" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS RelWithDebInfo OPTIONAL NAMELINK_ONLY)
    else()
        install(FILES "${PROJECT_BINARY_DIR}/x265.pdb" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug)
        install(FILES "${PROJECT_BINARY_DIR}/x265.pdb" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS RelWithDebInfo)
        install(FILES "${PROJECT_BINARY_DIR}/libx265.pdb" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug OPTIONAL NAMELINK_ONLY)
        install(FILES "${PROJECT_BINARY_DIR}/libx265.pdb" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS RelWithDebInfo OPTIONAL NAMELINK_ONLY)
    endif()
endif()
```
Because of no `x265.pdb` due to this error.
Fixed: https://github.com/microsoft/vcpkg/blob/master/ports/x265/disable-install-pdb.patch

We need to disable install pdb code in `CMakeLists.txt` when windows and mingw gcc.
My fixed:
`.conan\\data\\libx265\\3.2.1\\_\\_\\export\\conanfile.py`
line 40
```
    def _patch_sources(self):
        cmakelists = os.path.join(self._source_subfolder, "source", "CMakeLists.txt")
        if self.settings.os == "Windows":
            #   file INSTALL cannot find x265.pdb
            if self.settings.compiler == "Visual Studio":
                tools.replace_in_file(cmakelists,
                                      "${PROJECT_BINARY_DIR}/Debug/x265.pdb",
                                      "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/x265.pdb")
                tools.replace_in_file(cmakelists,
                                      "${PROJECT_BINARY_DIR}/x265.pdb",
                                      "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/x265.pdb")
            else:
                tools.replace_in_file(cmakelists,
                                      "install(FILES \\"${PROJECT_BINARY_DIR}/Debug/x265.pdb\\" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug)",
                                      "# install(FILES \\"${PROJECT_BINARY_DIR}/Debug/x265.pdb\\" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug)")
                tools.replace_in_file(cmakelists,
                                      "install(FILES \\"${PROJECT_BINARY_DIR}/RelWithDebInfo/x265.pdb\\" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS RelWithDebInfo)",
                                      "# install(FILES \\"${PROJECT_BINARY_DIR}/RelWithDebInfo/x265.pdb\\" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS RelWithDebInfo)")
                tools.replace_in_file(cmakelists,
                                      "install(FILES \\"${PROJECT_BINARY_DIR}/x265.pdb\\" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug)",
                                      "# install(FILES \\"${PROJECT_BINARY_DIR}/x265.pdb\\" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS Debug)")
                tools.replace_in_file(cmakelists,
                                      "install(FILES \\"${PROJECT_BINARY_DIR}/x265.pdb\\" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS RelWithDebInfo)",
                                      "# install(FILES \\"${PROJECT_BINARY_DIR}/x265.pdb\\" DESTINATION ${BIN_INSTALL_DIR} CONFIGURATIONS RelWithDebInfo)")
```

### Logs (Include/Attach if Applicable)
<details><summary>Click to expand log</summary>

```
[ 79%] Built target x265-static
[ 82%] Built target x265-shared
[100%] Built target cli
Install the project...
-- Install configuration: "Debug"
-- Installing: C:/Users/Home/.conan/data/libx265/3.2.1/_/_/package/e82f74c25b82d272dbcd1630371590cd62192d65/lib/libx265.a
-- Installing: C:/Users/Home/.conan/data/libx265/3.2.1/_/_/package/e82f74c25b82d272dbcd1630371590cd62192d65/include/x265.h
-- Installing: C:/Users/Home/.conan/data/libx265/3.2.1/_/_/package/e82f74c25b82d272dbcd1630371590cd62192d65/include/x265_config.h
CMake Error at source_subfolder/source/cmake_install.cmake:48 (file):
  file INSTALL cannot find
  "C:/Users/Home/.conan/data/libx265/3.2.1/_/_/build/e82f74c25b82d272dbcd1630371590cd62192d65/build_subfolder/bin/x265.pdb".
Call Stack (most recent call first):
  cmake_install.cmake:37 (include)


mingw32-make.exe: *** [Makefile:73: install] Error 1
ERROR: libx265/3.2.1: Error in package() method, line 95
	cmake.install()
	ConanException: Error 2 while executing cmake --build C:\\Users\\Home\\.conan\\data\\libx265\\3.2.1\\_\\_\\build\\e82f74c25b82d272dbcd1630371590cd62192d65\\build_subfolder --target install -- -j4

```
</details>


Changed files:
recipes/libx265/all/conanfile.py

diff --git a/recipes/libx265/all/conanfile.py b/recipes/libx265/all/conanfile.py
index 3e1f78eb7..9ad6c4cd8 100644
--- a/recipes/libx265/all/conanfile.py
+++ b/recipes/libx265/all/conanfile.py
@@ -71,14 +71,10 @@ class Libx265Conan(ConanFile):
 
     def _patch_sources(self):
         cmakelists = os.path.join(self._source_subfolder, "source", "CMakeLists.txt")
-        if self.settings.os == "Windows":
-            tools.replace_in_file(cmakelists,
-                                  "${PROJECT_BINARY_DIR}/Debug/x265.pdb",
-                                  "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/x265.pdb")
-            tools.replace_in_file(cmakelists,
-                                  "${PROJECT_BINARY_DIR}/x265.pdb",
-                                  "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/x265.pdb")
-        elif self.settings.os == "Android":
+        tools.replace_in_file(cmakelists,
+                                "if((WIN32 AND ENABLE_CLI) OR (WIN32 AND ENABLE_SHARED))",
+                                "if(FALSE)")
+        if self.settings.os == "Android":
             tools.replace_in_file(cmakelists,
                 "list(APPEND PLATFORM_LIBS pthread)", "")
             tools.replace_in_file(cmakelists,