From 7f63ce19f72cab66849e56011efb94ddb263fea8 Mon Sep 17 00:00:00 2001 From: Carlos O'Ryan Date: Thu, 23 Apr 2020 15:59:12 -0400 Subject: [PATCH] fix: avoid warnings with newer CMake versions (#48) I noticed this with CMake 3.17.1, but may have started earlier. Using `include()` to load a module does not work because the calls to `find_package_handle_standard_args()` generate a ton of warnings. Loading the module using `find_package()` works as expected. --- cmake/FindgRPC.cmake | 3 ++- cmake/config.cmake.in | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/FindgRPC.cmake b/cmake/FindgRPC.cmake index 358285b..e153cd8 100644 --- a/cmake/FindgRPC.cmake +++ b/cmake/FindgRPC.cmake @@ -68,7 +68,8 @@ find_package(Threads REQUIRED) # Load the module to find protobuf with proper targets. Do not use # `find_package()` because we (have to) install this module in non-standard # locations. -include(${CMAKE_CURRENT_LIST_DIR}/FindProtobufTargets.cmake) +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") +find_package(ProtobufTargets) # The gRPC::grpc_cpp_plugin target is sometimes defined, but without a # IMPORTED_LOCATION diff --git a/cmake/config.cmake.in b/cmake/config.cmake.in index 02169ef..812df9c 100644 --- a/cmake/config.cmake.in +++ b/cmake/config.cmake.in @@ -14,8 +14,9 @@ # limitations under the License. # ~~~ -include("${CMAKE_CURRENT_LIST_DIR}/FindProtobufTargets.cmake") -include("${CMAKE_CURRENT_LIST_DIR}/FindgRPC.cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") +find_package(ProtobufTargets) +find_package(gRPC) include("${CMAKE_CURRENT_LIST_DIR}/googleapis-targets.cmake")