[Cmake-commits] [cmake-commits] hoffman committed cmCMakeMinimumRequired.h 1.12 1.12.2.1 cmCMakePolicyCommand.h 1.4 1.4.2.1 cmComputeLinkDepends.cxx 1.12 1.12.2.1 cmComputeLinkDepends.h 1.5 1.5.2.1 cmComputeLinkInformation.cxx 1.24 1.24.2.1 cmComputeLinkInformation.h 1.15 1.15.2.1 cmDocumentVariables.cxx 1.18 1.18.2.1 cmExportFileGenerator.cxx 1.11 1.11.2.1 cmListCommand.cxx 1.18 1.18.2.1 cmLocalUnixMakefileGenerator3.cxx 1.240 1.240.2.1 cmMakefile.cxx 1.463 1.463.2.1 cmPolicies.cxx 1.20 1.20.2.1 cmPolicies.h 1.10 1.10.2.1 cmSourceFileLocation.cxx 1.3 1.3.2.1 cmTarget.cxx 1.207 1.207.2.1 cmTarget.h 1.109 1.109.2.1

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Mar 18 10:23:57 EDT 2008


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

Modified Files:
      Tag: CMake-2-6
	cmCMakeMinimumRequired.h cmCMakePolicyCommand.h 
	cmComputeLinkDepends.cxx cmComputeLinkDepends.h 
	cmComputeLinkInformation.cxx cmComputeLinkInformation.h 
	cmDocumentVariables.cxx cmExportFileGenerator.cxx 
	cmListCommand.cxx cmLocalUnixMakefileGenerator3.cxx 
	cmMakefile.cxx cmPolicies.cxx cmPolicies.h 
	cmSourceFileLocation.cxx cmTarget.cxx cmTarget.h 
Log Message:
ENH: move head to branch


Index: cmComputeLinkDepends.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.h,v
retrieving revision 1.5
retrieving revision 1.5.2.1
diff -C 2 -d -r1.5 -r1.5.2.1
*** cmComputeLinkDepends.h	13 Feb 2008 20:29:55 -0000	1.5
--- cmComputeLinkDepends.h	18 Mar 2008 14:23:54 -0000	1.5.2.1
***************
*** 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: cmSourceFileLocation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSourceFileLocation.cxx,v
retrieving revision 1.3
retrieving revision 1.3.2.1
diff -C 2 -d -r1.3 -r1.3.2.1
*** cmSourceFileLocation.cxx	13 Mar 2008 01:06:32 -0000	1.3
--- cmSourceFileLocation.cxx	18 Mar 2008 14:23:54 -0000	1.3.2.1
***************
*** 174,183 ****
      // This can occur when referencing a source file from a different
      // directory.  This is not yet allowed.
!     this->Makefile->
!       IssueMessage(cmake::INTERNAL_ERROR,
!                    "Matches error: Each side has a directory relative to a different"
!                    " location. This can occur when referencing a "
!                    "source file from a different directory.  "
!                    "This is not yet allowed.");
      return false;
      }
--- 174,183 ----
      // This can occur when referencing a source file from a different
      // directory.  This is not yet allowed.
!     this->Makefile->IssueMessage(
!       cmake::INTERNAL_ERROR,
!       "Matches error: Each side has a directory relative to a different "
!       "location. This can occur when referencing a source file from a "
!       "different directory.  This is not yet allowed."
!       );
      return false;
      }

Index: cmPolicies.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmPolicies.h,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -C 2 -d -r1.10 -r1.10.2.1
*** cmPolicies.h	13 Mar 2008 15:38:46 -0000	1.10
--- cmPolicies.h	18 Mar 2008 14:23:54 -0000	1.10.2.1
***************
*** 44,47 ****
--- 44,50 ----
      CMP0001, // Ignore old compatibility variable
      CMP0002, // Target names must be unique
+     CMP0003, // Linking does not include extra -L paths
+     CMP0004, // Libraries linked may not have leading or trailing whitespace
+     CMP0005, // Definition value escaping
  
      // 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.20
retrieving revision 1.20.2.1
diff -C 2 -d -r1.20 -r1.20.2.1
*** cmPolicies.cxx	13 Mar 2008 19:01:58 -0000	1.20
--- cmPolicies.cxx	18 Mar 2008 14:23:54 -0000	1.20.2.1
***************
*** 91,103 ****
      "CMake requires that projects specify the version of CMake to which "
      "they have been written.  "
!     "This policy has been put in place to help CMake maintain backwards "
!     "compatibility with existing projects while allowing it to evolve "
!     "more rapidly.\n"
      "The easiest way to specify a policy version number is to "
!     "call the cmake_policy command at the top of your CMakeLists file:\n"
      "  cmake_policy(VERSION <major>.<minor>)\n"
!     "where <major>.<minor> is the version of CMake you want to support.  "
!     "The cmake_minimum_required command may also be used; see its "
!     "documentation for details.",
      2,6,0, cmPolicies::WARN
      );
--- 91,110 ----
      "CMake requires that projects specify the version of CMake to which "
      "they have been written.  "
!     "This policy has been put in place to help existing projects build with "
!     "new CMake versions as it evolves.  "
      "The easiest way to specify a policy version number is to "
!     "call the cmake_minimum_required command at the top of "
!     "your CMakeLists.txt file:\n"
!     "  cmake_minimum_required(VERSION <major>.<minor>)\n"
!     "where \"<major>.<minor>\" is the version of CMake you want to support "
!     "(such as \"2.6\").  "
!     "The command will ensure that at least the given version of CMake is "
!     "running and set the policy version.  "
!     "See documentation of cmake_minimum_required for details.  "
!     "The cmake_policy command may be used at any time to set the "
!     "policy version:\n"
      "  cmake_policy(VERSION <major>.<minor>)\n"
!     "This is the recommended way to set the policy version except at "
!     "the very top of a project.",
      2,6,0, cmPolicies::WARN
      );
***************
*** 140,143 ****
--- 147,248 ----
      2,6,0, cmPolicies::WARN
      );
+ 
+   this->DefinePolicy(
+     CMP0003, "CMP0003",
+     "Libraries linked via full path no longer produce linker search paths.",
+     "This policy affects how libraries whose full paths are NOT known "
+     "are found at link time, but was created due to a change in how CMake "
+     "deals with libraries whose full paths are known.  "
+     "Consider the code\n"
+     "  target_link_libraries(myexe /path/to/libA.so)\n"
+     "CMake 2.4 and below implemented linking to libraries whose full paths "
+     "are known by splitting them on the link line into separate components "
+     "consisting of the linker search path and the library name.  "
+     "The example code might have produced something like\n"
+     "  ... -L/path/to -lA ...\n"
+     "in order to link to library A.  "
+     "An analysis was performed to order multiple link directories such that "
+     "the linker would find library A in the desired location, but there "
+     "are cases in which this does not work.  "
+     "CMake versions 2.6 and above use the more reliable approach of passing "
+     "the full path to libraries directly to the linker in most cases.  "
+     "The example code now produces something like\n"
+     "  ... /path/to/libA.so ....\n"
+     "Unfortunately this change can break code like\n"
+     "  target_link_libraries(myexe /path/to/libA.so B)\n"
+     "where \"B\" is meant to find \"/path/to/libB.so\".  "
+     "This code is wrong because the user is asking the linker to find "
+     "library B but has not provided a linker search path (which may be "
+     "added with the link_directories command).  "
+     "However, with the old linking implementation the code would work "
+     "accidentally because the linker search path added for library A "
+     "allowed library B to be found."
+     "\n"
+     "In order to support projects depending on linker search paths "
+     "added by linking to libraries with known full paths, the OLD "
+     "behavior for this policy will add the linker search paths even "
+     "though they are not needed for their own libraries.  "
+     "When this policy is set to OLD, CMake will produce a link line such as\n"
+     "  ... -L/path/to /path/to/libA.so -lB ...\n"
+     "which will allow library B to be found as it was previously.  "
+     "When this policy is set to NEW, CMake will produce a link line such as\n"
+     "  ... /path/to/libA.so -lB ...\n"
+     "which more accurately matches what the project specified."
+     "\n"
+     "The setting for this policy used when generating the link line is that "
+     "in effect when the target is created by an add_executable or "
+     "add_library command.  For the example described above, the code\n"
+     "  cmake_policy(SET CMP0003 OLD) # or cmake_policy(VERSION 2.4)\n"
+     "  add_executable(myexe myexe.c)\n"
+     "  target_link_libraries(myexe /path/to/libA.so B)\n"
+     "will work and suppress the warning for this policy.  "
+     "It may also be updated to work with the corrected linking approach:\n"
+     "  cmake_policy(SET CMP0003 NEW) # or cmake_policy(VERSION 2.6)\n"
+     "  link_directories(/path/to) # needed to find library B\n"
+     "  add_executable(myexe myexe.c)\n"
+     "  target_link_libraries(myexe /path/to/libA.so B)\n"
+     "Even better, library B may be specified with a full path:\n"
+     "  add_executable(myexe myexe.c)\n"
+     "  target_link_libraries(myexe /path/to/libA.so /path/to/libB.so)\n"
+     "When all items on the link line have known paths CMake does not check "
+     "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);
+ 
+   this->DefinePolicy(
+     CMP0005, "CMP0005",
+     "Preprocessor definition values are now escaped automatically.",
+     "This policy determines whether or not CMake should generate escaped "
+     "preprocessor definition values added via add_definitions.  "
+     "CMake versions 2.4 and below assumed that only trivial values would "
+     "be given for macros in add_definitions calls.  "
+     "It did not attempt to escape non-trivial values such as string "
+     "literals in generated build rules.  "
+     "CMake versions 2.6 and above support escaping of most values, but "
+     "cannot assume the user has not added escapes already in an attempt to "
+     "work around limitations in earlier versions.\n"
+     "The OLD behavior for this policy is to place definition values given "
+     "to add_definitions directly in the generated build rules without "
+     "attempting to escape anything.  "
+     "The NEW behavior for this policy is to generate correct escapes "
+     "for all native build tools automatically.  "
+     "See documentation of the COMPILE_DEFINITIONS target property for "
+     "limitations of the escaping implementation.",
+     2,6,0, cmPolicies::WARN);
  }
  

Index: cmExportFileGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportFileGenerator.cxx,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -C 2 -d -r1.11 -r1.11.2.1
*** cmExportFileGenerator.cxx	24 Feb 2008 19:05:11 -0000	1.11
--- cmExportFileGenerator.cxx	18 Mar 2008 14:23:54 -0000	1.11.2.1
***************
*** 21,24 ****
--- 21,25 ----
  #include "cmSystemTools.h"
  #include "cmTarget.h"
+ #include "cmVersion.h"
  
  #include <cmsys/auto_ptr.hxx>
***************
*** 80,83 ****
--- 81,89 ----
  
    // Start with the import file header.
+   os << "CMAKE_POLICY(PUSH)\n"
+      << "CMAKE_POLICY(VERSION "
+      << cmVersion::GetMajorVersion() << "."
+      << cmVersion::GetMinorVersion() << "."
+      << cmVersion::GetPatchVersion() << ")\n";
    this->GenerateImportHeaderCode(os);
  
***************
*** 87,90 ****
--- 93,97 ----
    // End with the import file footer.
    this->GenerateImportFooterCode(os);
+   os << "CMAKE_POLICY(POP)\n";
  
    return result;

Index: cmComputeLinkInformation.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.h,v
retrieving revision 1.15
retrieving revision 1.15.2.1
diff -C 2 -d -r1.15 -r1.15.2.1
*** cmComputeLinkInformation.h	1 Mar 2008 17:51:07 -0000	1.15
--- cmComputeLinkInformation.h	18 Mar 2008 14:23:54 -0000	1.15.2.1
***************
*** 154,164 ****
    // Linker search path computation.
    cmOrderDirectories* OrderLinkerSearchPath;
!   void FinishLinkerSearchDirectories();
    std::set<cmStdString> ImplicitLinkDirs;
  
    // Linker search path compatibility mode.
    std::vector<std::string> OldLinkDirItems;
    bool OldLinkDirMode;
-   bool HaveUserFlagItem;
  
    // Runtime path computation.
--- 154,166 ----
    // Linker search path computation.
    cmOrderDirectories* OrderLinkerSearchPath;
!   bool FinishLinkerSearchDirectories();
!   void PrintLinkPolicyDiagnosis(std::ostream&);
    std::set<cmStdString> ImplicitLinkDirs;
  
    // Linker search path compatibility mode.
+   std::set<cmStdString> OldLinkDirMask;
    std::vector<std::string> OldLinkDirItems;
+   std::vector<std::string> OldUserFlagItems;
    bool OldLinkDirMode;
  
    // Runtime path computation.

Index: cmComputeLinkInformation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.cxx,v
retrieving revision 1.24
retrieving revision 1.24.2.1
diff -C 2 -d -r1.24 -r1.24.2.1
*** cmComputeLinkInformation.cxx	2 Mar 2008 19:35:23 -0000	1.24
--- cmComputeLinkInformation.cxx	18 Mar 2008 14:23:54 -0000	1.24.2.1
***************
*** 397,403 ****
      }
  
-   // Initial state.
-   this->HaveUserFlagItem = false;
- 
    // Decide whether to enable compatible library search path mode.
    // There exists code that effectively does
--- 397,400 ----
***************
*** 411,420 ****
    // order to support such projects we need to add the directories
    // containing libraries linked with a full path to the -L path.
!   this->OldLinkDirMode = false;
!   if(this->Makefile->IsOn("CMAKE_LINK_OLD_PATHS") ||
!      this->Makefile->GetLocalGenerator()
!      ->NeedBackwardsCompatibility(2, 4))
      {
!     this->OldLinkDirMode = true;
      }
  }
--- 408,423 ----
    // order to support such projects we need to add the directories
    // containing libraries linked with a full path to the -L path.
!   this->OldLinkDirMode =
!     this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW;
!   if(this->OldLinkDirMode)
      {
!     // Construct a mask to not bother with this behavior for link
!     // directories already specified by the user.
!     std::vector<std::string> const& dirs = this->Target->GetLinkDirectories();
!     for(std::vector<std::string>::const_iterator di = dirs.begin();
!         di != dirs.end(); ++di)
!       {
!       this->OldLinkDirMask.insert(*di);
!       }
      }
  }
***************
*** 538,542 ****
  
    // Finish setting up linker search directories.
!   this->FinishLinkerSearchDirectories();
  
    return true;
--- 541,548 ----
  
    // Finish setting up linker search directories.
!   if(!this->FinishLinkerSearchDirectories())
!     {
!     return false;
!     }
  
    return true;
***************
*** 996,999 ****
--- 1002,1014 ----
      }
  
+   // For compatibility with CMake 2.4 include the item's directory in
+   // the linker search path.
+   if(this->OldLinkDirMode &&
+      this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
+      this->OldLinkDirMask.end())
+     {
+     this->OldLinkDirItems.push_back(item);
+     }
+ 
    // Now add the full path to the library.
    this->Items.push_back(Item(item, true));
***************
*** 1038,1042 ****
    // For compatibility with CMake 2.4 include the item's directory in
    // the linker search path.
!   if(this->OldLinkDirMode)
      {
      this->OldLinkDirItems.push_back(item);
--- 1053,1059 ----
    // For compatibility with CMake 2.4 include the item's directory in
    // the linker search path.
!   if(this->OldLinkDirMode &&
!      this->OldLinkDirMask.find(cmSystemTools::GetFilenamePath(item)) ==
!      this->OldLinkDirMask.end())
      {
      this->OldLinkDirItems.push_back(item);
***************
*** 1162,1166 ****
      {
      // This is a linker option provided by the user.
!     this->HaveUserFlagItem = true;
  
      // Restore the target link type since this item does not specify
--- 1179,1183 ----
      {
      // This is a linker option provided by the user.
!     this->OldUserFlagItems.push_back(item);
  
      // Restore the target link type since this item does not specify
***************
*** 1175,1179 ****
      {
      // This is a name specified by the user.
!     this->HaveUserFlagItem = true;
  
      // We must ask the linker to search for a library with this name.
--- 1192,1196 ----
      {
      // This is a name specified by the user.
!     this->OldUserFlagItems.push_back(item);
  
      // We must ask the linker to search for a library with this name.
***************
*** 1305,1320 ****
  
  //----------------------------------------------------------------------------
! void cmComputeLinkInformation::FinishLinkerSearchDirectories()
  {
    // Support broken projects if necessary.
!   if(this->HaveUserFlagItem && this->OldLinkDirMode)
      {
!     for(std::vector<std::string>::const_iterator
!           i = this->OldLinkDirItems.begin();
!         i != this->OldLinkDirItems.end(); ++i)
        {
!       this->OrderLinkerSearchPath->AddLinkLibrary(*i);
        }
      }
  }
  
--- 1322,1437 ----
  
  //----------------------------------------------------------------------------
! bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
  {
    // Support broken projects if necessary.
!   if(this->OldLinkDirItems.empty() || this->OldUserFlagItems.empty() ||
!      !this->OldLinkDirMode)
      {
!     return true;
!     }
! 
!   // Enforce policy constraints.
!   switch(this->Target->GetPolicyStatusCMP0003())
!     {
!     case cmPolicies::WARN:
        {
!       cmOStringStream w;
!       w << (this->Makefile->GetPolicies()
!             ->GetPolicyWarning(cmPolicies::CMP0003)) << "\n";
!       this->PrintLinkPolicyDiagnosis(w);
!       this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
!                                         this->Target->GetBacktrace());
        }
+     case cmPolicies::OLD:
+       // OLD behavior is to add the paths containing libraries with
+       // known full paths as link directories.
+       break;
+     case cmPolicies::NEW:
+       // Should never happen due to assignment of OldLinkDirMode
+       return true;
+     case cmPolicies::REQUIRED_IF_USED:
+     case cmPolicies::REQUIRED_ALWAYS:
+       {
+       cmOStringStream e;
+       e << (this->Makefile->GetPolicies()->
+             GetRequiredPolicyError(cmPolicies::CMP0003)) << "\n";
+       this->PrintLinkPolicyDiagnosis(e);
+       this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(),
+                                         this->Target->GetBacktrace());
+       return false;
+       }
+     }
+ 
+   // Add the link directories for full path items.
+   for(std::vector<std::string>::const_iterator
+         i = this->OldLinkDirItems.begin();
+       i != this->OldLinkDirItems.end(); ++i)
+     {
+     this->OrderLinkerSearchPath->AddLinkLibrary(*i);
+     }
+   return true;
+ }
+ 
+ //----------------------------------------------------------------------------
+ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
+ {
+   // Name the target.
+   os << "Target \"" << this->Target->GetName() << "\" ";
+ 
+   // List the items that would add paths in old behavior.
+   std::set<cmStdString> emitted;
+   os << " links to some items by full path not located in any linker search "
+      << "directory added by a link_directories command:\n";
+   for(std::vector<std::string>::const_iterator
+         i = this->OldLinkDirItems.begin();
+       i != this->OldLinkDirItems.end(); ++i)
+     {
+     if(emitted.insert(cmSystemTools::GetFilenamePath(*i)).second)
+       {
+       os << "  " << *i << "\n";
+       }
+     }
+ 
+   // List the items that might need the old-style paths.
+   os << "This is okay but it also links to some items with no path known:\n";
+   {
+   // Format the list of unknown items to be as short as possible while
+   // still fitting in the allowed width (a true solution would be the
+   // bin packing problem if we were allowed to change the order).
+   std::string::size_type max_size = 76;
+   std::string line;
+   const char* sep = "  ";
+   for(std::vector<std::string>::const_iterator
+         i = this->OldUserFlagItems.begin();
+       i != this->OldUserFlagItems.end(); ++i)
+     {
+     // If the addition of another item will exceed the limit then
+     // output the current line and reset it.  Note that the separator
+     // is either " " or ", " which is always 2 characters.
+     if(!line.empty() && (line.size() + i->size() + 2) > max_size)
+       {
+       os << line << "\n";
+       sep = "  ";
+       line = "";
+       }
+     line += sep;
+     line += *i;
+ 
+     // Convert to the other separator.
+     sep = ", ";
+     }
+   if(!line.empty())
+     {
+     os << line << "\n";
      }
+   }
+ 
+   // Tell the user what is wrong.
+   os << "The linker will search for libraries in the second list.  "
+      << "Finding them may depend on linker search paths earlier CMake "
+      << "versions added as an implementation detail for linking to the "
+      << "libraries in the first list.  "
+      << "For compatibility CMake is including the extra linker search "
+      << "paths, but policy CMP0003 should be set by the project.";
  }
  

Index: cmListCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmListCommand.cxx,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -C 2 -d -r1.18 -r1.18.2.1
*** cmListCommand.cxx	12 Mar 2008 21:02:10 -0000	1.18
--- cmListCommand.cxx	18 Mar 2008 14:23:54 -0000	1.18.2.1
***************
*** 403,407 ****
    if(args.size() < 2)
      {
!     this->SetError("sub-command REMOVE_DUPLICATES requires a list as an argument.");
      return false;
      }
--- 403,408 ----
    if(args.size() < 2)
      {
!     this->SetError(
!       "sub-command REMOVE_DUPLICATES requires a list as an argument.");
      return false;
      }
***************
*** 412,416 ****
    if ( !this->GetList(varArgsExpanded, listName.c_str()) )
      {
!     this->SetError("sub-command REMOVE_DUPLICATES requires list to be present.");
      return false;
      }
--- 413,418 ----
    if ( !this->GetList(varArgsExpanded, listName.c_str()) )
      {
!     this->SetError(
!       "sub-command REMOVE_DUPLICATES requires list to be present.");
      return false;
      }

Index: cmComputeLinkDepends.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.cxx,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -C 2 -d -r1.12 -r1.12.2.1
*** cmComputeLinkDepends.cxx	24 Feb 2008 19:05:11 -0000	1.12
--- cmComputeLinkDepends.cxx	18 Mar 2008 14:23:54 -0000	1.12.2.1
***************
*** 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: cmDocumentVariables.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmDocumentVariables.cxx,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -C 2 -d -r1.18 -r1.18.2.1
*** cmDocumentVariables.cxx	4 Mar 2008 14:40:38 -0000	1.18
--- cmDocumentVariables.cxx	18 Mar 2008 14:23:54 -0000	1.18.2.1
***************
*** 785,806 ****
       "Variables that Control the Build");
    cm->DefineProperty
-     ("CMAKE_LINK_OLD_PATHS", cmProperty::VARIABLE,
-      "Enable linker search path compatibility mode.",
-      "This option enables linking compatibility mode for broken projects.  "
-      "There exists code that effectively does\n"
-      "  target_link_libraries(myexe /path/to/libA.so -lB)\n"
-      "where -lB is meant to link to /path/to/libB.so.  This is broken "
-      "because it specifies -lB without adding \"/path/to\" to the linker "
-      "search path with the link_directories command.  With CMake 2.4 and "
-      "below the code worked accidentally because \"/path/to\" would be "
-      "added to the linker search path by its implementation of linking to "
-      "/path/to/libA.so (which passed -L/path/to -lA to the linker).  "
-      "This option tells CMake to add the directories containing libraries "
-      "specified with a full path to the linker search path if the link "
-      "line contains any items like -lB.  "
-      "The behavior is also enabled if CMAKE_BACKWARDS_COMPATIBILITY is "
-      "set to 2.4 or lower.", false,
-      "Variables that Control the Build");
-   cm->DefineProperty
      ("CMAKE_USE_RELATIVE_PATHS", cmProperty::VARIABLE,
       "Use relative paths (May not work!).",
--- 785,788 ----

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.109
retrieving revision 1.109.2.1
diff -C 2 -d -r1.109 -r1.109.2.1
*** cmTarget.h	13 Mar 2008 17:48:57 -0000	1.109
--- cmTarget.h	18 Mar 2008 14:23:54 -0000	1.109.2.1
***************
*** 20,23 ****
--- 20,24 ----
  #include "cmCustomCommand.h"
  #include "cmPropertyMap.h"
+ #include "cmPolicies.h"
  
  class cmake;
***************
*** 106,109 ****
--- 107,118 ----
    cmMakefile *GetMakefile() const { return this->Makefile;};
  
+   /** Get the status of policy CMP0003 when the target was created.  */
+   cmPolicies::PolicyStatus GetPolicyStatusCMP0003() const
+     { 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
***************
*** 531,534 ****
--- 540,547 ----
    cmMakefile* Makefile;
  
+   // Policy status recorded when target was created.
+   cmPolicies::PolicyStatus PolicyStatusCMP0003;
+   cmPolicies::PolicyStatus PolicyStatusCMP0004;
+ 
    // Internal representation details.
    friend class cmTargetInternals;

Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.240
retrieving revision 1.240.2.1
diff -C 2 -d -r1.240 -r1.240.2.1
*** cmLocalUnixMakefileGenerator3.cxx	13 Mar 2008 01:06:32 -0000	1.240
--- cmLocalUnixMakefileGenerator3.cxx	18 Mar 2008 14:23:54 -0000	1.240.2.1
***************
*** 739,742 ****
--- 739,754 ----
      ".SUFFIXES", no_depends, no_commands, false);
  
+   // turn off RCS and SCCS automatic stuff from gmake
+   makefileStream << "# Remove some rules from gmake that .SUFFIXES does not remove.\n"
+                  << "# This makes gmake faster as it does not try to run implicit rules\n"
+                  << "# on targets that never exist.\n"
+                  << "%: %,v\n"
+                  << "%: RCS/%,v\n"
+                  << "%: RCS/%\n"
+                  << "%: s.%\n"
+                  << "%: %.w\n"
+                  << "%.c: %.w %.ch\n"
+                  << "%: %.tex\n"
+                  << "%: SCCS/s.%\n\n";
    // Add a fake suffix to keep HP happy.  Must be max 32 chars for SGI make.
    std::vector<std::string> depends;

Index: cmCMakePolicyCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCMakePolicyCommand.h,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C 2 -d -r1.4 -r1.4.2.1
*** cmCMakePolicyCommand.h	13 Mar 2008 15:38:46 -0000	1.4
--- cmCMakePolicyCommand.h	18 Mar 2008 14:23:54 -0000	1.4.2.1
***************
*** 59,63 ****
    virtual const char* GetTerseDocumentation() 
      {
!     return "Manage CMake policy settings.";
      }
    
--- 59,63 ----
    virtual const char* GetTerseDocumentation() 
      {
!     return "Manage CMake Policy settings.";
      }
    
***************
*** 68,78 ****
      {
      return
        "  cmake_policy(VERSION major.minor[.patch])\n"
        "Specify that the current CMake list file is written for the "
        "given version of CMake.  "
        "All policies introduced in the specified version or earlier "
!       "will be set NEW.  "
!       "All policies introduced after the specified version will be set "
!       "to WARN, which is like OLD but also produces a warning.  "
        "This effectively requests behavior preferred as of a given CMake "
        "version and tells newer CMake versions to warn about their new "
--- 68,96 ----
      {
      return
+       "As CMake evolves it is sometimes necessary to change existing "
+       "behavior in order to fix bugs or improve implementations of "
+       "existing features.  "
+       "The CMake Policy mechanism is designed to help keep existing projects "
+       "building as new versions of CMake introduce changes in behavior.  "
+       "Each new policy (behavioral change) is given an identifier of "
+       "the form \"CMP<NNNN>\" where \"<NNNN>\" is an integer index.  "
+       "Documentation associated with each policy describes the OLD and NEW "
+       "behavior and the reason the policy was introduced.  "
+       "Projects may set each policy to select the desired behavior.  "
+       "When CMake needs to know which behavior to use it checks for "
+       "a setting specified by the project.  "
+       "If no setting is available the OLD behavior is assumed and a warning "
+       "is produced requesting that the policy be set.\n"
+       "The cmake_policy command is used to set policies to OLD or NEW "
+       "behavior.  "
+       "While setting policies individually is supported, we encourage "
+       "projects to set policies based on CMake versions.\n"
        "  cmake_policy(VERSION major.minor[.patch])\n"
        "Specify that the current CMake list file is written for the "
        "given version of CMake.  "
        "All policies introduced in the specified version or earlier "
!       "will be set to use NEW behavior.  "
!       "All policies introduced after the specified version will be reset "
!       "to use OLD behavior with a warning.  "
        "This effectively requests behavior preferred as of a given CMake "
        "version and tells newer CMake versions to warn about their new "
***************
*** 83,88 ****
        "than 2.4 see documentation of policy CMP0001."
        "\n"
!       "  cmake_policy(SET <CMPNNNN> NEW)\n"
!       "  cmake_policy(SET <CMPNNNN> OLD)\n"
        "Tell CMake to use the OLD or NEW behavior for a given policy.  "
        "Projects depending on the old behavior of a given policy may "
--- 101,106 ----
        "than 2.4 see documentation of policy CMP0001."
        "\n"
!       "  cmake_policy(SET CMP<NNNN> NEW)\n"
!       "  cmake_policy(SET CMP<NNNN> OLD)\n"
        "Tell CMake to use the OLD or NEW behavior for a given policy.  "
        "Projects depending on the old behavior of a given policy may "
***************
*** 97,102 ****
        "This is useful when mixing multiple projects, subprojects, and "
        "files included from external projects that may each have been "
!       "written for a different version of CMake."
!       ;
      }
    
--- 115,122 ----
        "This is useful when mixing multiple projects, subprojects, and "
        "files included from external projects that may each have been "
!       "written for a different version of CMake.  "
!       "Each subdirectory entered by the project automatically pushes "
!       "a new level on the stack to isolate the subdirectories from "
!       "their parents.";
      }
    

Index: cmCMakeMinimumRequired.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmCMakeMinimumRequired.h,v
retrieving revision 1.12
retrieving revision 1.12.2.1
diff -C 2 -d -r1.12 -r1.12.2.1
*** cmCMakeMinimumRequired.h	7 Mar 2008 20:30:32 -0000	1.12
--- cmCMakeMinimumRequired.h	18 Mar 2008 14:23:54 -0000	1.12.2.1
***************
*** 70,78 ****
        "                         [FATAL_ERROR])\n"
        "If the current version of CMake is lower than that required "
!       "it will stop processing the project and report an error.\n"
        "When a version higher than 2.4 is specified the command implicitly "
        "invokes\n"
        "  cmake_policy(VERSION major[.minor[.patch]])\n"
!       "which sets the cmake policy version level to the version specified.\n"
        "When version 2.4 or lower is given the command implicitly invokes\n"
        "  cmake_policy(VERSION 2.4)\n"
--- 70,78 ----
        "                         [FATAL_ERROR])\n"
        "If the current version of CMake is lower than that required "
!       "it will stop processing the project and report an error.  "
        "When a version higher than 2.4 is specified the command implicitly "
        "invokes\n"
        "  cmake_policy(VERSION major[.minor[.patch]])\n"
!       "which sets the cmake policy version level to the version specified.  "
        "When version 2.4 or lower is given the command implicitly invokes\n"
        "  cmake_policy(VERSION 2.4)\n"

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.207
retrieving revision 1.207.2.1
diff -C 2 -d -r1.207 -r1.207.2.1
*** cmTarget.cxx	13 Mar 2008 17:48:57 -0000	1.207
--- cmTarget.cxx	18 Mar 2008 14:23:54 -0000	1.207.2.1
***************
*** 54,57 ****
--- 54,59 ----
  {
    this->Makefile = 0;
+   this->PolicyStatusCMP0003 = cmPolicies::WARN;
+   this->PolicyStatusCMP0004 = cmPolicies::WARN;
    this->LinkLibrariesAnalyzed = false;
    this->HaveInstallRule = false;
***************
*** 727,730 ****
--- 729,738 ----
    // Save the backtrace of target construction.
    this->Makefile->GetBacktrace(this->Internal->Backtrace);
+ 
+   // Record current policies for later use.
+   this->PolicyStatusCMP0003 =
+     this->Makefile->GetPolicyStatus(cmPolicies::CMP0003);
+   this->PolicyStatusCMP0004 =
+     this->Makefile->GetPolicyStatus(cmPolicies::CMP0004);
  }
  
***************
*** 2579,2587 ****
    if(this->IsImported())
      {
!     std::string msg =  "GetExecutableNamesInternal called on imported target: ";
      msg += this->GetName();
!     this->GetMakefile()->
!       IssueMessage(cmake::INTERNAL_ERROR,
!                    msg.c_str());
      }
  
--- 2587,2594 ----
    if(this->IsImported())
      {
!     std::string msg =
!       "GetExecutableNamesInternal called on imported target: ";
      msg += this->GetName();
!     this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg.c_str());
      }
  

Index: cmMakefile.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefile.cxx,v
retrieving revision 1.463
retrieving revision 1.463.2.1
diff -C 2 -d -r1.463 -r1.463.2.1
*** cmMakefile.cxx	13 Mar 2008 18:13:44 -0000	1.463
--- cmMakefile.cxx	18 Mar 2008 14:23:54 -0000	1.463.2.1
***************
*** 1024,1035 ****
  {
    // Create a regular expression to match valid definitions.
-   // Definitions with non-trivial values must not be matched because
-   // escaping them could break compatibility with escapes added by
-   // users.
    static cmsys::RegularExpression
!     regex("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=[A-Za-z0-9_.]+)?$");
  
    // Make sure the definition matches.
!   if(!regex.find(def.c_str()))
      {
      return false;
--- 1024,1032 ----
  {
    // Create a regular expression to match valid definitions.
    static cmsys::RegularExpression
!     valid("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=.*)?$");
  
    // Make sure the definition matches.
!   if(!valid.find(def.c_str()))
      {
      return false;
***************
*** 1044,1047 ****
--- 1041,1075 ----
      }
  
+   // Definitions with non-trivial values require a policy check.
+   static cmsys::RegularExpression
+     trivial("^[-/]D[A-Za-z_][A-Za-z0-9_]*(=[A-Za-z0-9_.]+)?$");
+   if(!trivial.find(def.c_str()))
+     {
+     // This definition has a non-trivial value.
+     switch(this->GetPolicyStatus(cmPolicies::CMP0005))
+       {
+       case cmPolicies::WARN:
+         this->IssueMessage(
+           cmake::AUTHOR_WARNING,
+           this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0005)
+           );
+       case cmPolicies::OLD:
+         // OLD behavior is to not escape the value.  We should not
+         // convert the definition to use the property.
+         return false;
+       case cmPolicies::REQUIRED_IF_USED:
+       case cmPolicies::REQUIRED_ALWAYS:
+         this->IssueMessage(
+           cmake::FATAL_ERROR,
+           this->GetPolicies()->GetRequiredPolicyError(cmPolicies::CMP0005)
+           );
+         return false;
+       case cmPolicies::NEW:
+         // NEW behavior is to escape the value.  Proceed to convert it
+         // to an entry in the property.
+         break;
+       }
+     }
+ 
    // Get the definition part after the flag.
    const char* define = def.c_str() + 2;



More information about the Cmake-commits mailing list