From ba1065ab7b3c293245b3bbe733f8f062b9aa7ac9 Mon Sep 17 00:00:00 2001 From: Clinton Stimpson Date: Fri, 14 Aug 2015 22:45:53 -0600 Subject: [PATCH] cmake: Add support for "--build ." in subdirectory (#15696) --- Source/cmake.cxx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 285532914..62b3f833a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2745,6 +2745,25 @@ int cmake::Build(const std::string& dir, } std::string cachePath = dir; cmSystemTools::ConvertToUnixSlashes(cachePath); + std::string cacheFile = cachePath; + cacheFile += "/CMakeCache.txt"; + if(!cmSystemTools::FileExists(cacheFile.c_str())) + { + // search in parent directories for cache + std::string cmakeFiles = cachePath; + cmakeFiles += "/CMakeFiles"; + if(cmSystemTools::FileExists(cmakeFiles.c_str())) + { + std::string cachePathFound = + cmSystemTools::FileExistsInParentDirectories( + "CMakeCache.txt", cachePath.c_str(), "/"); + if(!cachePathFound.empty()) + { + cachePath = cmSystemTools::GetFilenamePath(cachePathFound); + } + } + } + if(!this->LoadCache(cachePath)) { std::cerr << "Error: could not load cache\n";