[Cmake-commits] [cmake-commits] king committed cmMakefile.cxx 1.508 1.509 cmMakefile.h 1.254 1.255 cmPolicies.cxx 1.38 1.39 cmPolicies.h 1.23 1.24
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Jun 17 13:40:13 EDT 2009
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv30666/Source
Modified Files:
cmMakefile.cxx cmMakefile.h cmPolicies.cxx cmPolicies.h
Log Message:
ENH: Create CMP0013 to disallow duplicate dirs
In CMake 2.6.3 and below we silently accepted duplicate build
directories whose build files would then conflict. At first this was
considured purely a bug that confused beginners but would not be used in
a real project. In CMake 2.6.4 we explicitly made it an error.
However, some real projects took advantage of this as a "feature" and
got lucky that the subtle build errors it can cause did not occur.
Therefore we need a policy to deal with the case more gracefully.
See issue #9173.
Index: cmPolicies.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -C 2 -d -r1.23 -r1.24
*** cmPolicies.h 12 Jun 2009 14:07:05 -0000 1.23
--- cmPolicies.h 17 Jun 2009 17:40:09 -0000 1.24
***************
*** 54,57 ****
--- 54,58 ----
CMP0011, // Strong policy scope for include and find_package
CMP0012, // Strong handling of boolean constants
+ CMP0013, // Duplicate binary directories not allowed
// 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.38
retrieving revision 1.39
diff -C 2 -d -r1.38 -r1.39
*** cmPolicies.cxx 15 Jun 2009 16:33:21 -0000 1.38
--- cmPolicies.cxx 17 Jun 2009 17:40:09 -0000 1.39
***************
*** 370,373 ****
--- 370,390 ----
"boolean constant.",
2,6,5, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0013, "CMP0013",
+ "Duplicate binary directories are not allowed.",
+ "CMake 2.6.3 and below silently permitted add_subdirectory() calls "
+ "to create the same binary directory multiple times. "
+ "During build system generation files would be written and then "
+ "overwritten in the build tree and could lead to strange behavior. "
+ "CMake 2.6.4 and above explicitly detect duplicate binary directories. "
+ "CMake 2.6.4 always considers this case an error. "
+ "In CMake 2.6.5 and above this policy determines whether or not "
+ "the case is an error. "
+ "The OLD behavior for this policy is to allow duplicate binary "
+ "directories. "
+ "The NEW behavior for this policy is to disallow duplicate binary "
+ "directories with an error.",
+ 2,6,5, cmPolicies::WARN);
}
Index: cmMakefile.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.h,v
retrieving revision 1.254
retrieving revision 1.255
diff -C 2 -d -r1.254 -r1.255
*** cmMakefile.h 16 Mar 2009 14:40:31 -0000 1.254
--- cmMakefile.h 17 Jun 2009 17:40:08 -0000 1.255
***************
*** 901,904 ****
--- 901,906 ----
bool ParseDefineFlag(std::string const& definition, bool remove);
+ bool EnforceUniqueDir(const char* srcPath, const char* binPath);
+
void ReadSources(std::ifstream& fin, bool t);
friend class cmMakeDepend; // make depend needs direct access
Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.508
retrieving revision 1.509
diff -C 2 -d -r1.508 -r1.509
*** cmMakefile.cxx 24 Apr 2009 15:18:05 -0000 1.508
--- cmMakefile.cxx 17 Jun 2009 17:40:08 -0000 1.509
***************
*** 1546,1560 ****
// Make sure the binary directory is unique.
! cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator();
! if(!gg->BinaryDirectoryIsNew(binPath))
{
- cmOStringStream e;
- e << "The binary directory\n"
- << " " << binPath << "\n"
- << "is already used to build another source directory, so it cannot "
- << "be used to build source directory\n"
- << " " << srcPath << "\n"
- << "Specify a unique binary directory name.";
- this->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
--- 1546,1551 ----
// Make sure the binary directory is unique.
! if(!this->EnforceUniqueDir(srcPath, binPath))
{
return;
}
***************
*** 3721,3724 ****
--- 3712,3763 ----
//----------------------------------------------------------------------------
+ bool cmMakefile::EnforceUniqueDir(const char* srcPath, const char* binPath)
+ {
+ // Make sure the binary directory is unique.
+ cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator();
+ if(gg->BinaryDirectoryIsNew(binPath))
+ {
+ return true;
+ }
+ cmOStringStream e;
+ switch (this->GetPolicyStatus(cmPolicies::CMP0013))
+ {
+ case cmPolicies::WARN:
+ // Print the warning.
+ e << this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0013)
+ << "\n"
+ << "The binary directory\n"
+ << " " << binPath << "\n"
+ << "is already used to build a source directory. "
+ << "This command uses it to build source directory\n"
+ << " " << srcPath << "\n"
+ << "which can generate conflicting build files. "
+ << "CMake does not support this use case but it used "
+ << "to work accidentally and is being allowed for "
+ << "compatibility.";
+ this->IssueMessage(cmake::AUTHOR_WARNING, e.str());
+ case cmPolicies::OLD:
+ // OLD behavior does not warn.
+ return true;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ e << this->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0013)
+ << "\n";
+ case cmPolicies::NEW:
+ // NEW behavior prints the error.
+ e << "The binary directory\n"
+ << " " << binPath << "\n"
+ << "is already used to build a source directory. "
+ << "It cannot be used to build source directory\n"
+ << " " << srcPath << "\n"
+ << "Specify a unique binary directory name.";
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ break;
+ }
+
+ return false;
+ }
+
+ //----------------------------------------------------------------------------
cmPolicies::PolicyStatus
cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id)
More information about the Cmake-commits
mailing list