[CMake] qt moc like feature
Dietmar Hummel
hummel at treibauf.ch
Fri Feb 11 11:37:41 EST 2011
Hi list!
Hopefulle you can help me with a problem I could not figure out how to do.
With a self written preprocessor, we add some generated code to our
software.
This means the preprocessor is looking into the cpp files and is
creating additional
code depending on some special marker found in the code. For most of the
files of
the project there is just nothing to create.
Because this preprocessor tool is self written, we are free to either
add this generated
code directly into the cpp file or to create a second module containing
this code.
My problem is to find a cmake solution to start the preprocessor for all
files of the project
but find a clean handling for the modified ones. In short words we are
searching a solution
likely the same as Qt moc.
First idea was a solution based on following thread:
http://stackoverflow.com/questions/2354473/cmake-add-custom-command
but the problem seems to be that this solution must create an additional
binary for every existing cpp file because the preprocessor is executed
at compile time and I have no chance to only add these files to the
project that are actually generated with useful content.
Second try was the idea to add the generated code directly into the cpp
file itself and call the
preprocessor with something like that:
add_custom_command(
OUTPUT ${binCmakeTestSources}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/dopoc2.bat "${binCmakeTestSources}"
DEPENDS ${binCmakeTestSources}
)
This runs the preprocessor but the buildsystem always compiles all
modules even if they are untouched....
Just two more questions: Is the Qt moc and uic handling in cmake some
special implementation?
Could this be easily enhanced by me with adapting macros? For me it
looks like this is some special Qt code inside cmake because i couldnt
find any macros and it looks like the decision if moc(uic is to be run
is made at cmake run not at c++ compile time...
Maybe somebody could give me a hint...
Regards
Dietmar
More information about the CMake
mailing list