[Cmake-commits] [cmake-commits] king committed cmComputeLinkDepends.cxx 1.12 1.13 cmComputeLinkDepends.h 1.5 1.6 cmPolicies.cxx 1.21 1.22 cmPolicies.h 1.11 1.12 cmTarget.cxx 1.208 1.209 cmTarget.h 1.110 1.111
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Mar 13 16:35:41 EDT 2008
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv17902/Source
Modified Files:
cmComputeLinkDepends.cxx cmComputeLinkDepends.h cmPolicies.cxx
cmPolicies.h cmTarget.cxx cmTarget.h
Log Message:
ENH: Add policy CMP_0004 to require library names to have no leading or trailing whitespace. Replace previous check of CMAKE_BACKWARDS_COMPATIBILITY against version 2.4 with the policy.
Index: cmComputeLinkDepends.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -C 2 -d -r1.5 -r1.6
*** cmComputeLinkDepends.h 13 Feb 2008 20:29:55 -0000 1.5
--- cmComputeLinkDepends.h 13 Mar 2008 20:35:39 -0000 1.6
***************
*** 30,33 ****
--- 30,34 ----
class cmMakefile;
class cmTarget;
+ class cmake;
/** \class cmComputeLinkDepends
***************
*** 61,64 ****
--- 62,66 ----
cmLocalGenerator* LocalGenerator;
cmGlobalGenerator* GlobalGenerator;
+ cmake* CMakeInstance;
bool DebugMode;
Index: cmPolicies.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -C 2 -d -r1.11 -r1.12
*** cmPolicies.h 13 Mar 2008 20:23:18 -0000 1.11
--- cmPolicies.h 13 Mar 2008 20:35:39 -0000 1.12
***************
*** 45,48 ****
--- 45,49 ----
CMP0002, // Target names must be unique
CMP0003, // Linking does not include extra -L paths
+ CMP0004, // Libraries linked may not have leading or trailing whitespace
// 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.21
retrieving revision 1.22
diff -C 2 -d -r1.21 -r1.22
*** cmPolicies.cxx 13 Mar 2008 20:23:18 -0000 1.21
--- cmPolicies.cxx 13 Mar 2008 20:35:39 -0000 1.22
***************
*** 201,204 ****
--- 201,220 ----
"this policy so it has no effect.",
2,6,0, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0004, "CMP0004",
+ "Libraries linked may not have leading or trailing whitespace.",
+ "CMake versions 2.4 and below silently removed leading and trailing "
+ "whitespace from libraries linked with code like\n"
+ " target_link_libraries(myexe \" A \")\n"
+ "This could lead to subtle errors in user projects.\n"
+ "The OLD behavior for this policy is to silently remove leading and "
+ "trailing whitespace. "
+ "The NEW behavior for this policy is to diagnose the existence of "
+ "such whitespace as an error. "
+ "The setting for this policy used when checking the library names is "
+ "that in effect when the target is created by an add_executable or "
+ "add_library command.",
+ 2,6,0, cmPolicies::WARN);
}
Index: cmComputeLinkDepends.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -C 2 -d -r1.12 -r1.13
*** cmComputeLinkDepends.cxx 24 Feb 2008 19:05:11 -0000 1.12
--- cmComputeLinkDepends.cxx 13 Mar 2008 20:35:39 -0000 1.13
***************
*** 22,25 ****
--- 22,26 ----
#include "cmMakefile.h"
#include "cmTarget.h"
+ #include "cmake.h"
#include <cmsys/stl/algorithm>
***************
*** 162,165 ****
--- 163,167 ----
this->LocalGenerator = this->Makefile->GetLocalGenerator();
this->GlobalGenerator = this->LocalGenerator->GetGlobalGenerator();
+ this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
// The configuration being linked.
***************
*** 569,583 ****
lib = lib.substr(0, pos+1);
}
! if(lib != item && !this->Makefile->NeedBackwardsCompatibility(2,4))
{
! cmOStringStream e;
! e << "Target \"" << this->Target->GetName() << "\" links to item \""
! << item << "\" which has leading or trailing whitespace. "
! << "CMake is stripping off the whitespace but this may not be "
! << "supported in the future. "
! << "Update the CMakeLists.txt files to avoid adding the whitespace. "
! << "Set CMAKE_BACKWARDS_COMPATIBILITY to 2.4 or lower to disable this "
! << "warning.";
! cmSystemTools::Message(e.str().c_str());
}
return lib;
--- 571,613 ----
lib = lib.substr(0, pos+1);
}
! if(lib != item)
{
! switch(this->Target->GetPolicyStatusCMP0004())
! {
! case cmPolicies::WARN:
! {
! cmOStringStream w;
! w << (this->Makefile->GetPolicies()
! ->GetPolicyWarning(cmPolicies::CMP0004)) << "\n"
! << "Target \"" << this->Target->GetName() << "\" links to item \""
! << item << "\" which has leading or trailing whitespace.";
! this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
! this->Target->GetBacktrace());
! }
! case cmPolicies::OLD:
! break;
! case cmPolicies::NEW:
! {
! cmOStringStream e;
! e << "Target \"" << this->Target->GetName() << "\" links to item \""
! << item << "\" which has leading or trailing whitespace. "
! << "This is now an error according to policy CMP0004.";
! this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
! this->Target->GetBacktrace());
! }
! break;
! case cmPolicies::REQUIRED_IF_USED:
! case cmPolicies::REQUIRED_ALWAYS:
! {
! cmOStringStream e;
! e << (this->Makefile->GetPolicies()
! ->GetRequiredPolicyError(cmPolicies::CMP0004)) << "\n"
! << "Target \"" << this->Target->GetName() << "\" links to item \""
! << item << "\" which has leading or trailing whitespace.";
! this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
! this->Target->GetBacktrace());
! }
! break;
! }
}
return lib;
Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.110
retrieving revision 1.111
diff -C 2 -d -r1.110 -r1.111
*** cmTarget.h 13 Mar 2008 20:23:18 -0000 1.110
--- cmTarget.h 13 Mar 2008 20:35:39 -0000 1.111
***************
*** 111,114 ****
--- 111,118 ----
{ return this->PolicyStatusCMP0003; }
+ /** Get the status of policy CMP0004 when the target was created. */
+ cmPolicies::PolicyStatus GetPolicyStatusCMP0004() const
+ { return this->PolicyStatusCMP0004; }
+
/**
* Get the list of the custom commands for this target
***************
*** 538,541 ****
--- 542,546 ----
// Policy status recorded when target was created.
cmPolicies::PolicyStatus PolicyStatusCMP0003;
+ cmPolicies::PolicyStatus PolicyStatusCMP0004;
// Internal representation details.
Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.208
retrieving revision 1.209
diff -C 2 -d -r1.208 -r1.209
*** cmTarget.cxx 13 Mar 2008 20:23:18 -0000 1.208
--- cmTarget.cxx 13 Mar 2008 20:35:39 -0000 1.209
***************
*** 55,58 ****
--- 55,59 ----
this->Makefile = 0;
this->PolicyStatusCMP0003 = cmPolicies::WARN;
+ this->PolicyStatusCMP0004 = cmPolicies::WARN;
this->LinkLibrariesAnalyzed = false;
this->HaveInstallRule = false;
***************
*** 732,735 ****
--- 733,738 ----
this->PolicyStatusCMP0003 =
this->Makefile->GetPolicyStatus(cmPolicies::CMP0003);
+ this->PolicyStatusCMP0004 =
+ this->Makefile->GetPolicyStatus(cmPolicies::CMP0004);
}
More information about the Cmake-commits
mailing list