diff options
author | Brad King <brad.king@kitware.com> | 2009-09-03 12:27:12 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-09-03 12:27:12 (GMT) |
commit | e3086213820a97db8432bf6089155509164fe960 (patch) | |
tree | 56bdbb70fa02ea4b64036af39bec6bd44d1a664c /Source/cmLocalGenerator.cxx | |
parent | 3fda5c6463f3d0d263b8e58503fa622a46932d8c (diff) | |
download | CMake-e3086213820a97db8432bf6089155509164fe960.zip CMake-e3086213820a97db8432bf6089155509164fe960.tar.gz CMake-e3086213820a97db8432bf6089155509164fe960.tar.bz2 |
Create CMP0014 to require CMakeLists.txt files
Until now CMake accidentally accepted add_subdirectory() and subdirs()
calls referring to directories that do not contain a CMakeLists.txt
file. We introduce CMake Policy CMP0014 to make this case an error.
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 65ea7e7..4d7bfdb 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -167,9 +167,49 @@ void cmLocalGenerator::ComputeObjectMaxPath() //---------------------------------------------------------------------------- void cmLocalGenerator::ReadInputFile() { + // Look for the CMakeLists.txt file. std::string currentStart = this->Makefile->GetStartDirectory(); currentStart += "/CMakeLists.txt"; - this->Makefile->ReadListFile(currentStart.c_str()); + if(cmSystemTools::FileExists(currentStart.c_str(), true)) + { + this->Makefile->ReadListFile(currentStart.c_str()); + return; + } + + if(!this->Parent) + { + return; + } + + // The file is missing. Check policy CMP0014. + cmMakefile* mf = this->Parent->GetMakefile(); + cmOStringStream e; + e << "The source directory\n" + << " " << this->Makefile->GetStartDirectory() << "\n" + << "does not contain a CMakeLists.txt file."; + switch (mf->GetPolicyStatus(cmPolicies::CMP0014)) + { + case cmPolicies::WARN: + // Print the warning. + e << "\n" + << "CMake does not support this case but it used " + << "to work accidentally and is being allowed for " + << "compatibility." + << "\n" + << mf->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0014); + mf->IssueMessage(cmake::AUTHOR_WARNING, e.str()); + case cmPolicies::OLD: + // OLD behavior does not warn. + return; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + e << "\n" + << mf->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0014); + case cmPolicies::NEW: + // NEW behavior prints the error. + mf->IssueMessage(cmake::FATAL_ERROR, e.str()); + break; + } } void cmLocalGenerator::SetupPathConversions() |