MantisBT - CMake
View Issue Details
0015161CMakeCMakepublic2014-09-17 00:202015-03-02 08:57
hansmi 
Brad King 
normalminoralways
closedfixed 
 
CMake 3.1CMake 3.1 
0015161: FindProtobuf: Generated source not regenerated on library update
After updating from Protocol Buffers 2.5.0 to 2.6.0 compilation of the generated source failed: “This file was generated by an older version of protoc which is incompatible with your Protocol Buffer headers. Please regenerate this file with a newer version of protoc.”.

Turns out the source and headers generated by way of FindProtobuf.cmake:PROTOBUF_GENERATE_CPP aren't updated. Adding a dependency on the compiler executable fixes this issue.

Proposed patch:

$ diff -u FindProtobuf.cmake.orig FindProtobuf.cmake
--- FindProtobuf.cmake.orig 2014-09-17 06:11:10.282377650 +0200
+++ FindProtobuf.cmake 2014-09-17 06:11:10.282377650 +0200
@@ -118,7 +118,7 @@
              "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
       COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
       ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
- DEPENDS ${ABS_FIL}
+ DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
       COMMENT "Running C++ protocol buffer compiler on ${FIL}"
       VERBATIM )
   endforeach()
1. Install Protocol Buffers 2.5.0
2. Generate source and header using 2.5.0's protoc binary
3. Install Protocol Buffers 2.6.0
4. Re-build source
Workaround in case someone's affected by this and can't modify FindProtobuf.cmake in their environment:

foreach(i ${PROTO_SRCS} ${PROTO_HDRS})
  add_custom_command(OUTPUT ${i} DEPENDS ${PROTOBUF_PROTOC_EXECUTABLE} APPEND)
endforeach()
No tags attached.
Issue History
2014-09-17 00:20hansmiNew Issue
2014-09-18 09:18Brad KingNote Added: 0036821
2014-09-18 09:18Brad KingAssigned To => Brad King
2014-09-18 09:18Brad KingStatusnew => resolved
2014-09-18 09:18Brad KingResolutionopen => fixed
2014-09-18 09:18Brad KingFixed in Version => CMake 3.1
2014-09-18 09:18Brad KingTarget Version => CMake 3.1
2015-03-02 08:57Robert MaynardNote Added: 0038126
2015-03-02 08:57Robert MaynardStatusresolved => closed

Notes
(0036821)
Brad King   
2014-09-18 09:18   
Applied, thanks:

FindProtobuf: Make outputs depend on protoc executable
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e380d7c5 [^]
(0038126)
Robert Maynard   
2015-03-02 08:57   
Closing resolved issues that have not been updated in more than 4 months.