[Cmake-commits] [cmake-commits] king committed cmLocalGenerator.cxx 1.308 1.309 cmPolicies.cxx 1.41 1.42 cmPolicies.h 1.24 1.25

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Sep 3 08:27:15 EDT 2009


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv8418/Source

Modified Files:
	cmLocalGenerator.cxx cmPolicies.cxx cmPolicies.h 
Log Message:
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.


Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.308
retrieving revision 1.309
diff -C 2 -d -r1.308 -r1.309
*** cmLocalGenerator.cxx	3 Sep 2009 12:26:59 -0000	1.308
--- cmLocalGenerator.cxx	3 Sep 2009 12:27:12 -0000	1.309
***************
*** 168,174 ****
  void cmLocalGenerator::ReadInputFile()
  {
    std::string currentStart = this->Makefile->GetStartDirectory();
    currentStart += "/CMakeLists.txt";
!   this->Makefile->ReadListFile(currentStart.c_str());
  }
  
--- 168,214 ----
  void cmLocalGenerator::ReadInputFile()
  {
+   // Look for the CMakeLists.txt file.
    std::string currentStart = this->Makefile->GetStartDirectory();
    currentStart += "/CMakeLists.txt";
!   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;
!     }
  }
  

Index: cmPolicies.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -C 2 -d -r1.24 -r1.25
*** cmPolicies.h	17 Jun 2009 17:40:09 -0000	1.24
--- cmPolicies.h	3 Sep 2009 12:27:12 -0000	1.25
***************
*** 55,58 ****
--- 55,59 ----
      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

Index: cmPolicies.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.cxx,v
retrieving revision 1.41
retrieving revision 1.42
diff -C 2 -d -r1.41 -r1.42
*** cmPolicies.cxx	3 Sep 2009 12:26:18 -0000	1.41
--- cmPolicies.cxx	3 Sep 2009 12:27:12 -0000	1.42
***************
*** 388,391 ****
--- 388,403 ----
      "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);
  }
  



More information about the Cmake-commits mailing list