Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg-config file is broken when CMAKE_INSTALL_{INCLUDE,LIB}DIR is absolute #612

Open
alexshpilkin opened this issue May 18, 2022 · 3 comments
Assignees

Comments

@alexshpilkin
Copy link

As per title: CMakeLists.txt has

set (prefix ${CMAKE_INSTALL_PREFIX})
set (exec_prefix "\${prefix}")
set (libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
set (includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
set (bindir "${CMAKE_INSTALL_FULL_BINDIR}")
set (sysconfdir "${CMAKE_INSTALL_FULL_SYSCONFDIR}")
set (top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")

and so can’t handle absolute paths in CMAKE_INSTALL_{INCLUDE,LIB}DIR. This leads to broken .pc files on NixOS in particular.

See “Concatenating paths when building pkg-config files” for a thorough discussion of the problem and a suggested fix, or KDE’s extra-cmake-modules for a simpler approach. (Using FULL variables as already done for other directories is a possibility, but seems to be frowned upon by some other distributions. That applies just as much to BINDIR and SYSCONFDIR, though.)

@aberaud aberaud self-assigned this May 18, 2022
@aberaud
Copy link
Member

aberaud commented May 18, 2022

@alexshpilkin Thanks. What solution do you suggest ?
Ideally we would like to remain compatible with Ubuntu 18.04 (CMake 3.10)

@alexshpilkin
Copy link
Author

@aberaud I’m not a CMake expert by any stretch of the imagination, but the KDE one, with if (IS_ABSOLUTE ...), seems to be compatible even with very old CMake versions, down to 3.0 even. It’s a bit less perfectionist than full path-joining in that it will leave a dot-dot component as is if someone passes one (why?..), but should still work correctly in all cases. (Even simpler would be to use the CMAKE_INSTALL_FULL_*DIR variables, which have also existed since basically forever, but this sacrifices relocatability, which some people apparently want.)

@n7tae
Copy link

n7tae commented Nov 21, 2022

Also, please add pkg-config to the build wiki in the Debian-Ubuntu section as not all popular versions have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants