Browse Source

Fix build for downloaded protobuf

Test sources generation command enhanced with dependees.

NOTE: Looks like fix for low versions of protobuf does not work.
It is worth perhaps to download protobuf if version found is
too low (like in Ubuntu 18.04: protoc v.3.0.0)
Viktor Kopp 6 years ago
parent
commit
d34a3de8c2
1 changed files with 3 additions and 2 deletions
  1. 3 2
      CMakeLists.txt

+ 3 - 2
CMakeLists.txt

@@ -10,6 +10,7 @@ if (NOT Protobuf_FOUND OR Protobuf_VERSION VERSION_LESS "3.0.0")
                      GIT_TAG             3.7.x
     )
     set(protobuf_BUILD_TESTS OFF CACHE BOOL "Disable protobuf tests build" FORCE)
+    set(Protobuf_PROTOC_EXECUTABLE protoc)
     add_subdirectory("${Protobuf_SOURCE_DIR}/cmake" ${Protobuf_BINARY_DIR})
 endif()
 
@@ -78,15 +79,15 @@ if(MAKE_TESTS)
             COMMENT "Generating test headers"
             )
     elseif(UNIX)
-        add_custom_command(TARGET ${testgeneration} POST_BUILD
+        add_custom_command(TARGET ${testgeneration}
             COMMAND ${Protobuf_PROTOC_EXECUTABLE} --plugin=protoc-gen-${PROJECT_NAME}=${CMAKE_BINARY_DIR}/qtprotobuf --qtprotobuf_out=${CMAKE_CURRENT_BINARY_DIR}/tests
             ${PROTO_FILES}
             WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tests/proto/
+            DEPENDS ${PROJECT_NAME} ${PROTO_FILES}
             COMMENT "Generating test headers"
             )
     endif()
 
-    add_dependencies(${testgeneration} ${PROJECT_NAME})
     add_subdirectory("tests")
 endif()