Use a relative install path for pkgconfig files

This allows the pkgconfig install path to still be correct when changing the CMAKE_INSTALL_PREFIX after the first cmake run.
This commit is contained in:
Bruno Van de Velde 2024-03-10 11:21:38 +01:00
parent 8096ba24fc
commit 47019cd32b

View File

@ -234,13 +234,13 @@ if(SFML_INSTALL_PKGCONFIG_FILES)
# set pkgconfig install directory
# this could be e.g. macports on mac or msys2 on windows etc.
set(SFML_PKGCONFIG_DIR "/${SFML_RELATIVE_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")
set(SFML_PKGCONFIG_DIR "libdata/pkgconfig")
endif()
sfml_set_option(SFML_PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${SFML_PKGCONFIG_DIR}" PATH "Install directory for SFML's pkg-config .pc files")
sfml_set_option(SFML_PKGCONFIG_INSTALL_DIR "${SFML_PKGCONFIG_DIR}" PATH "Install directory for SFML's pkg-config .pc files")
foreach(sfml_module IN ITEMS all system window graphics audio network)
configure_file(
@ -248,7 +248,7 @@ if(SFML_INSTALL_PKGCONFIG_FILES)
"tools/pkg-config/sfml-${sfml_module}.pc"
@ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/tools/pkg-config/sfml-${sfml_module}.pc"
DESTINATION "${SFML_PKGCONFIG_INSTALL_PREFIX}")
DESTINATION "${SFML_PKGCONFIG_INSTALL_DIR}")
endforeach()
endif()