From 5ba411dd641d4410d46c6dac9dedd542573b58f8 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Thu, 18 Apr 2002 14:19:39 -0400 Subject: [PATCH] ENH: check for mis-matched source directories --- Source/cmake.cxx | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Source/cmake.cxx b/Source/cmake.cxx index d5faaa5ce..20235368b 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -356,6 +356,31 @@ int cmake::Generate(const std::vector& args, bool buildMakefiles) // Read and parse the input makefile mf.MakeStartDirectoriesCurrent(); cmCacheManager::GetInstance()->LoadCache(&mf); + if(mf.GetDefinition("CMAKE_START_DIRECTORY")) + { + std::string cacheStart = + cmSystemTools::CollapseFullPath(mf.GetDefinition("CMAKE_START_DIRECTORY")); + std::string currentStart = + cmSystemTools::CollapseFullPath(mf.GetStartDirectory()); +#ifdef _WIN32 + cacheStart = cmSystemTools::LowerCase(cacheStart); + currentStart = cmSystemTools::LowerCase(currentStart); +#endif + if(cacheStart != currentStart) + { + std::string message = "Error: source directory: "; + message += currentStart; + message += "\nDoes not match source directory used to generate cache: "; + message += cacheStart; + message += "\nRe-run cmake with a different source directory."; + cmSystemTools::Error(message.c_str()); + return -1; + } + } + mf.AddCacheDefinition("CMAKE_START_DIRECTORY", mf.GetStartDirectory(), + "Start directory with the top level CMakeLists.txt file for this project", + cmCacheManager::INTERNAL); + // extract command line arguments that might add cache entries this->SetCacheArgs(mf, args); // no generator specified on the command line