[Cmake-commits] [cmake-commits] king committed cmComputeLinkDepends.cxx 1.28 1.29 cmComputeLinkDepends.h 1.14 1.15 cmExportFileGenerator.cxx 1.14 1.15 cmTarget.cxx 1.225 1.226 cmTarget.h 1.119 1.120 cmTargetLinkLibrariesCommand.cxx 1.28 1.29 cmTargetLinkLibrariesCommand.h 1.18 1.19 cmake.cxx 1.394 1.395 cmake.h 1.116 1.117

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Sep 4 17:34:27 EDT 2008


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

Modified Files:
	cmComputeLinkDepends.cxx cmComputeLinkDepends.h 
	cmExportFileGenerator.cxx cmTarget.cxx cmTarget.h 
	cmTargetLinkLibrariesCommand.cxx 
	cmTargetLinkLibrariesCommand.h cmake.cxx cmake.h 
Log Message:
ENH: Allow a custom list of debug configurations

Create a DEBUG_CONFIGURATIONS global property as a way for projects to
specify which configuration names are considered to be 'debug'
configurations.


Index: cmComputeLinkDepends.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -C 2 -d -r1.14 -r1.15
*** cmComputeLinkDepends.h	27 Aug 2008 14:35:53 -0000	1.14
--- cmComputeLinkDepends.h	4 Sep 2008 21:34:24 -0000	1.15
***************
*** 73,76 ****
--- 73,77 ----
    // Configuration information.
    const char* Config;
+   cmTarget::LinkLibraryType LinkType;
  
    // Output information.

Index: cmTargetLinkLibrariesCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTargetLinkLibrariesCommand.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -C 2 -d -r1.18 -r1.19
*** cmTargetLinkLibrariesCommand.h	18 Aug 2008 14:11:29 -0000	1.18
--- cmTargetLinkLibrariesCommand.h	4 Sep 2008 21:34:24 -0000	1.19
***************
*** 75,79 ****
        "the library immediately following it is to be used only for the "
        "corresponding build configuration.  "
!       "The \"debug\" keyword corresponds to the Debug configuration.  "
        "The \"optimized\" keyword corresponds to all other configurations.  "
        "The \"general\" keyword corresponds to all configurations, and is "
--- 75,81 ----
        "the library immediately following it is to be used only for the "
        "corresponding build configuration.  "
!       "The \"debug\" keyword corresponds to the Debug configuration "
!       "(or to configurations named in the DEBUG_CONFIGURATIONS global "
!       "property if it is set).  "
        "The \"optimized\" keyword corresponds to all other configurations.  "
        "The \"general\" keyword corresponds to all configurations, and is "
***************
*** 94,105 ****
        "                        [[debug|optimized|general] <lib>] ...)\n"
        "The LINK_INTERFACE_LIBRARIES mode appends the libraries "
!       "to the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG "
        "target properties instead of using them for linking.  "
        "Libraries specified as \"debug\" are appended to the "
!       "the LINK_INTERFACE_LIBRARIES_DEBUG property.  "
        "Libraries specified as \"optimized\" are appended to the "
        "the LINK_INTERFACE_LIBRARIES property.  "
        "Libraries specified as \"general\" (or without any keyword) are "
!       "appended to both properties."
        ;
      }
--- 96,109 ----
        "                        [[debug|optimized|general] <lib>] ...)\n"
        "The LINK_INTERFACE_LIBRARIES mode appends the libraries "
!       "to the LINK_INTERFACE_LIBRARIES and its per-configuration equivalent "
        "target properties instead of using them for linking.  "
        "Libraries specified as \"debug\" are appended to the "
!       "the LINK_INTERFACE_LIBRARIES_DEBUG property (or to the properties "
!       "corresponding to configurations listed in the DEBUG_CONFIGURATIONS "
!       "global property if it is set).  "
        "Libraries specified as \"optimized\" are appended to the "
        "the LINK_INTERFACE_LIBRARIES property.  "
        "Libraries specified as \"general\" (or without any keyword) are "
