Repository: conan-io/conan-center-index

Issue:
[package] boost/[>=1.69]: shared build fails with MinGW (Windows)
### Package and Environment Details
  * Package Name/Version: boost (tested with 1.69 and higher)
  * Operating System+version: **Windows 10 (21H1)**
  * Compiler+version: **MinGW 8.1.0 (provided by Qt) - GCC 8**
  * Conan version: **conan 1.36.0**
  * Python version: **Python 3.8**

### Conan profile
```ini
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=8
compiler.libcxx=libstdc++11
compiler.threads=posix
compiler.exception=seh
build_type=Release
[options]
[build_requires]
[env]
```

### Steps to reproduce

conanfile.txt
```ini
[requires]
boost/1.69.0

[options]
boost:shared=True
boost:without_atomic=True
boost:without_chrono=True
boost:without_container=True
boost:without_context=True
boost:without_contract=True
boost:without_coroutine=True
boost:without_date_time=True
boost:without_exception=True
boost:without_fiber=True
boost:without_filesystem=False
boost:without_graph=True
boost:without_graph_parallel=True
boost:without_iostreams=True
boost:without_locale=True
boost:without_log=True
boost:without_math=True
boost:without_mpi=True
boost:without_program_options=True
boost:without_python=True
boost:without_random=True
boost:without_regex=True
boost:without_serialization=True
boost:without_stacktrace=True
boost:without_system=False
boost:without_test=True
boost:without_thread=True
boost:without_timer=True
boost:without_type_erasure=True
boost:without_wave=True
```

### Logs
```
boost/1.69.0: WARN: Boost component 'filesystem' is missing libraries. Try building boost with '-o boost:without_filesystem'. (Option is not guaranteed to exist)
boost/1.69.0: WARN: Boost component 'system' is missing libraries. Try building boost with '-o boost:without_system'. (Option is not guaranteed to exist)
ERROR: boost/1.69.0: Error in package_info() method, line 1492
        raise Conan Exception("These libraries were build, but were not used in any boost module: {}".format(non_used))
        ConanException: These libraries were built, but were not used in any boost module: {'boost_system.dll', 'boost_filesystem.dll'}
```

The thing is MinGW when building shared libs outputs two files: `xxx.dll` (placed in `package/{id}/bin`) and `xxx.dll.a` (placed in `package/{id}/lib`), then `tools.collect_libs(self)` reports what it finds in the `lib` folder (without lib prefix and .a suffix): `{'boost_system.dll', 'boost_filesystem.dll'}` instead of reporting `{'boost_system', 'boost_filesystem'}` and the packaging fails while everything was alright.

boost conanfile.py: 
```python
all_detected_libraries = set(tools.collect_libs(self))
# prints {'boost_system.dll', 'boost_filesystem.dll'} if shared=True
    ...
module_libraries = filter_transform_module_libraries(self._dependencies["libs"][module])
# prints {'boost_system', 'boost_filesystem'}
all_expected_libraries = all_expected_libraries.union(module_libraries)
if set(module_libraries).difference(all_detected_libraries): # here is the problem
    incomplete_components.append(module)
```


Discussion:
We can't use `str.removesuffix` as that required CPython 3.9.
Does replacing
```python
all_detected_libraries = set(tools.collect_libs(self))
```
with
```python
def clean_libname(lib):
    if lib.endswith(".dll"):
        return lib[:-4]
    return lib
all_detected_libraries = set(clean_libname(l) for l in tools.collect_libs(self))
```
fix your problem?
Yes it does. Used:
```python
set(l[:-4] if l.endswith(".dll") else l for l in tools.collect_libs(self))
```
Great to hear this!
If you feel up to the task, please open a pr with the fix.

Resolving patch:
diff --git a/recipes/boost/all/conanfile.py b/recipes/boost/all/conanfile.py
--- a/recipes/boost/all/conanfile.py
+++ b/recipes/boost/all/conanfile.py
@@ -1429,7 +1429,7 @@ def add_libprefix(n):
                     libprefix = "lib"
                 return libprefix + n
 
-            all_detected_libraries = set(tools.collect_libs(self))
+            all_detected_libraries = set(l[:-4] if l.endswith(".dll") else l for l in tools.collect_libs(self))
             all_expected_libraries = set()
             incomplete_components = list()
 


Test patch: