conan-io / conan-io/docs

[bug] CMakeDeps throws error for package(s) defined as platform_requires

Open
#3,908 5 comments 0 reactions 1 assignee Claimed by @memsharded View on GitHub
type: question
Dominant language
C++
Stars
125
Forks
382
Avg merge
22h 39m
Merged PRs (30d)
21

Description

### Describe the bug

macOS 14.7, Conan 2.9.2, apple-clang 15

I declared some libs as `platform_requires` (Apple OSs have them preinstalled in the system), everything built fine. But at the final moment when CMakeDeps starts its work it throws an error:

> ERROR: Error in generator 'CMakeDeps': error generating context for 'ffmpeg/7.0.1': ffmpeg/7.0.1: component 'avcodec' required 'zlib::zlib', but 'zlib' is not a direct dependency

Also, had to tune a few other recipes a bit that they don't throw an error when trying to access the platform_requires libs from `self.dependencies`, [see here](https://github.com/conan-io/conan-center-index/commit/d5184b9179bf912241c689819724637238272e73). Is it to be considered a bug or should be adjusted on a recipe basis?

Previously in Conan v1 I wrote [wrapper recipes](https://github.com/kambala-decapitator/conan-system-libs) for these libs and there was no such issue. Oh, actually I faced one issue that resembles the `self.dependencies` one described above for which I provided a PR https://github.com/conan-io/conan-center-index/pull/23478, but no issues with CMakeDeps.

P.S. Also asked this on [Slack](https://cpplang.slack.com/archives/C41CWV9HA/p1731769058754799)

P.P.S. One more example of such error, but no full log at hand at the moment:

```
ERROR: sdl_mixer/2.8.0: Error in generate() method, line 227
deps.generate()
ConanException: error generating context for 'openssl/3.3.2': openssl/3.3.2: component 'crypto' required 'zlib::zlib', but 'zlib' is not a direct dependency
```

### How to reproduce it

conanfile.txt
```
[requires]
ffmpeg/7.0.1

[generators]
CMakeToolchain
CMakeDeps
```

Build profile (basically the detected one):
```
[settings]
arch=x86_64
build_type=Release
compiler=apple-clang
compiler.cppstd=gnu17
compiler.libcxx=libc++
compiler.version=15
os=Macos

[platform_tool_requires]
cmake/3.31.0
ninja/1.12.1
```

Host profile: same as build (used `include`) with the addition of
```
[platform_requires]
bzip2/1.0.8
libiconv/1.17
sqlite3/3.47.0
zlib/1.2.11
```

Command used:

conan install . -pr:b default -pr:h 'default copy' -of 1 -b missing

Full log: [log.txt.zip](https://github.com/user-attachments/files/17822234/log.txt.zip)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.