It was suggested that we might fail to generate the flatbuffer includes before compiling when doing parallel builds (which would be a bug).
We currently generate the includes like this, and according to my understanding target_sources should take care of the dependency.
function(generate_flatbuffers _target) foreach(fbs ${ARGN}) #Necessary because we can get relative paths as name, e.g. commands/create_entity get_filename_component(filename ${fbs} NAME) #We first generate into a temporary directory to avoid changing the timestamp of the actual dependency unnecessarily. #Otherwise we'd end up unnecessarily rebuilding the target. add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${fbs}_generated.h COMMAND ${FLATBUFFERS_FLATC_EXECUTABLE} -c -b -o ${CMAKE_CURRENT_BINARY_DIR}/flatbufferstmp ${CMAKE_CURRENT_SOURCE_DIR}/${fbs}.fbs COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/flatbufferstmp/${filename}_generated.h ${CMAKE_CURRENT_BINARY_DIR}/${filename}_generated.h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${fbs}.fbs ) target_sources(${_target} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/${fbs}_generated.h) set_property(SOURCE ${fbs}_generated.h PROPERTY SKIP_AUTOMOC ON) endforeach(fbs) endfunction(generate_flatbuffers)