diff options
author | Brad King <brad.king@kitware.com> | 2022-09-27 14:28:30 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-09-27 14:28:49 (GMT) |
commit | 50b668ddc833f7312cbd1140ddcca85ac46a1b2b (patch) | |
tree | 11555484691ac8b02741ba95451d6163af3128b4 /Source | |
parent | 954b861dba50b4f84c2a1e58e5bdf3f05179572b (diff) | |
parent | 2eb30a7036214ec960f0666163ff44ef754f6afe (diff) | |
download | CMake-50b668ddc833f7312cbd1140ddcca85ac46a1b2b.zip CMake-50b668ddc833f7312cbd1140ddcca85ac46a1b2b.tar.gz CMake-50b668ddc833f7312cbd1140ddcca85ac46a1b2b.tar.bz2 |
Merge topic 'add_subdirectory_system'
2eb30a7036 add_subdirectory: Add SYSTEM option
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7399
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmAddSubDirectoryCommand.cxx | 12 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 6 | ||||
-rw-r--r-- | Source/cmMakefile.h | 2 | ||||
-rw-r--r-- | Source/cmSubdirCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 2 |
5 files changed, 20 insertions, 6 deletions
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 83d6306..6a2ab0b 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -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; } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index cf5d880..6e0d704 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1783,7 +1783,8 @@ void cmMakefile::ConfigureSubDirectory(cmMakefile* mf) void cmMakefile::AddSubDirectory(const std::string& srcPath, const std::string& binPath, - bool excludeFromAll, bool immediate) + bool excludeFromAll, bool immediate, + bool system) { if (this->DeferRunning) { this->IssueMessage( @@ -1813,6 +1814,9 @@ void cmMakefile::AddSubDirectory(const std::string& srcPath, if (excludeFromAll) { subMf->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); } + if (system) { + subMf->SetProperty("SYSTEM", "TRUE"); + } if (immediate) { this->ConfigureSubDirectory(subMf); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 873454d..3866aca 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -270,7 +270,7 @@ public: */ void AddSubDirectory(const std::string& fullSrcDir, const std::string& fullBinDir, bool excludeFromAll, - bool immediate); + bool immediate, bool system); void Configure(); diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx index 2477d7a..47082f1 100644 --- a/Source/cmSubdirCommand.cxx +++ b/Source/cmSubdirCommand.cxx @@ -32,7 +32,7 @@ bool cmSubdirCommand(std::vector<std::string> const& args, std::string srcPath = mf.GetCurrentSourceDirectory() + "/" + i; if (cmSystemTools::FileIsDirectory(srcPath)) { std::string binPath = mf.GetCurrentBinaryDirectory() + "/" + i; - mf.AddSubDirectory(srcPath, binPath, excludeFromAll, false); + mf.AddSubDirectory(srcPath, binPath, excludeFromAll, false, false); } // otherwise it is a full path else if (cmSystemTools::FileIsDirectory(i)) { @@ -40,7 +40,7 @@ bool cmSubdirCommand(std::vector<std::string> const& args, // element from the source path and use that std::string binPath = mf.GetCurrentBinaryDirectory() + "/" + cmSystemTools::GetFilenameName(i); - mf.AddSubDirectory(i, binPath, excludeFromAll, false); + mf.AddSubDirectory(i, binPath, excludeFromAll, false, false); } else { status.SetError(cmStrCat("Incorrect SUBDIRS command. Directory: ", i, " does not exist.")); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8fdc39..874195b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -786,7 +786,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, } } - if (this->IsImported()) { + if (this->IsImported() || mf->GetPropertyAsBool("SYSTEM")) { this->SetProperty("SYSTEM", "ON"); } |