summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-09-03 12:27:12 (GMT)
committerBrad King <brad.king@kitware.com>2009-09-03 12:27:12 (GMT)
commite3086213820a97db8432bf6089155509164fe960 (patch)
tree56bdbb70fa02ea4b64036af39bec6bd44d1a664c /Source/cmLocalGenerator.cxx
parent3fda5c6463f3d0d263b8e58503fa622a46932d8c (diff)
downloadCMake-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.cxx42
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()