Sfml: Multiple problems with pkg-config file installation

Created on 8 May 2018  路  5Comments  路  Source: SFML/SFML

Subject of the issue

pkg-config files are installed both to correct directory (libdata/pkgconfig on my system) and to installation prefix directly which is broken. This happens because installation is duplicated:

https://github.com/SFML/SFML/blob/192eb968a4e938f36948e97f97ddc354a8a470fe/CMakeLists.txt#L285-L286

and

https://github.com/SFML/SFML/blob/192eb968a4e938f36948e97f97ddc354a8a470fe/CMakeLists.txt#L317-L318

Another inconsistency is that even if some SFML modules are disabled, .pc files for them are still installed.

Your environment

  • FreeBSD 12
  • SFML 2.5.0
  • Clang 4.0.0

Steps to reproduce

Just install SFML with -DSFML_INSTALL_PKGCONFIG_FILES=ON. Judging from the code, this should be reproducible on Linux as well.

bug config linux accepted

Most helpful comment

I think the duplication was caused by an incorrect rebase in #800. This PR was opened before #1173 which changed all the pkg-config code, but merged afterwards and reintroduced some code which should not be there. I suggest removing the first instance of pkg-config handling because it looks like it was added by mistake.

I agree that the pkg-config detection code is incorrect. I think setting some per-os defaults like @AMDmi3 suggested is the best option. It would also be useful if the PKGCONFIG_DIR could be configured by some CMake option so I don't have to patch SFML to handle Debian's funky kFreeBSD architecture (which identifies as FreeBSD, but uses the Linux/Debian pkg-config paths).

This is what I've done for Debian, although some of it is very Debian specific:
https://salsa.debian.org/games-team/libsfml/tree/master/debian/patches

All 5 comments

What is your suggested solution? Or what exactly needs to be fixed?

  • .pc file installation code should be reviewed and deduplicated (CMakeLists.txt lines 272-294 vs 309-320). I can't come up with more detailed suggestion as the former chunk looks overcomplicated, and the latter is broken, maybe we should start with the following problem:

  • pkgconfig support detection should be fixed:

https://github.com/SFML/SFML/blob/192eb968a4e938f36948e97f97ddc354a8a470fe/cmake/Config.cmake#L72-L83

  • you cannot rely on pkg-config executable presence. It's not required to install .pc files, it's only required for consumer projects to use them, so it may not be installed at the time of SFML installation
  • you cannot rely on presence of pkgconfig directories, as they may not be present yet

The only solutions I see is to unconditionally enable .pc file installation (as most projects generally do), or to enable it based on SFML_OS_* (it will be required to set correct SFML_OS_PKGCONFIG_DIR anyway, so it's a possible solution too).

I think the duplication was caused by an incorrect rebase in #800. This PR was opened before #1173 which changed all the pkg-config code, but merged afterwards and reintroduced some code which should not be there. I suggest removing the first instance of pkg-config handling because it looks like it was added by mistake.

I agree that the pkg-config detection code is incorrect. I think setting some per-os defaults like @AMDmi3 suggested is the best option. It would also be useful if the PKGCONFIG_DIR could be configured by some CMake option so I don't have to patch SFML to handle Debian's funky kFreeBSD architecture (which identifies as FreeBSD, but uses the Linux/Debian pkg-config paths).

This is what I've done for Debian, although some of it is very Debian specific:
https://salsa.debian.org/games-team/libsfml/tree/master/debian/patches

I'll try to tackle this this or maybe next week, but I have zero experience with pkg-config files, so if someone else is willing to contribute a PR, I'd highly appreciate that.

Fixed in 9712bb1ec8379cc29fd7417f64bc5e6b11cc4728

Was this page helpful?
0 / 5 - 0 ratings