I'm working on a project that is partially generated from an XSD schema using codesynthesis. I have used the FindXSD.cmake at the following address to have CMake properly search for the XSD header: http://wiki.codesynthesis.com/uploads/8/86/FindXSD.cmake.gz
This FindXSD.cmake sets the XSD_EXECUTABLE variable, which I would like to use to also generate the code from the schema prior to building any target (the main target of the project is a library), but being unfamiliar with CMake, I have a hard time understanding how to integrate such a custom command.
Here is what I did so far:
add_library (mylibrary ${MY_PROJECT_SRC})
add_custom_command(TARGET mylibrary PRE_BUILD
COMMAND "${XSD_EXECUTABLE} cxx-tree --type-naming knr
-- hxx-suffix .hpp --cxx-suffix .cpp
${MY_PROJECT_SOURCE_DIR}/src/model/Model.xsd")
But it doesn't seem to do anything and besides, if it did, I wouldn't know where the files are generated (the command should generate Model.hpp and Model.cpp), so I don't know what commands to add to have Model.cpp being compiled within the target library and Model.hpp being found by other source files that require it.