!       "treated as if specified for both \"debug\" and \"optimized\"."
        ;
      }

Index: cmExportFileGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportFileGenerator.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -C 2 -d -r1.14 -r1.15
*** cmExportFileGenerator.cxx	27 Apr 2008 11:30:45 -0000	1.14
--- cmExportFileGenerator.cxx	4 Sep 2008 21:34:24 -0000	1.15
***************
*** 178,186 ****
  {
    // Compute which library configuration to link.
!   cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED;
!   if(config && cmSystemTools::UpperCase(config) == "DEBUG")
!     {
!     linkType = cmTarget::DEBUG;
!     }
  
    // Construct the list of libs linked for this configuration.
--- 178,182 ----
  {
    // Compute which library configuration to link.
!   cmTarget::LinkLibraryType linkType = target->ComputeLinkType(config);
  
    // Construct the list of libs linked for this configuration.

Index: cmake.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.h,v
retrieving revision 1.116
retrieving revision 1.117
diff -C 2 -d -r1.116 -r1.117
*** cmake.h	31 Jul 2008 14:33:25 -0000	1.116
--- cmake.h	4 Sep 2008 21:34:24 -0000	1.117
***************
*** 333,336 ****
--- 333,340 ----
    bool IsPropertyChained(const char *name, cmProperty::ScopeType scope);
  
+   /** Get the list of configurations (in upper case) considered to be
+       debugging configurations.*/
+   std::vector<std::string> const& GetDebugConfigs();
+ 
    // record accesses of properties and variables
    void RecordPropertyAccess(const char *name, cmProperty::ScopeType scope);
***************
*** 457,460 ****
--- 461,465 ----
    cmFileTimeComparison* FileComparison;
    std::string GraphVizFile;
+   std::vector<std::string> DebugConfigs;
    
    void UpdateConversionPathTable();

Index: cmake.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmake.cxx,v
retrieving revision 1.394
retrieving revision 1.395
diff -C 2 -d -r1.394 -r1.395
*** cmake.cxx	4 Sep 2008 17:15:08 -0000	1.394
--- cmake.cxx	4 Sep 2008 21:34:24 -0000	1.395
***************
*** 3365,3368 ****
--- 3365,3381 ----
  
    cm->DefineProperty(
+     "DEBUG_CONFIGURATIONS", cmProperty::GLOBAL,
+     "Specify which configurations are for debugging.",
+     "The value must be a semi-colon separated list of configuration names.  "
+     "Currently this property is used only by the target_link_libraries "
+     "command (see its documentation for details).  "
+     "Additional uses may be defined in the future.  "
+     "\n"
+     "This property must be set at the top level of the project and before "
+     "the first target_link_libraries command invocation.  "
+     "If any entry in the list does not match a valid configuration for "
+     "the project the behavior is undefined.");
+ 
+   cm->DefineProperty(
      "GLOBAL_DEPENDS_DEBUG_MODE", cmProperty::GLOBAL,
      "Enable global target dependency graph debug mode.",
***************
*** 3552,3555 ****
--- 3565,3574 ----
      }
  
+   // Special hook to invalidate cached value.
+   if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0)
+     {
+     this->DebugConfigs.clear();
+     }
+ 
    this->Properties.SetProperty(prop, value, cmProperty::GLOBAL);
  }
***************
*** 3561,3564 ****
--- 3580,3590 ----
      return;
      }
+ 
+   // Special hook to invalidate cached value.
+   if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0)
+     {
+     this->DebugConfigs.clear();
+     }
+ 
    this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL);
  }
***************
*** 4271,4272 ****
--- 4297,4323 ----
      }
  }
