add_subdirectory: Add SYSTEM option

Fixes: #22401
Signed-off-by: Da Quexian <daquexian566@gmail.com>
This commit is contained in:
Da Quexian
2022-06-22 20:18:06 +08:00
committed by Brad King
parent 80e4a155e0
commit 2eb30a7036
42 changed files with 199 additions and 18 deletions

View File

@@ -26,6 +26,7 @@ bool cmAddSubDirectoryCommand(std::vector<std::string> const& args,
std::string binArg;
bool excludeFromAll = false;
bool system = false;
// process the rest of the arguments looking for optional args
for (std::string const& arg : cmMakeRange(args).advance(1)) {
@@ -33,6 +34,10 @@ bool cmAddSubDirectoryCommand(std::vector<std::string> const& args,
excludeFromAll = true;
continue;
}
if (arg == "SYSTEM") {
system = true;
continue;
}
if (binArg.empty()) {
binArg = arg;
} else {
@@ -40,6 +45,11 @@ bool cmAddSubDirectoryCommand(std::vector<std::string> const& args,
return false;
}
}
// "SYSTEM" directory property should also affects targets in nested
// subdirectories.
if (mf.GetPropertyAsBool("SYSTEM")) {
system = true;
}
// Compute the full path to the specified source directory.
// Interpret a relative path with respect to the current source directory.
@@ -102,7 +112,7 @@ bool cmAddSubDirectoryCommand(std::vector<std::string> const& args,
binPath = cmSystemTools::CollapseFullPath(binPath);
// Add the subdirectory using the computed full paths.
mf.AddSubDirectory(srcPath, binPath, excludeFromAll, true);
mf.AddSubDirectory(srcPath, binPath, excludeFromAll, true, system);
return true;
}