I have a fairly large project which is structured in such a way that, after a large number of files have been generated, they are placed into a special ‘Generated’ folder within my Visual Studio project:
source_group(TREE ${CMAKE_CURRENT_BINARY_DIR}/GENERATED
PREFIX "Generated"
FILES ${SOURCE_FILES_GENERATED_FROM_BISON}
${HEADER_FILES_GENERATED_FROM_BISON}
${SOURCE_FILES_GENERATED_FROM_FLEX}
${SOURCE_FILES_GENERATED_FROM_UI}
${HEADER_FILES_GENERATED_FROM_UI}
${MOC_FILES})
Much later in the project, after having gathered some other information which wasn’t available when the first files were generated, I generate one more file and I’d like to add it to the same Visual Studio project folder as the ones I generated earlier.
I can’t figure out a way of doing this. If I use the alternative syntax for the source_group command, viz.
source_group(${target}/GENERATED/${target}
FILES ${extraFile})
…then the new file is placed exactly where I want it to be, but all the ones that were there before get removed from the folder.
It looks that the two ways of using source_group are mutually incompatible. Is that the case, or is there a way of doing this?
[I know that there is a workaround of retaining the list of files that I had when I executed the first source_group command, and then doing a single invocation of source_group using the ‘TREE’ syntax after the extra file has been generated. That would need quite a lot of refactoring, though, so I’d rather avoid it if there’s a simpler way.]