Fix Nix pkg-config support

CMAKE_INSTALL_LIBDIR is an absolute path on Nix (which is a valid
thing to do). In such a case two absolute paths would get appended
resulting in a nonsense path that broke pkg-config support.
This commit is contained in:
Chris Thrasher 2023-12-12 11:09:39 -07:00
parent 9cea872dbc
commit 5e18e5403b
8 changed files with 11 additions and 7 deletions

View File

@ -303,9 +303,12 @@ endif()
sfml_set_option(SFML_INSTALL_PKGCONFIG_FILES ${SFML_INSTALL_PKGCONFIG_DEFAULT} BOOL "TRUE to automatically install pkg-config files so other projects can find SFML") sfml_set_option(SFML_INSTALL_PKGCONFIG_FILES ${SFML_INSTALL_PKGCONFIG_DEFAULT} BOOL "TRUE to automatically install pkg-config files so other projects can find SFML")
if(SFML_INSTALL_PKGCONFIG_FILES) if(SFML_INSTALL_PKGCONFIG_FILES)
# account for CMAKE_INSTALL_LIBDIR potentially being an absolute path
file(RELATIVE_PATH SFML_RELATIVE_INSTALL_LIBDIR ${CMAKE_INSTALL_PREFIX} ${CMAKE_INSTALL_FULL_LIBDIR})
# set pkgconfig install directory # set pkgconfig install directory
# this could be e.g. macports on mac or msys2 on windows etc. # this could be e.g. macports on mac or msys2 on windows etc.
set(SFML_PKGCONFIG_DIR "/${CMAKE_INSTALL_LIBDIR}/pkgconfig") set(SFML_PKGCONFIG_DIR "/${SFML_RELATIVE_INSTALL_LIBDIR}/pkgconfig")
if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD) if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD OR SFML_OS_NETBSD)
set(SFML_PKGCONFIG_DIR "/libdata/pkgconfig") set(SFML_PKGCONFIG_DIR "/libdata/pkgconfig")

View File

@ -7,6 +7,7 @@
- Ensure GNUInstallDirs cache vars are included before first used (#2778, #2779) - Ensure GNUInstallDirs cache vars are included before first used (#2778, #2779)
- [macOS] Fix incorrect variable expansion (#2780) - [macOS] Fix incorrect variable expansion (#2780)
- Issue warning when trying to use UCRT MinGW with precompiled MSVCRT depenencies (#2821) - Issue warning when trying to use UCRT MinGW with precompiled MSVCRT depenencies (#2821)
- Fix Nix pkg-config support
### Audio ### Audio

View File

@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@
includedir=${prefix}/include includedir=${prefix}/include
Name: SFML-all Name: SFML-all

View File

@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@
includedir=${prefix}/include includedir=${prefix}/include
Name: SFML-audio Name: SFML-audio

View File

@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@
includedir=${prefix}/include includedir=${prefix}/include
Name: SFML-graphics Name: SFML-graphics

View File

@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@
includedir=${prefix}/include includedir=${prefix}/include
Name: SFML-network Name: SFML-network

View File

@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@
includedir=${prefix}/include includedir=${prefix}/include
Name: SFML-system Name: SFML-system

View File

@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@
includedir=${prefix}/include includedir=${prefix}/include
Name: SFML-window Name: SFML-window