diff options
author | Vitaly Buka <vitalybuka@google.com> | 2018-10-31 13:41:56 -0700 |
---|---|---|
committer | Vitaly Buka <vitalybuka@gmail.com> | 2018-10-31 16:25:24 -0700 |
commit | 3a5b2f6fb9dc0dcb651fca132a055eaf2d1a7f35 (patch) | |
tree | ee78b1b254a7a56b0e41cb5afc2abadc478b8529 | |
parent | 652f387fc39b15a45794e383a7311ad22696ec48 (diff) | |
download | libprotobuf-mutator-3a5b2f6fb9dc0dcb651fca132a055eaf2d1a7f35.tar.gz |
Fix build with LIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON
Fix build with cmake 3.10. Not it uses protobuf::protoc instead of protoc.
Fix build when protoc is already installed but we still want to download own copy.
-rw-r--r-- | cmake/external/protobuf.cmake | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/cmake/external/protobuf.cmake b/cmake/external/protobuf.cmake index df79110..88066ff 100644 --- a/cmake/external/protobuf.cmake +++ b/cmake/external/protobuf.cmake @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# We only need protobuf_generate_cpp from FindProtobuf, and we are going to +# override the rest with ExternalProject version. include (FindProtobuf) set(PROTOBUF_TARGET external.protobuf) @@ -38,10 +40,19 @@ endforeach(lib) set(PROTOBUF_PROTOC_EXECUTABLE ${PROTOBUF_INSTALL_DIR}/bin/protoc) list(APPEND PROTOBUF_BUILD_BYPRODUCTS ${PROTOBUF_PROTOC_EXECUTABLE}) -add_executable(protoc IMPORTED) -set_property(TARGET protoc PROPERTY IMPORTED_LOCATION + +if(${CMAKE_VERSION} VERSION_LESS "3.10.0") + set(PROTOBUF_PROTOC_TARGET protoc) +else() + set(PROTOBUF_PROTOC_TARGET protobuf::protoc) +endif() + +if(NOT TARGET ${PROTOBUF_PROTOC_TARGET}) + add_executable(${PROTOBUF_PROTOC_TARGET} IMPORTED) +endif() +set_property(TARGET ${PROTOBUF_PROTOC_TARGET} PROPERTY IMPORTED_LOCATION ${PROTOBUF_PROTOC_EXECUTABLE}) -add_dependencies(protoc ${PROTOBUF_TARGET}) +add_dependencies(${PROTOBUF_PROTOC_TARGET} ${PROTOBUF_TARGET}) include (ExternalProject) ExternalProject_Add(${PROTOBUF_TARGET} |