From 1b96e0a81db061c4b302d352a9b7f54d1cd89a6e Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 21 Apr 2019 10:08:39 +0200 Subject: [PATCH] Fix for CMake > 3.9 --- CMakeLists.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 695d6db32..b071f94b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1799,6 +1799,21 @@ if(ENABLE_PROTOBUF) PURPOSE "Used to serialize output data in a way that can be read by other applications." TYPE REQUIRED ) + if(Protobuf_FOUND AND CMAKE_VERSION VERSION_LESS 3.9) + add_library(protobuf::libprotobuf SHARED IMPORTED) + set_target_properties(protobuf::libprotobuf PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${Protobuf_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${Protobuf_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES "${Protobuf_LIBRARY}" + ) + add_executable(protobuf::protoc IMPORTED) + set_target_properties(protobuf::protoc PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${Protobuf_PROTOC_EXECUTABLE}" + INTERFACE_LINK_LIBRARIES "${Protobuf_PROTOC_LIBRARY}" + ) + endif() if(Protobuf_FOUND AND CMAKE_CROSSCOMPILING) find_program(PROTOC_EXECUTABLE protoc HINTS