summaryrefslogtreecommitdiff
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-06-03 08:32:44 -0400
committerBrad King <brad.king@kitware.com>2021-06-03 08:32:44 -0400
commit6c34ed9b879906d1eaadad80f37f518829017789 (patch)
tree45043b460fae481ff6592a7fc016e1b893431bc7 /Source/cmake.cxx
parent9c33ff4dda643f8a93d55f9895e31dce9056134f (diff)
downloadcmake-6c34ed9b879906d1eaadad80f37f518829017789.tar.gz
cmake: Allow CMAKE_TOOLCHAIN_FILE to be set by environment variable
When no `CMAKE_TOOLCHAIN_FILE` is explicitly specified while creating a new build tree, check for an environment variable of the same name.
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx10
1 files changed, 10 insertions, 0 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 840a9d959c..9a866ab89b 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2040,6 +2040,16 @@ int cmake::ActualConfigure()
this->GlobalGenerator->GetExtraGeneratorName().c_str(),
"Name of external makefile project generator.",
cmStateEnums::INTERNAL);
+
+ if (!this->State->GetInitializedCacheValue("CMAKE_TOOLCHAIN_FILE")) {
+ std::string envToolchain;
+ if (cmSystemTools::GetEnv("CMAKE_TOOLCHAIN_FILE", envToolchain) &&
+ !envToolchain.empty()) {
+ this->AddCacheEntry("CMAKE_TOOLCHAIN_FILE", envToolchain.c_str(),
+ "The CMake toolchain file",
+ cmStateEnums::FILEPATH);
+ }
+ }
}
if (cmProp instance =