diff options
author | Peter Waller <p@pwaller.net> | 2019-08-20 21:32:50 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-08-27 14:51:40 (GMT) |
commit | 4ca0526f8a78e7abbd08e9978d4110f836ccef9b (patch) | |
tree | 619d1ab993466c1250f2fca9c1ffcb1f4a40bd8e /Source/cmake.cxx | |
parent | 43fe736b2bf272647fb24b481bdc9a585c0666ac (diff) | |
download | CMake-4ca0526f8a78e7abbd08e9978d4110f836ccef9b.zip CMake-4ca0526f8a78e7abbd08e9978d4110f836ccef9b.tar.gz CMake-4ca0526f8a78e7abbd08e9978d4110f836ccef9b.tar.bz2 |
cmake: Pass -S and -B into PreLoad.cmake and -C scripts
Before this, it was not possible to see what the source or build directories
were set to on the command line.
Fixes: #19619
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 4ed17a3..b9902a3 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -430,6 +430,11 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) } // Register fake project commands that hint misuse in script mode. GetProjectCommandsInScriptMode(this->GetState()); + // Documented behaviour of CMAKE{,_CURRENT}_{SOURCE,BINARY}_DIR is to be + // set to $PWD for -P mode. + this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); + this->SetHomeOutputDirectory( + cmSystemTools::GetCurrentWorkingDirectory()); this->ReadListFile(args, path); } else if (arg.find("--find-package", 0) == 0) { findPackageMode = true; @@ -459,15 +464,9 @@ void cmake::ReadListFile(const std::vector<std::string>& args, // read in the list file to fill the cache if (!path.empty()) { this->CurrentSnapshot = this->State->Reset(); - std::string homeDir = this->GetHomeDirectory(); - std::string homeOutputDir = this->GetHomeOutputDirectory(); - this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); - this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); cmStateSnapshot snapshot = this->GetCurrentSnapshot(); - snapshot.GetDirectory().SetCurrentBinary( - cmSystemTools::GetCurrentWorkingDirectory()); - snapshot.GetDirectory().SetCurrentSource( - cmSystemTools::GetCurrentWorkingDirectory()); + snapshot.GetDirectory().SetCurrentBinary(this->GetHomeOutputDirectory()); + snapshot.GetDirectory().SetCurrentSource(this->GetHomeDirectory()); snapshot.SetDefaultDefinitions(); cmMakefile mf(gg, snapshot); if (this->GetWorkingMode() != NORMAL_MODE) { @@ -480,8 +479,6 @@ void cmake::ReadListFile(const std::vector<std::string>& args, if (!mf.ReadListFile(path)) { cmSystemTools::Error("Error processing file: " + path); } - this->SetHomeDirectory(homeDir); - this->SetHomeOutputDirectory(homeOutputDir); } // free generic one if generated |