You can run a CMake script with add_custom_command() which executes file(blob). Check out the "-P" flag to cmake.
On Sat, Apr 4, 2009 at 10:07 AM, Jeremy Cowgar <[email protected]> wrote: > 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's done? This has to be able to be solved somehow... > > Jeremy > > > Jeremy Cowgar wrote: > >> Hello, >> >> 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's output and how to link >> against it. >> >> 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't want to maintain that parser.e translates into XYZ, >> ABC files because it's in such a state of flux. So, I did this: >> >> FILE( MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/int ) >> ADD_CUSTOM_COMMAND( >> OUTPUT int/main.c >> DEPENDS ${EU_CORE_FILES} ${EU_INTERPRETER_FILES} >> WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/int >> COMMAND ${TRANSLATOR} ${CMAKE_CURRENT_SOURCE_DIR}/int.ex >> ) >> FILE( GLOB EU_INTERPRETER_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/int/*.c" ) >> >> 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 ... ). >> >> 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. >> > > _______________________________________________ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake > -- Philip Lowman
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
