I'm generating .pro files for QtCreator from a CMake script. A file in the project is to be generated later using a QMAKE_EXTRA_COMPILERS instruction (the file is re-generated from other ones using an external tool only if it is older than them).
- To make sure the file to be generated is imported in QtCreator project without warning, I need to create it (else QtCreator reports warnings while parsing the .pro file).
- To make sure the file gets generated upon first compilation, I need to change the timestamp to be very old (older than any input file used to generate it). This is needed for QMAKE_EXTRA_COMPILERS to consider the file as needing to be re-generated.
To do so, I do:
file(WRITE ${output_file_path} "To be generated..." )
execute_process( COMMAND touch.exe ${output_file_path} -t 0001010101 )
But, the execute_process( COMMAND touch.exe ${output_file_path} -t 0001010101 ) takes a while. I have hundreds of files like that in my project and commenting this execute_process line divides my CMake generation time by 2 (0m45s vs 1m30s). I bet the execution of an external process is slowing things down....
Is there any way to change a file timestamp using pure CMake commands?