+ 
+ //----------------------------------------------------------------------------
+ std::vector<std::string> const& cmake::GetDebugConfigs()
+ {
+   // Compute on-demand.
+   if(this->DebugConfigs.empty())
+     {
+     if(const char* config_list = this->GetProperty("DEBUG_CONFIGURATIONS"))
+       {
+       // Expand the specified list and convert to upper-case.
+       cmSystemTools::ExpandListArgument(config_list, this->DebugConfigs);
+       for(std::vector<std::string>::iterator i = this->DebugConfigs.begin();
+           i != this->DebugConfigs.end(); ++i)
+         {
+         *i = cmSystemTools::UpperCase(*i);
+         }
+       }
+     // If no configurations were specified, use a default list.
+     if(this->DebugConfigs.empty())
+       {
+       this->DebugConfigs.push_back("DEBUG");
+       }
+     }
+   return this->DebugConfigs;
+ }

Index: cmComputeLinkDepends.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.cxx,v
retrieving revision 1.28
retrieving revision 1.29
diff -C 2 -d -r1.28 -r1.29
*** cmComputeLinkDepends.cxx	29 Aug 2008 17:22:41 -0000	1.28
--- cmComputeLinkDepends.cxx	4 Sep 2008 21:34:24 -0000	1.29
***************
*** 189,192 ****
--- 189,193 ----
    // The configuration being linked.
    this->Config = (config && *config)? config : 0;
+   this->LinkType = this->Target->ComputeLinkType(this->Config);
  
    // Enable debug mode if requested.
***************
*** 447,457 ****
    cmSystemTools::ExpandListArgument(value, deplist);
  
-   // Compute which library configuration to link.
-   cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED;
-   if(this->Config && cmSystemTools::UpperCase(this->Config) == "DEBUG")
-     {
-     linkType = cmTarget::DEBUG;
-     }
- 
    // Look for entries meant for this configuration.
    std::vector<std::string> actual_libs;
--- 448,451 ----
***************
*** 501,505 ****
  
        // If the library is meant for this link type then use it.
