You might want to look at this:<div><meta http-equiv="content-type" content="text/html; charset=utf-8"><a href="https://github.com/rpavlik/cmake-modules/blob/master/FileCopyTargets.cmake">https://github.com/rpavlik/cmake-modules/blob/master/FileCopyTargets.cmake</a></div>
<div><br></div><div><a href="https://github.com/rpavlik/cmake-modules/blob/master/FileCopyTargets.cmake"></a>While the command it adds just does a copy, you could run your preprocessor in place of that copy command.  Perhaps the most pertinent piece of advice is to use a loop and add a custom command for each input/output file pair, rather than a single overall command - this will let you just regenerate the files that depend on modified sources.</div>
<div><br></div><div>Ryan<br><br><div class="gmail_quote">On Fri, Feb 11, 2011 at 10:37 AM, Dietmar Hummel <span dir="ltr">&lt;<a href="mailto:hummel@treibauf.ch">hummel@treibauf.ch</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
 Hi list!<br>
<br>
Hopefulle you can help me with a problem I could not figure out how to do.<br>
With a self written preprocessor, we add some generated code to our software.<br>
This means the preprocessor is looking into the cpp files and is creating additional<br>
code depending on some special marker found in the code. For most of the files of<br>
the project there is just nothing to create.<br>
Because this preprocessor tool is self written, we are free to either add this generated<br>
code directly into the cpp file or to create a second module containing this code.<br>
<br>
My problem is to find a cmake solution to start the preprocessor for all files of the project<br>
but find a clean handling for the modified ones. In short words we are searching a solution<br>
likely the same as Qt moc.<br>
<br>
First idea was a solution based on following thread:<br>
<a href="http://stackoverflow.com/questions/2354473/cmake-add-custom-command" target="_blank">http://stackoverflow.com/questions/2354473/cmake-add-custom-command</a><br>
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.<br>

<br>
Second try was the idea to add the generated code directly into the cpp file itself and call the<br>
preprocessor with something like that:<br>
<br>
add_custom_command(<br>
  OUTPUT ${binCmakeTestSources}<br>
  COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/dopoc2.bat &quot;${binCmakeTestSources}&quot;<br>
  DEPENDS ${binCmakeTestSources}<br>
)<br>
<br>
This runs the preprocessor but the buildsystem always compiles all modules even if they are untouched....<br>
Just two more questions: Is the Qt moc and uic handling in cmake some special implementation?<br>
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...<br>

<br>
Maybe somebody could give me a hint...<br>
<br>
Regards<br>
Dietmar<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Ryan Pavlik<br>HCI Graduate Student<br>Virtual Reality Applications Center<br>Iowa State University<br><br><a href="mailto:rpavlik@iastate.edu">rpavlik@iastate.edu</a><br>
<a href="http://academic.cleardefinition.com">http://academic.cleardefinition.com</a><br>Internal VRAC/HCI Site: <a href="http://tinyurl.com/rpavlik">http://tinyurl.com/rpavlik</a><br>
</div>