Create pkg-config files from CMake

pull/20211/head
Zack Galbreath 5 years ago
parent 985d0f9ec8
commit 7bb75068b5
  1. 71
      CMakeLists.txt
  2. 12
      cmake/pkg-config-template.pc.in
  3. 71
      templates/CMakeLists.txt.template

@ -25,10 +25,11 @@ cmake_minimum_required(VERSION 3.5.1)
set(PACKAGE_NAME "grpc")
set(PACKAGE_VERSION "1.25.0-dev")
set(gRPC_CORE_VERSION "8.0.0")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/")
project(${PACKAGE_NAME} C CXX)
project(${PACKAGE_NAME} LANGUAGES C CXX)
set(gRPC_INSTALL_BINDIR "bin" CACHE STRING "Installation directory for executables")
set(gRPC_INSTALL_LIBDIR "lib" CACHE STRING "Installation directory for libraries")
@ -19431,3 +19432,71 @@ endforeach()
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/etc/roots.pem
DESTINATION ${gRPC_INSTALL_SHAREDIR})
# Function to generate pkg-config files.
function(generate_pkgconfig name description version requires
libs libs_private output_filename)
set(PC_NAME "${name}")
set(PC_DESCRIPTION "${description}")
set(PC_VERSION "${version}")
set(PC_REQUIRES "${requires}")
set(PC_LIB "${libs}")
set(PC_LIBS_PRIVATE "${libs_private}")
set(output_filepath "${grpc_BINARY_DIR}/libs/opt/pkgconfig/${output_filename}")
configure_file(
"${grpc_SOURCE_DIR}/cmake/pkg-config-template.pc.in"
"${output_filepath}"
@ONLY)
install(FILES "${output_filepath}"
DESTINATION "lib/pkgconfig/")
endfunction()
# gpr .pc file
generate_pkgconfig(
"gpr"
"gRPC platform support library"
"${gRPC_CORE_VERSION}"
""
"-lgpr"
""
"gpr.pc")
# grpc .pc file
generate_pkgconfig(
"gRPC"
"high performance general RPC framework"
"${gRPC_CORE_VERSION}"
"gpr"
"-lgrpc -laddress_sorting -lcares -lz"
""
"grpc.pc")
# grpc_unsecure .pc file
generate_pkgconfig(
"gRPC unsecure"
"high performance general RPC framework without SSL"
"${gRPC_CORE_VERSION}"
"gpr"
"-lgrpc_unsecure"
""
"grpc_unsecure.pc")
# grpc++ .pc file
generate_pkgconfig(
"gRPC++"
"C++ wrapper for gRPC"
"${PACKAGE_VERSION}"
"grpc"
"-lgrpc++"
""
"grpc++.pc")
# grpc++_unsecure .pc file
generate_pkgconfig(
"gRPC++ unsecure"
"C++ wrapper for gRPC without SSL"
"${PACKAGE_VERSION}"
"grpc_unsecure"
"-lgrpc++_unsecure"
""
"grpc++_unsecure.pc")

@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib
Name: @PC_NAME@
Description: @PC_DESCRIPTION@
Version: @PC_VERSION@
Cflags: -I${includedir}
Requires: @PC_REQUIRES@
Libs: -L${libdir} @PC_LIB@
Libs.private: @PC_LIBS_PRIVATE@

@ -73,10 +73,11 @@
set(PACKAGE_NAME "grpc")
set(PACKAGE_VERSION "${settings.cpp_version}")
set(gRPC_CORE_VERSION "${settings.core_version}")
set(PACKAGE_STRING "<%text>${PACKAGE_NAME} ${PACKAGE_VERSION}</%text>")
set(PACKAGE_TARNAME "<%text>${PACKAGE_NAME}-${PACKAGE_VERSION}</%text>")
set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/")
project(<%text>${PACKAGE_NAME}</%text> C CXX)
project(<%text>${PACKAGE_NAME}</%text> LANGUAGES C CXX)
set(gRPC_INSTALL_BINDIR "bin" CACHE STRING "Installation directory for executables")
set(gRPC_INSTALL_LIBDIR "lib" CACHE STRING "Installation directory for libraries")
@ -569,3 +570,71 @@
install(FILES <%text>${CMAKE_CURRENT_SOURCE_DIR}/etc/roots.pem</%text>
DESTINATION <%text>${gRPC_INSTALL_SHAREDIR}</%text>)
# Function to generate pkg-config files.
function(generate_pkgconfig name description version requires
libs libs_private output_filename)
set(PC_NAME "<%text>${name}</%text>")
set(PC_DESCRIPTION "<%text>${description}</%text>")
set(PC_VERSION "<%text>${version}</%text>")
set(PC_REQUIRES "<%text>${requires}</%text>")
set(PC_LIB "<%text>${libs}</%text>")
set(PC_LIBS_PRIVATE "<%text>${libs_private}</%text>")
set(output_filepath "<%text>${grpc_BINARY_DIR}/libs/opt/pkgconfig/${output_filename}</%text>")
configure_file(
"<%text>${grpc_SOURCE_DIR}/cmake/pkg-config-template.pc.in</%text>"
"<%text>${output_filepath}</%text>"
@ONLY)
install(FILES "<%text>${output_filepath}</%text>"
DESTINATION "lib/pkgconfig/")
endfunction()
# gpr .pc file
generate_pkgconfig(
"gpr"
"gRPC platform support library"
"<%text>${gRPC_CORE_VERSION}</%text>"
""
"-lgpr"
""
"gpr.pc")
# grpc .pc file
generate_pkgconfig(
"gRPC"
"high performance general RPC framework"
"<%text>${gRPC_CORE_VERSION}</%text>"
"gpr"
"-lgrpc -laddress_sorting -lcares -lz"
""
"grpc.pc")
# grpc_unsecure .pc file
generate_pkgconfig(
"gRPC unsecure"
"high performance general RPC framework without SSL"
"<%text>${gRPC_CORE_VERSION}</%text>"
"gpr"
"-lgrpc_unsecure"
""
"grpc_unsecure.pc")
# grpc++ .pc file
generate_pkgconfig(
"gRPC++"
"C++ wrapper for gRPC"
"<%text>${PACKAGE_VERSION}</%text>"
"grpc"
"-lgrpc++"
""
"grpc++.pc")
# grpc++_unsecure .pc file
generate_pkgconfig(
"gRPC++ unsecure"
"C++ wrapper for gRPC without SSL"
"<%text>${PACKAGE_VERSION}</%text>"
"grpc_unsecure"
"-lgrpc++_unsecure"
""
"grpc++_unsecure.pc")

Loading…
Cancel
Save