Cmake to autogenerate thrift code

build, cmake, thrift

Solution

Better late then never. Use add_custom_command

add_custom_command(
OUTPUT
    ${GEN_FILES_PATH}/DebugProtoTest_types.cpp
    ${GEN_FILES_PATH}/DebugProtoTest_types.h
COMMAND
    $<TARGET_FILE:compiler> --gen cpp:dense ${TEST_PATH}/DebugProtoTest.thrift
DEPENDS
    compiler
WORKING_DIRECTORY
    ${CMAKE_BINARY_DIR}
)

I use it to generate test-related stuff for Apache thrift here

Problem

So the only decent example I've found for this is http://grokbase.com/t/thrift/user/1162hvgrdn/recommended-way-to-incorporate-thrift-to-the-build-system , however it seems to be quite buggy, for example the if statement is missing ${THRIFT_FILE} . That said I'm getting caught up on execute prcoess command returning: "execute_process given uknown argument - "STUFF" where stuff is what looks tobe a proper thrift command. Any suggestions and what's wrong here?

Original source