Skip to content

Commit

Permalink
Fix Nix pkg-config support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ChrisThrasher committed Dec 15, 2023
1 parent 9cea872 commit 5e18e54
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 7 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion tools/pkg-config/sfml-all.pc.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/pkg-config/sfml-audio.pc.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/pkg-config/sfml-graphics.pc.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/pkg-config/sfml-network.pc.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/pkg-config/sfml-system.pc.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion tools/pkg-config/sfml-window.pc.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5e18e54

Please sign in to comment.