diff options
-rw-r--r-- | Source/cmLocalGenerator.cxx | 42 | ||||
-rw-r--r-- | Source/cmPolicies.cxx | 12 | ||||
-rw-r--r-- | Source/cmPolicies.h | 1 |
3 files changed, 54 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() diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index e8c7fcf..576ccd7 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -387,6 +387,18 @@ cmPolicies::cmPolicies() "The NEW behavior for this policy is to disallow duplicate binary " "directories with an error.", 2,6,5, cmPolicies::WARN); + + this->DefinePolicy( + CMP0014, "CMP0014", + "Input directories must have CMakeLists.txt.", + "CMake versions before 2.8 silently ignored missing CMakeLists.txt " + "files in directories referenced by add_subdirectory() or subdirs(), " + "treating them as if present but empty. " + "In CMake 2.8.0 and above this policy determines whether or not " + "the case is an error. " + "The OLD behavior for this policy is to silently ignore the problem. " + "The NEW behavior for this policy is to report an error.", + 2,7,20090902, cmPolicies::WARN); } cmPolicies::~cmPolicies() diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 391b91c..49dec3b 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -54,6 +54,7 @@ public: CMP0011, // Strong policy scope for include and find_package CMP0012, // Strong handling of boolean constants CMP0013, // Duplicate binary directories not allowed + CMP0014, // Input directories must have CMakeLists.txt // Always the last entry. Useful mostly to avoid adding a comma // the last policy when adding a new one. |