From 3166a05c18b9efc3509668596b056ae879ce5939 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 13 Sep 2024 21:07:47 +0200
Subject: [PATCH] cmake: don't prepend absolute CMAKE_INSTALL_{INCLUDE,LIB}DIR
with ${prefix}
---
cmake/sdl3.pc.in | 4 ++--
cmake/sdltargets.cmake | 11 +++++++++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/cmake/sdl3.pc.in b/cmake/sdl3.pc.in
index bfc2afffeb314..38566f57f746d 100644
--- a/cmake/sdl3.pc.in
+++ b/cmake/sdl3.pc.in
@@ -1,7 +1,7 @@
prefix=@SDL_PKGCONFIG_PREFIX@
exec_prefix=${prefix}
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@LIBDIR_FOR_PKG_CONFIG@
+includedir=@INCLUDEDIR_FOR_PKG_CONFIG@
Name: sdl3
Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
diff --git a/cmake/sdltargets.cmake b/cmake/sdltargets.cmake
index d11061c9cb69b..781ca01c8bebd 100644
--- a/cmake/sdltargets.cmake
+++ b/cmake/sdltargets.cmake
@@ -346,6 +346,17 @@ function(configure_sdl3_pc)
string(REGEX REPLACE "[/]+$" "" SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG "${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}")
set(SDL_PKGCONFIG_PREFIX "\${pcfiledir}/${SDL_PATH_PREFIX_RELATIVE_TO_PKGCONFIG}")
+ if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
+ set(INCLUDEDIR_FOR_PKG_CONFIG "${CMAKE_INSTALL_INCLUDEDIR}")
+ else()
+ set(INCLUDEDIR_FOR_PKG_CONFIG "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
+ endif()
+ if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
+ set(LIBDIR_FOR_PKG_CONFIG "${CMAKE_INSTALL_LIBDIR}")
+ else()
+ set(LIBDIR_FOR_PKG_CONFIG "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
+ endif()
+
configure_file("${SDL3_SOURCE_DIR}/cmake/sdl3.pc.in" "${SDL3_BINARY_DIR}/sdl3.pc" @ONLY)
endfunction()