[CMake] Generating Source Files

Michael Jackson mike.jackson at bluequartz.net
Wed Apr 8 13:29:19 EDT 2009


Jeremy Cowgar wrote:
> Bill Hoffman wrote:
>> One more option would be to run the parser every time cmake is run.  
>> If you had an option to the parser that just spit out the list of 
>> files you needed to compile, and it ran relatively fast, you could do 
>> this:
>>
>> # only run if parser.e is newer than source.cmake
>> if(parser.e IS_NEWER_THAN source.cmake)
>>    execute_process(COMMAND myparser  parser.e --sources sources.cmake)
>> endif()
> 
> I like this solution much better, but I have simplified things for my 
> example. I have been stating parser.e is the only input file. While that 
> is true, parser.e is known to depend on a set of other files. So, in the 
> above example I would need to check IS_NEWER_THAN a list of files I have:
> 
> SET( EU_CORE_FILES common.e emit.e error.e fwdref.e global.e inline.e 
> keylist.e main.e mode.e opnames.e parser.e
>  pathopen.e reswords.e scanner.e scinot.e shift.e symtab.e )
> 
> Is there a simple way of doing that?
> 
> Jeremy

# Something like the following should get you started.

set(UPDATE_PARSER_STUFF 0)
foreach(file ${EU_CORE_FILES} )
   if(${file} IS_NEWER_THAN source.cmake)
    set(UPDATE_PARSER_STUFF 1)
  endif()
endforeach()

if (UPDATE_PARSER_STUFF)
# fix the below command to take the correct arguments
  execute_process(COMMAND myparser  parser.e --sources sources.cmake)
endif()







More information about the CMake mailing list