From 6ecac46b4e2dd174909ec349bd03bca92950266e Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 4 Jul 2018 15:09:22 +0200 Subject: [PATCH] cmake: fix detection protobuf --- lib/formats/CMakeLists.txt | 56 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/formats/CMakeLists.txt b/lib/formats/CMakeLists.txt index 8e4ecee3f..52d918698 100644 --- a/lib/formats/CMakeLists.txt +++ b/lib/formats/CMakeLists.txt @@ -38,33 +38,8 @@ set(LIBRARIES ${OPENSSL_LIBRARIES} ) -if(DEFINED PROTOBUF_COMPILER) - add_custom_target(protobuf ALL - COMMAND ${PROTOBUF_COMPILER} - --python_out=${CMAKE_CURRENT_BINARY_DIR} - #--php_out=${CMAKE_BINARY_DIR} - --js_out=${CMAKE_CURRENT_BINARY_DIR} - --cpp_out=${CMAKE_CURRENT_BINARY_DIR} - villas.proto - DEPENDS villas.proto - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) -endif() - -if(DEFINED PROTOBUFC_COMPILER) - add_custom_target(protobuf-c ALL - COMMAND ${PROTOBUFC_COMPILER} - --c_out=${CMAKE_CURRENT_BINARY_DIR} - villas.proto - DEPENDS villas.proto - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - ) - - add_dependencies(protobuf protobuf-c) -endif() - # Enable Google Protobuf format -if(ProtobufC_FOUND) +if(PROTOBUFC_FOUND) list(APPEND FORMAT_SRC protobuf.c ${CMAKE_CURRENT_BINARY_DIR}/villas.pb-c.c @@ -83,10 +58,35 @@ if(ProtobufC_FOUND) PROPERTIES GENERATED TRUE ) - - add_dependencies(formats protobuf-c) endif() add_library(formats STATIC ${FORMAT_SRC}) target_include_directories(formats PUBLIC ${INCLUDE_DIRS}) target_link_libraries(formats INTERFACE ${LIBRARIES}) + +if(DEFINED PROTOBUF_COMPILER AND PROTOBUF_FOUND) + add_custom_target(protobuf ALL + COMMAND ${PROTOBUF_COMPILER} + --python_out=${CMAKE_CURRENT_BINARY_DIR} + #--php_out=${CMAKE_BINARY_DIR} + --js_out=${CMAKE_CURRENT_BINARY_DIR} + --cpp_out=${CMAKE_CURRENT_BINARY_DIR} + villas.proto + DEPENDS villas.proto + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + + add_dependencies(formats protobuf) +endif() + +if(DEFINED PROTOBUFC_COMPILER AND PROTOBUFC_FOUND) + add_custom_target(protobuf-c ALL + COMMAND ${PROTOBUFC_COMPILER} + --c_out=${CMAKE_CURRENT_BINARY_DIR} + villas.proto + DEPENDS villas.proto + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ) + + add_dependencies(formats protobuf-c) +endif()