Reputation: 341
I want to install all files under a folder called scfg which contains .cfg, .xml files, and folders to another location which contains scfg. The code below installs correctly.
file(GLOB config_files "scfg/*.cfg")
install(FILES ${config_files} DESTINATION scfg)
file(GLOB xml_files "scfg/*.xml")
install(FILES ${xml_files} DESTINATION scfg)
But it is possible that there will be more files with types other than .cfg and .xml in the future. To prevent changing this file frequently, I am looking for a more generic solution, such as installing all file types other than folders. I have heard about the EXCLUDE keyword. But I don't know what PATTERN I should use for folders.
Upvotes: 6
Views: 16054
Reputation: 341
It should exclude subdirectories explicitly and then all other files will be installed correctly as usual.
install(DIRECTORY scfg/ DESTINATION scfg
PATTERN "scfg/config/" EXCLUDE
PATTERN "scfg/xml/" EXCLUDE
)
Upvotes: 11