!       if(llt == cmTarget::GENERAL || llt == linkType)
          {
          actual_libs.push_back(*di);
--- 495,499 ----
  
        // If the library is meant for this link type then use it.
!       if(llt == cmTarget::GENERAL || llt == this->LinkType)
          {
          actual_libs.push_back(*di);
***************
*** 525,535 ****
                                             LinkLibraryVectorType const& libs)
  {
-   // Compute which library configuration to link.
-   cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED;
-   if(this->Config && cmSystemTools::UpperCase(this->Config) == "DEBUG")
-     {
-     linkType = cmTarget::DEBUG;
-     }
- 
    // Look for entries meant for this configuration.
    std::vector<std::string> actual_libs;
--- 519,522 ----
***************
*** 537,541 ****
        li != libs.end(); ++li)
      {
!     if(li->second == cmTarget::GENERAL || li->second == linkType)
        {
        actual_libs.push_back(li->first);
--- 524,528 ----
        li != libs.end(); ++li)
      {
!     if(li->second == cmTarget::GENERAL || li->second == this->LinkType)
        {
        actual_libs.push_back(li->first);

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.119
retrieving revision 1.120
diff -C 2 -d -r1.119 -r1.120
*** cmTarget.h	19 Aug 2008 15:43:51 -0000	1.119
--- cmTarget.h	4 Sep 2008 21:34:24 -0000	1.120
***************
*** 187,190 ****
--- 187,193 ----
      {return this->OriginalLinkLibraries;}
  
+   /** Compute the link type to use for the given configuration.  */
+   LinkLibraryType ComputeLinkType(const char* config);
+ 
    /**
     * Clear the dependency information recorded for this target, if any.

Index: cmTargetLinkLibrariesCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTargetLinkLibrariesCommand.cxx,v
retrieving revision 1.28
retrieving revision 1.29
diff -C 2 -d -r1.28 -r1.29
*** cmTargetLinkLibrariesCommand.cxx	18 Aug 2008 14:11:28 -0000	1.28
--- cmTargetLinkLibrariesCommand.cxx	4 Sep 2008 21:34:24 -0000	1.29
***************
*** 189,215 ****
      }
  
    // Include this library in the link interface for the target.
!   if(llt == cmTarget::DEBUG)
      {
!     // Put in only the DEBUG configuration interface.
!     this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES_DEBUG", lib);
      }
!   else if(llt == cmTarget::OPTIMIZED)
      {
!     // Put in only the non-DEBUG configuration interface.
      this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib);
  
!     // Make sure the DEBUG configuration interface exists so that this
!     // one will not be used as a fall-back.
!     if(!this->Target->GetProperty("LINK_INTERFACE_LIBRARIES_DEBUG"))
        {
!       this->Target->SetProperty("LINK_INTERFACE_LIBRARIES_DEBUG", "");
        }
      }
-   else
-     {
-     // Put in both the DEBUG and non-DEBUG configuration interfaces.
-     this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib);
-     this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES_DEBUG", lib);
-     }
  }
--- 189,226 ----
      }
  
+   // Get the list of configurations considered to be DEBUG.
+   std::vector<std::string> const& debugConfigs =
+     this->Makefile->GetCMakeInstance()->GetDebugConfigs();
+   std::string prop;
+ 
    // Include this library in the link interface for the target.
!   if(llt == cmTarget::DEBUG || llt == cmTarget::GENERAL)
      {
!     // Put in the DEBUG configuration interfaces.
!     for(std::vector<std::string>::const_iterator i = debugConfigs.begin();
!         i != debugConfigs.end(); ++i)
!       {
!       prop = "LINK_INTERFACE_LIBRARIES_";
!       prop += *i;
!       this->Target->AppendProperty(prop.c_str(), lib);
!       }
      }
!   if(llt == cmTarget::OPTIMIZED || llt == cmTarget::GENERAL)
      {
!     // Put in the non-DEBUG configuration interfaces.
      this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib);
  
!     // Make sure the DEBUG configuration interfaces exist so that the
!     // general one will not be used as a fall-back.
!     for(std::vector<std::string>::const_iterator i = debugConfigs.begin();
!         i != debugConfigs.end(); ++i)
        {
!       prop = "LINK_INTERFACE_LIBRARIES_";
!       prop += *i;
!       if(!this->Target->GetProperty(prop.c_str()))
!         {
!         this->Target->SetProperty(prop.c_str(), "");
!         }
        }
      }
  }

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.225
retrieving revision 1.226
diff -C 2 -d -r1.225 -r1.226
*** cmTarget.cxx	2 Sep 2008 16:06:32 -0000	1.225
--- cmTarget.cxx	4 Sep 2008 21:34:24 -0000	1.226
***************
*** 1258,1261 ****
--- 1258,1289 ----
  
  //----------------------------------------------------------------------------
+ cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config)
+ {
+   // No configuration is always optimized.
+   if(!(config && *config))
+     {
+     return cmTarget::OPTIMIZED;
+     }
+ 
+   // Get the list of configurations considered to be DEBUG.
+   std::vector<std::string> const& debugConfigs =
+     this->Makefile->GetCMakeInstance()->GetDebugConfigs();
+ 
+   // Check if any entry in the list matches this configuration.
+   std::string configUpper = cmSystemTools::UpperCase(config);
+   for(std::vector<std::string>::const_iterator i = debugConfigs.begin();
+       i != debugConfigs.end(); ++i)
+     {
+     if(*i == configUpper)
+       {
+       return cmTarget::DEBUG;
+       }
+     }
+ 
+   // The current configuration is not a debug configuration.
+   return cmTarget::OPTIMIZED;
+ }
+ 
+ //----------------------------------------------------------------------------
  void cmTarget::ClearDependencyInformation( cmMakefile& mf,
                                             const char* target )
***************
*** 3621,3629 ****
  
      // Compute which library configuration to link.
!     cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED;
!     if(config && cmSystemTools::UpperCase(config) == "DEBUG")
!       {
!       linkType = cmTarget::DEBUG;
!       }
  
      // Construct the list of libs linked for this configuration.
--- 3649,3653 ----
  
      // Compute which library configuration to link.
!     cmTarget::LinkLibraryType linkType = this->ComputeLinkType(config);
  
      // Construct the list of libs linked for this configuration.



More information about the Cmake-commits mailing list