From a69638409ca3816c9da8ae1166273eb7a8fe1b8d Mon Sep 17 00:00:00 2001 From: Tao He Date: Wed, 4 Aug 2021 11:27:56 +0800 Subject: [PATCH] The target protobuf::protoc exists since cmake 3.10. Fixes for cmake version later than v3.10, e.g., cmake 3.9. See also upstream patch: https://github.com/Kitware/CMake/commit/c281acf80768c56bbe12a9f017a856d8e966f084 Signed-off-by: Tao He --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c04d523..b47932b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,15 @@ endif() find_package(OpenSSL REQUIRED) find_package(Protobuf REQUIRED) +if(Protobuf_PROTOC_EXECUTABLE) + if(NOT TARGET protobuf::protoc) + add_executable(protobuf::protoc IMPORTED) + if(EXISTS "${Protobuf_PROTOC_EXECUTABLE}") + set_target_properties(protobuf::protoc PROPERTIES + IMPORTED_LOCATION "${Protobuf_PROTOC_EXECUTABLE}") + endif() + endif() +endif() find_package(cpprestsdk QUIET) if(cpprestsdk_FOUND) set(CPPREST_INCLUDE_DIR)