Reputation: 144
The FindProtobuf module available in cmake offers the command PROTOBUF_GENERATE_CPP that calls protoc from within cmake. This command is normally executed at compilation time (when you run "make"). Since some of my source files include the generated files, the dependency check during "cmake .." fails because the files are not yet generated.
Is it possible to have this command run at configuration time right before the dependency check?
Thanks
Upvotes: 3
Views: 7010
Reputation: 20561
You can mark the files as going to be generated, so that the dependency check will work:
file(GLOB PROTOBUF_FILELIST ${PROTO_INCLUDE_DIR}/*.proto)
foreach( proto_file ${PROTOBUF_FILELIST} )
get_filename_component(proto_name ${proto_file} NAME_WE)
get_filename_component(proto_path ${PROTO_INCLUDE_DIR} ABSOLUTE)
set_source_files_properties("${proto_path}/${proto_name}.pb.cc"
"${proto_path}/${proto_name}.pb.h"
PROPERTIES GENERATED TRUE)
endforeach()
Upvotes: 4