0

My build system manually generates some files from others. It's using Visual Studio 2015 with CMake 3.11.4. It uses ADD_CUSTOM_TARGET to invoke some internal scripts. Those scripts end up creating a file containing the timestamp when files where generated and this file is later used to only generate what needs to be.

I want this file containing the timestamp to be deleted when we clean the solution (In Visual Studio, "Build" -> "Clean solution"). I tried to add some CMake instruction:

SET_TARGET_PROPERTIES( MY_TARGET PROPERTIES ADDITIONAL_CLEAN_FILES "C:/dev/build/generated.timestamp" )
SET_PROPERTY( TARGET MY_TARGET APPEND PROPERTY ADDITIONAL_CLEAN_FILES "C:/dev/build/generated.timestamp" ) 
SET_PROPERTY( GLOBAL APPEND PROPERTY ADDITIONAL_CLEAN_FILES "C:/dev/build/generated.timestamp" )
SET_DIRECTORY_PROPERTIES( PROPERTIES ADDITIONAL_CLEAN_FILES "C:/dev/build/generated.timestamp" )

But none of them makes the file be deleted when I clean.

Is this doable and if so, what am I doing wrong?

jpo38
  • 20,821
  • 10
  • 70
  • 151
  • 2
    From the description of the property [ADDITIONAL_CLEAN_FILES](https://cmake.org/cmake/help/latest/prop_tgt/ADDITIONAL_CLEAN_FILES.html): "This property only works for the Ninja and the Makefile generators. It is ignored by other generators.". That means the property doesn't work for Visual Studio. – Tsyvarev Sep 01 '20 at 10:19
  • @Tsyvarev: Good point, I totally missed that. Do you know if there is any alternative? – jpo38 Sep 01 '20 at 10:29
  • No, I don't know an alternative for Visual Studio. Actually, looking into the [way](https://stackoverflow.com/a/3956598/3440745) how one could set clean files for Visual Studio **without** CMake, I find it very similar to `ADDITIONAL_CLEAN_FILES` semantic. It looks strange that CMake developers doesn't implement `ADDITIONAL_CLEAN_FILES` for Visual Studio. – Tsyvarev Sep 01 '20 at 11:31

0 Answers0