From 244948e174c0b698ac492d5aa8e379d5ccbc1323 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Fri, 30 Jul 2021 13:19:46 +0200 Subject: [PATCH] Export pkg-config dependencies via the CMake cache This will be useful when building GLFW as a CMake object library and linking it into a larger library that exports pkg-config information. Partly based on #1307 by @a3f. Closes #1307. --- CMake/glfw3.pc.in | 4 ++-- CMakeLists.txt | 9 +++++++-- README.md | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CMake/glfw3.pc.in b/CMake/glfw3.pc.in index f74298d4..37f4efd9 100644 --- a/CMake/glfw3.pc.in +++ b/CMake/glfw3.pc.in @@ -7,7 +7,7 @@ Name: GLFW Description: A multi-platform library for OpenGL, window and input Version: @GLFW_VERSION@ URL: https://www.glfw.org/ -Requires.private: @GLFW_PKG_DEPS@ +Requires.private: @GLFW_PKG_CONFIG_REQUIRES_PRIVATE@ Libs: -L${libdir} -l@GLFW_LIB_NAME@ -Libs.private: @GLFW_PKG_LIBS@ +Libs.private: @GLFW_PKG_CONFIG_LIBS_PRIVATE@ Cflags: -I${includedir} diff --git a/CMakeLists.txt b/CMakeLists.txt index ab3248ee..2519b071 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -258,12 +258,17 @@ endif() # Export GLFW library dependencies #-------------------------------------------------------------------- foreach(arg ${glfw_PKG_DEPS}) - set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} ${arg}") + set(deps "${deps} ${arg}") endforeach() foreach(arg ${glfw_PKG_LIBS}) - set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} ${arg}") + set(libs "${libs} ${arg}") endforeach() +set(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL + "GLFW pkg-config Requires.private") +set(GLFW_PKG_CONFIG_LIBS_PRIVATE "${libs}" CACHE INTERNAL + "GLFW pkg-config Libs.private") + #-------------------------------------------------------------------- # Create generated files #-------------------------------------------------------------------- diff --git a/README.md b/README.md index 98b49733..4667347c 100644 --- a/README.md +++ b/README.md @@ -131,6 +131,8 @@ information on what to include when reporting a bug. surface extension (#1793) - Added `GLFW_LIBRARY_TYPE` CMake variable for overriding the library type (#279,#1307,#1497,#1574,#1928) + - Added `GLFW_PKG_CONFIG_REQUIRES_PRIVATE` and `GLFW_PKG_CONFIG_LIBS_PRIVATE` CMake + variables exposing pkg-config dependencies (#1307) - Made joystick subsystem initialize at first use (#1284,#1646) - Made `GLFW_DOUBLEBUFFER` a read-only window attribute - Updated the minimum required CMake version to 3.1 @@ -322,6 +324,7 @@ skills. - Fredrik Ehnbom - Robin Eklind - Siavash Eliasi + - Ahmad Fatoum - Felipe Ferreira - Michael Fogleman - Gerald Franz