Fix wrong version in gRPCConfigVersion.cmake and grpc++*.pc

They use PACKAGE_VERSION to generate version information but
PACKAGE_VERSION may be overridden by find_package(). For example,
-DgRPC_CARES_PROVIDER=package with c-ares 1.16.0 overrides
PACKAGE_VERSION to 1.16.0. Because c-ares-config-version.cmake has the
following line:

    set(PACKAGE_VERSION "1.16.0")

Setting PACKAGE_VERSION in version.cmake is a common CMake convention:

https://cmake.org/cmake/help/latest/command/find_package.html#version-selection

> PACKAGE_VERSION
>
>    full provided version string

So we should use gRPC_CPP_VERSION not PACKAGE_VERSION to generate
gRPCConfigVersion.cmake and grpc++*.pc.
pull/22529/head
Sutou Kouhei 5 years ago
parent 7126ffe0eb
commit bdb3f86064
  1. 6
      CMakeLists.txt
  2. 6
      templates/CMakeLists.txt.template

@ -15161,7 +15161,7 @@ include(CMakePackageConfigHelpers)
configure_file(cmake/gRPCConfig.cmake.in
gRPCConfig.cmake @ONLY)
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/gRPCConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
VERSION ${gRPC_CPP_VERSION}
COMPATIBILITY AnyNewerVersion)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/gRPCConfig.cmake
@ -15228,7 +15228,7 @@ generate_pkgconfig(
generate_pkgconfig(
"gRPC++"
"C++ wrapper for gRPC"
"${PACKAGE_VERSION}"
"${gRPC_CPP_VERSION}"
"grpc"
"-lgrpc++ -labsl_bad_optional_access -labsl_str_format_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
""
@ -15238,7 +15238,7 @@ generate_pkgconfig(
generate_pkgconfig(
"gRPC++ unsecure"
"C++ wrapper for gRPC without SSL"
"${PACKAGE_VERSION}"
"${gRPC_CPP_VERSION}"
"grpc_unsecure"
"-lgrpc++_unsecure -labsl_bad_optional_access -labsl_str_format_internal -labsl_time -labsl_time_zone -labsl_civil_time -labsl_strings -labsl_strings_internal -labsl_throw_delegate -labsl_int128 -labsl_base -labsl_spinlock_wait -labsl_raw_logging_internal -labsl_log_severity -labsl_dynamic_annotations"
""

@ -673,7 +673,7 @@
configure_file(cmake/gRPCConfig.cmake.in
gRPCConfig.cmake @ONLY)
write_basic_package_version_file(<%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>gRPCConfigVersion.cmake
VERSION <%text>${PACKAGE_VERSION}</%text>
VERSION <%text>${gRPC_CPP_VERSION}</%text>
COMPATIBILITY AnyNewerVersion)
install(FILES
<%text>${CMAKE_CURRENT_BINARY_DIR}/</%text>gRPCConfig.cmake
@ -740,7 +740,7 @@
generate_pkgconfig(
"gRPC++"
"C++ wrapper for gRPC"
"<%text>${PACKAGE_VERSION}</%text>"
"<%text>${gRPC_CPP_VERSION}</%text>"
"grpc"
"${" ".join(("-l" + l) for l in ["grpc++",] + list_absl_lib_files_for("grpc++"))}"
""
@ -750,7 +750,7 @@
generate_pkgconfig(
"gRPC++ unsecure"
"C++ wrapper for gRPC without SSL"
"<%text>${PACKAGE_VERSION}</%text>"
"<%text>${gRPC_CPP_VERSION}</%text>"
"grpc_unsecure"
"${" ".join(("-l" + l) for l in ["grpc++_unsecure",] + list_absl_lib_files_for("grpc++_unsecure"))}"
""

Loading…
Cancel
Save