file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Greenstack/payload)

macro(Flatbuffers)
   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Greenstack/payload/${ARGV0}_generated.h
                      COMMAND
                         ${FLATC} -c
                                  -o ${CMAKE_CURRENT_BINARY_DIR}/Greenstack/payload
                                  ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}.fbs
                      DEPENDS
                         ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}.fbs
                      COMMENT "Generating code for ${ARGV0}")
    list(APPEND FLATBUFFER_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/Greenstack/payload/${ARGV0}_generated.h")
endmacro(Flatbuffers)

Flatbuffers(AssumeRoleRequest)
Flatbuffers(CreateBucketRequest)
Flatbuffers(DeleteBucketRequest)
Flatbuffers(Document)
FlatBuffers(GetRequest)
FlatBuffers(GetResponse)
Flatbuffers(HelloRequest)
Flatbuffers(HelloResponse)
FlatBuffers(KeepaliveRequest)
Flatbuffers(ListBucketsResponse)
Flatbuffers(MutationRequest)
Flatbuffers(MutationResponse)
Flatbuffers(SaslAuthRequest)
Flatbuffers(SaslAuthResponse)
Flatbuffers(SelectBucketRequest)

add_custom_target(generate_flatbuffer_headers ALL
                  DEPENDS
                  ${FLATBUFFER_SOURCES})

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Greenstack/payload)

macro(Flatbuffers)
   add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Greenstack/payload/${ARGV0}_generated.h
                      COMMAND
                         ${FLATC} -c
                                  -o ${CMAKE_CURRENT_BINARY_DIR}/Greenstack/payload
                                  ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}.fbs
                      DEPENDS
                         ${CMAKE_CURRENT_SOURCE_DIR}/${ARGV0}.fbs
                         ${FLATC}
                      COMMENT "Generating code for ${ARGV0}")
    list(APPEND FLATBUFFER_SOURCES "${CMAKE_CURRENT_BINARY_DIR}/Greenstack/payload/${ARGV0}_generated.h")
endmacro(Flatbuffers)

Flatbuffers(AssumeRoleRequest)
Flatbuffers(CreateBucketRequest)
Flatbuffers(DeleteBucketRequest)
Flatbuffers(Document)
FlatBuffers(GetRequest)
FlatBuffers(GetResponse)
Flatbuffers(HelloRequest)
Flatbuffers(HelloResponse)
FlatBuffers(KeepaliveRequest)
Flatbuffers(ListBucketsResponse)
Flatbuffers(MutationRequest)
Flatbuffers(MutationResponse)
Flatbuffers(SaslAuthRequest)
Flatbuffers(SaslAuthResponse)
Flatbuffers(SelectBucketRequest)

add_custom_target(generate_flatbuffer_headers ALL
                  DEPENDS
                  ${FLATBUFFER_SOURCES})

Add dep to flatc for the generated flatbuffer files
CBD-1942: Add dep to flatc for the generated flatbuffer files

The source generated by one version of flatbuffers may not
compile with the header files from another version of
flatbuffers so they should be regenerated when we upgrade
flatbuffers.

Change-Id: I269f18245ee8824dea1749f8b7711f619143207e
Reviewed-on: http://review.couchbase.org/71399
Tested-by: buildbot <80754af91bfb6d1073585b046fe0a474ce868509@couchbase.com>
Reviewed-by: Trond Norbye <60edd2ef23891a753f231b0c6f161dc634079a93@gmail.com>
