[cmake-developers] Generating files at generate-time

Stephen Kelly steveire at gmail.com
Thu May 2 11:07:36 EDT 2013


Brad King wrote:

> On 04/23/2013 03:07 PM, Stephen Kelly wrote:
>>  file(EVALUATE "${CMAKE_CURRENT_SOURCE_DIR}/input.txt"
>>                "${CMAKE_CURRENT_BINARY_DIR}/output.txt"
>>  )
> [snip]
>>  file(EVALUATE "${CMAKE_CURRENT_BINARY_DIR}/input.txt"
>>                "${CMAKE_CURRENT_BINARY_DIR}/output_$<CONFIGURATION>.txt"
>>      CONFIGURATIONS Debug Release
>>  )
> [snip]
>>  file(EVALUATE "${CMAKE_CURRENT_BINARY_DIR}/input.txt"
>>                "${CMAKE_CURRENT_BINARY_DIR}/output_$<CONFIGURATION>.txt"
>>      ALL_CONFIGURATIONS
>>  )

> In order to select which configurations get the generation we could
> just have an argument to specify a condition for generation.  That
> condition could then be populated with a generator expression to
> test $<CONFIG:...> or something.

That's a little bit better than a list of configurations as I proposed, but 
I don't think it solves the problem I raised.

How do you generate a file only once with non-config-dependent content in a 
simple case?

 file(GENERATE
      OUTPUT "the_output.txt"
      CONTENT "The content"
      CONDITION 1
   )

That will be generated N times in multi-config generators, and once for 
single-config, right? Currently in my branch it is an error to cause one 
file name to be used to generate content twice.

Thanks,

Steve.





More information about the cmake-developers mailing list