From d333f089588961a419dfcc97b10dcd89bba19cbc Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 25 Nov 2024 23:39:11 -0800 Subject: [PATCH] CMake: generate a pkg-config file that follow pkg-config conventions (#4456) * CMake: configure pkg-config with @only And use @ replacement instead of {}, since ${} is significant in pkg-config's format * CMake: use conventional prefix and incluedir variables in pkg-config This is more standard, and has some advantages when cross compiling. This also means that the pkg-config files generated by Meson and CMake now match. --- CMakeLists.txt | 1 + cmake/pkg-config.pc.in | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index df61fc332..27440a5d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,6 +149,7 @@ endif() CONFIGURE_FILE( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" + @ONLY ) ## diff --git a/cmake/pkg-config.pc.in b/cmake/pkg-config.pc.in index d36317f09..21a91a3cf 100644 --- a/cmake/pkg-config.pc.in +++ b/cmake/pkg-config.pc.in @@ -1,4 +1,7 @@ -Name: ${PROJECT_NAME} +prefix=@CMAKE_INSTALL_PREFIX@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ Description: JSON for Modern C++ -Version: ${PROJECT_VERSION} -Cflags: -I${CMAKE_INSTALL_FULL_INCLUDEDIR} +Version: @PROJECT_VERSION@ +Cflags: -I${includedir}