diff --git a/CMakeLists.txt b/CMakeLists.txt index 52041b069..40cfa1b2a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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") 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 # 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) set(SFML_PKGCONFIG_DIR "/libdata/pkgconfig") diff --git a/changelog.md b/changelog.md index ea9410cea..365e5aecd 100644 --- a/changelog.md +++ b/changelog.md @@ -7,6 +7,7 @@ - Ensure GNUInstallDirs cache vars are included before first used (#2778, #2779) - [macOS] Fix incorrect variable expansion (#2780) - Issue warning when trying to use UCRT MinGW with precompiled MSVCRT depenencies (#2821) +- Fix Nix pkg-config support ### Audio diff --git a/tools/pkg-config/sfml-all.pc.in b/tools/pkg-config/sfml-all.pc.in index 3dba4f7c8..7f5f1b9f1 100644 --- a/tools/pkg-config/sfml-all.pc.in +++ b/tools/pkg-config/sfml-all.pc.in @@ -1,6 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@ includedir=${prefix}/include Name: SFML-all diff --git a/tools/pkg-config/sfml-audio.pc.in b/tools/pkg-config/sfml-audio.pc.in index ad7fad727..1d26fa8fc 100644 --- a/tools/pkg-config/sfml-audio.pc.in +++ b/tools/pkg-config/sfml-audio.pc.in @@ -1,6 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@ includedir=${prefix}/include Name: SFML-audio diff --git a/tools/pkg-config/sfml-graphics.pc.in b/tools/pkg-config/sfml-graphics.pc.in index 46f53874c..868be2211 100644 --- a/tools/pkg-config/sfml-graphics.pc.in +++ b/tools/pkg-config/sfml-graphics.pc.in @@ -1,6 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@ includedir=${prefix}/include Name: SFML-graphics diff --git a/tools/pkg-config/sfml-network.pc.in b/tools/pkg-config/sfml-network.pc.in index c0199350c..f57c7f1a4 100644 --- a/tools/pkg-config/sfml-network.pc.in +++ b/tools/pkg-config/sfml-network.pc.in @@ -1,6 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@ includedir=${prefix}/include Name: SFML-network diff --git a/tools/pkg-config/sfml-system.pc.in b/tools/pkg-config/sfml-system.pc.in index 285852d7b..feb3f6b97 100644 --- a/tools/pkg-config/sfml-system.pc.in +++ b/tools/pkg-config/sfml-system.pc.in @@ -1,6 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@ includedir=${prefix}/include Name: SFML-system diff --git a/tools/pkg-config/sfml-window.pc.in b/tools/pkg-config/sfml-window.pc.in index e216473ca..e287d9201 100644 --- a/tools/pkg-config/sfml-window.pc.in +++ b/tools/pkg-config/sfml-window.pc.in @@ -1,6 +1,6 @@ prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} -libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +libdir=${exec_prefix}/@SFML_RELATIVE_INSTALL_LIBDIR@ includedir=${prefix}/include Name: SFML-window