You can run a CMake script with add_custom_command() which executes file(blob).  Check out the &quot;-P&quot; flag to cmake.<br><br><div class="gmail_quote">On Sat, Apr 4, 2009 at 10:07 AM, Jeremy Cowgar <span dir="ltr">&lt;<a href="mailto:jeremy@cowgar.com">jeremy@cowgar.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Can I trigger the FILE( GLOB .. ) to run right before the executable is built? Or cause the ADD_CUSTOM_COMMAND to execute the FILE( GLOB ... ) after it&#39;s done? This has to be able to be solved somehow...<br>
<font color="#888888">
<br>
Jeremy</font><div class="im"><br>
<br>
<br>
Jeremy Cowgar wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello,<br>
<br>
I use CMake with quite a few simple projects, however, I am migrating one project that has a few Makefiles for different platforms/compilers. I am running into a problem with a custom command, it&#39;s output and how to link against it.<br>

<br>
Here is the situation. I have 1 file, say parser.e. It will be translated into C. However, the tool doing the translating will split the file into many C files if too large, but more than that, parser.e may include common.e, version.e, johndoe.e. The translator will also translate all of those. So, from parser.e, I wind up with parser_1.c, parser_2.c, common.c, version.c, johndoe.c. Now, someone ads a feature to parser.e that requires regex.e, well, now the translation will include regex_1.c, regex_2.c. So, the thing is, I don&#39;t want to maintain that parser.e translates into XYZ, ABC files because it&#39;s in such a state of flux. So, I did this:<br>

<br>
FILE( MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/int )<br>
ADD_CUSTOM_COMMAND(<br>
 OUTPUT int/main.c<br>
 DEPENDS ${EU_CORE_FILES} ${EU_INTERPRETER_FILES}<br>
 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/int<br>
 COMMAND ${TRANSLATOR} ${CMAKE_CURRENT_SOURCE_DIR}/int.ex<br>
)<br>
FILE( GLOB EU_INTERPRETER_SOURCES &quot;${CMAKE_CURRENT_SOURCE_DIR}/int/*.c&quot; )<br>
<br>
That makes the directory where the translated files will go, adds a custom command with the output set to int/main.c which I know will *always* exist after translation. Then, I set the source file list that I can later link into the main application via FILE( GLOB ... ).<br>

<br>
The problem with this is, it seems that FILE( GLOB .. ) is running before the custom command, thus, the first time I try to build, I get all sorts of linking problems because EU_INTERPRETER_SOURCES is empty. Now, the next time I run, it finds the files and things link properly.<br>

</blockquote>
<br></div><div><div></div><div class="h5">
_______________________________________________<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>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Philip Lowman<br>