More-correct .pc file path fix

- When passing paths to the build system, they are now correctly
  relative to the prefix rather than absolute.
This commit is contained in:
Benjamin A. Beasley 2022-11-21 07:48:33 -05:00
parent dce1612c8a
commit 15ce3e7fd3
2 changed files with 15 additions and 9 deletions

View File

@ -1,4 +1,4 @@
From 2bc8a76b14b5db09ceb3d00a081d8411c34451cf Mon Sep 17 00:00:00 2001
From beb3d7c392c22517c5a91e2f13558bee379abb2a Mon Sep 17 00:00:00 2001
From: "Benjamin A. Beasley" <code@musicinmybrain.net>
Date: Wed, 16 Nov 2022 09:00:21 -0500
Subject: [PATCH] Use CMake variables for paths in pkg-config files
@ -13,7 +13,7 @@ Use @gRPC_INSTALL_INCLUDEDIR@ for consistency.
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cmake/pkg-config-template.pc.in b/cmake/pkg-config-template.pc.in
index d56154bb3a53..3a260418a815 100644
index d56154bb3a53..5a56b4f88530 100644
--- a/cmake/pkg-config-template.pc.in
+++ b/cmake/pkg-config-template.pc.in
@@ -1,7 +1,7 @@
@ -21,8 +21,8 @@ index d56154bb3a53..3a260418a815 100644
exec_prefix=${prefix}
-includedir=${prefix}/include
-libdir=${exec_prefix}/lib
+includedir=@gRPC_INSTALL_INCLUDEDIR@
+libdir=@gRPC_INSTALL_LIBDIR@
+includedir=${prefix}/@gRPC_INSTALL_INCLUDEDIR@
+libdir=${exec_prefix}/@gRPC_INSTALL_LIBDIR@
Name: @PC_NAME@
Description: @PC_DESCRIPTION@

View File

@ -858,6 +858,12 @@ sed -r -i 's/(std=c\+\+)14/\1%{cpp_std}/g' \
%build
# ~~~~ C (core) and C++ (cpp) ~~~~
# Length of the prefix (e.g. /usr), plus a trailing slash (or newline), plus
# one, to get the index of the first relative path character after the prefix.
# This is needed because gRPC_INSTALL_*DIR options expect paths relative to the
# prefix, and supplying absolute paths causes certain subtle problems.
%global rmprefix %(echo $(($(wc -c <<<'%{_prefix}')+1)))
echo '===== Building C (core) and C++ components =====' 2>&1
# We could use either make or ninja as the backend; ninja is faster and has no
# disadvantages (except a small additional BR, given we already need Python)
@ -867,11 +873,11 @@ echo '===== Building C (core) and C++ components =====' 2>&1
-DgRPC_INSTALL:BOOL=ON \
-DCMAKE_CXX_STANDARD:STRING=%{cpp_std} \
-DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON \
-DgRPC_INSTALL_BINDIR:PATH=%{_bindir} \
-DgRPC_INSTALL_LIBDIR:PATH=%{_libdir} \
-DgRPC_INSTALL_INCLUDEDIR:PATH=%{_includedir} \
-DgRPC_INSTALL_CMAKEDIR:PATH=%{_libdir}/cmake/grpc \
-DgRPC_INSTALL_SHAREDIR:PATH=%{_datadir}/grpc \
-DgRPC_INSTALL_BINDIR:PATH=%(cut -b %{rmprefix}- <<<'%{_bindir}') \
-DgRPC_INSTALL_LIBDIR:PATH=%(cut -b %{rmprefix}- <<<'%{_libdir}') \
-DgRPC_INSTALL_INCLUDEDIR:PATH=%(cut -b %{rmprefix}- <<<'%{_includedir}') \
-DgRPC_INSTALL_CMAKEDIR:PATH=%(cut -b %{rmprefix}- <<<'%{_libdir}/cmake/grpc') \
-DgRPC_INSTALL_SHAREDIR:PATH=%(cut -b %{rmprefix}- <<<'%{_datadir}/grpc') \
-DgRPC_BUILD_TESTS:BOOL=%{?with_core_tests:ON}%{?!with_core_tests:OFF} \
-DgRPC_BUILD_CODEGEN:BOOL=ON \
-DgRPC_BUILD_CSHARP_EXT:BOOL=ON \