[Cmake-commits] [cmake-commits] king committed cmTarget.cxx 1.238 1.239

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Apr 8 16:29:05 EDT 2009


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

Modified Files:
	cmTarget.cxx 
Log Message:
ENH: Allow IMPORTED_IMPLIB w/o IMPORTED_LOCATION

Linking to a Windows shared library (.dll) requires only its import
library (.lib).  This teaches CMake to recognize SHARED IMPORTED library
targets that set only IMPORTED_IMPLIB and not IMPORTED_LOCATION.


Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.238
retrieving revision 1.239
diff -C 2 -d -r1.238 -r1.239
*** cmTarget.cxx	8 Apr 2009 20:28:55 -0000	1.238
--- cmTarget.cxx	8 Apr 2009 20:29:03 -0000	1.239
***************
*** 2528,2548 ****
  std::string cmTarget::ImportedGetFullPath(const char* config, bool implib)
  {
    if(cmTarget::ImportInfo const* info = this->GetImportInfo(config))
      {
!     if(implib)
!       {
!       return info->ImportLibrary;
!       }
!     else
!       {
!       return info->Location;
!       }
      }
!   else
      {
!     std::string result = this->GetName();
      result += "-NOTFOUND";
-     return result;
      }
  }
  
--- 2528,2542 ----
  std::string cmTarget::ImportedGetFullPath(const char* config, bool implib)
  {
+   std::string result;
    if(cmTarget::ImportInfo const* info = this->GetImportInfo(config))
      {
!     result = implib? info->ImportLibrary : info->Location;
      }
!   if(result.empty())
      {
!     result = this->GetName();
      result += "-NOTFOUND";
      }
+   return result;
  }
  
***************
*** 3468,3472 ****
    // If the location is empty then the target is not available for
    // this configuration.
!   if(i->second.Location.empty())
      {
      return 0;
--- 3462,3466 ----
    // If the location is empty then the target is not available for
    // this configuration.
!   if(i->second.Location.empty() && i->second.ImportLibrary.empty())
      {
      return 0;
***************
*** 3492,3495 ****
--- 3486,3495 ----
    suffix += desired_config;
  
+   // On a DLL platform there may be only IMPORTED_IMPLIB for a shared
+   // library or an executable with exports.
+   bool allowImp =
+     this->DLLPlatform && (this->GetType() == cmTarget::SHARED_LIBRARY ||
+                           this->IsExecutableWithExports());
+ 
    // Look for a mapping from the current project's configuration to
    // the imported project's configuration.
***************
*** 3506,3511 ****
    // If a mapping was found, check its configurations.
    const char* loc = 0;
    for(std::vector<std::string>::const_iterator mci = mappedConfigs.begin();
!       !loc && mci != mappedConfigs.end(); ++mci)
      {
      // Look for this configuration.
--- 3506,3512 ----
    // If a mapping was found, check its configurations.
    const char* loc = 0;
+   const char* imp = 0;
    for(std::vector<std::string>::const_iterator mci = mappedConfigs.begin();
!       !loc && !imp && mci != mappedConfigs.end(); ++mci)
      {
      // Look for this configuration.
***************
*** 3514,3520 ****
      locProp += mcUpper;
      loc = this->GetProperty(locProp.c_str());
  
      // If it was found, use it for all properties below.
!     if(loc)
        {
        suffix = "_";
--- 3515,3527 ----
      locProp += mcUpper;
      loc = this->GetProperty(locProp.c_str());
+     if(allowImp)
+       {
+       std::string impProp = "IMPORTED_IMPLIB_";
+       impProp += mcUpper;
+       imp = this->GetProperty(impProp.c_str());
+       }
  
      // If it was found, use it for all properties below.
!     if(loc || imp)
        {
        suffix = "_";
***************
*** 3526,3530 ****
    // then the target is not found.  The project does not want any
    // other configuration.
!   if(!mappedConfigs.empty() && !loc)
      {
      return;
--- 3533,3537 ----
    // then the target is not found.  The project does not want any
    // other configuration.
!   if(!mappedConfigs.empty() && !loc && !imp)
      {
      return;
***************
*** 3533,3546 ****
    // If we have not yet found it then there are no mapped
    // configurations.  Look for an exact-match.
!   if(!loc)
      {
      std::string locProp = "IMPORTED_LOCATION";
      locProp += suffix;
      loc = this->GetProperty(locProp.c_str());
      }
  
    // If we have not yet found it then there are no mapped
    // configurations and no exact match.
!   if(!loc)
      {
      // The suffix computed above is not useful.
--- 3540,3559 ----
    // If we have not yet found it then there are no mapped
    // configurations.  Look for an exact-match.
!   if(!loc && !imp)
      {
      std::string locProp = "IMPORTED_LOCATION";
      locProp += suffix;
      loc = this->GetProperty(locProp.c_str());
+     if(allowImp)
+       {
+       std::string impProp = "IMPORTED_IMPLIB";
+       impProp += suffix;
+       imp = this->GetProperty(impProp.c_str());
+       }
      }
  
    // If we have not yet found it then there are no mapped
    // configurations and no exact match.
!   if(!loc && !imp)
      {
      // The suffix computed above is not useful.
***************
*** 3550,3558 ****
      // manually-written code.
      loc = this->GetProperty("IMPORTED_LOCATION");
      }
  
    // If we have not yet found it then the project is willing to try
    // any available configuration.
!   if(!loc)
      {
      std::vector<std::string> availableConfigs;
--- 3563,3575 ----
      // manually-written code.
      loc = this->GetProperty("IMPORTED_LOCATION");
+     if(allowImp)
+       {
+       imp = this->GetProperty("IMPORTED_IMPLIB");
+       }
      }
  
    // If we have not yet found it then the project is willing to try
    // any available configuration.
!   if(!loc && !imp)
      {
      std::vector<std::string> availableConfigs;
***************
*** 3563,3567 ****
      for(std::vector<std::string>::const_iterator
            aci = availableConfigs.begin();
!         !loc && aci != availableConfigs.end(); ++aci)
        {
        suffix = "_";
--- 3580,3584 ----
      for(std::vector<std::string>::const_iterator
            aci = availableConfigs.begin();
!         !loc && !imp && aci != availableConfigs.end(); ++aci)
        {
        suffix = "_";
***************
*** 3570,3578 ****
        locProp += suffix;
        loc = this->GetProperty(locProp.c_str());
        }
      }
  
    // If we have not yet found it then the target is not available.
!   if(!loc)
      {
      return;
--- 3587,3601 ----
        locProp += suffix;
        loc = this->GetProperty(locProp.c_str());
+       if(allowImp)
+         {
+         std::string impProp = "IMPORTED_IMPLIB";
+         impProp += suffix;
+         imp = this->GetProperty(impProp.c_str());
+         }
        }
      }
  
    // If we have not yet found it then the target is not available.
!   if(!loc && !imp)
      {
      return;
***************
*** 3581,3585 ****
    // A provided configuration has been chosen.  Load the
    // configuration's properties.
!   info.Location = loc;
  
    // Get the soname.
--- 3604,3626 ----
    // A provided configuration has been chosen.  Load the
    // configuration's properties.
! 
!   // Get the location.
!   if(loc)
!     {
!     info.Location = loc;
!     }
!   else
!     {
!     std::string impProp = "IMPORTED_LOCATION";
!     impProp += suffix;
!     if(const char* config_location = this->GetProperty(impProp.c_str()))
!       {
!       info.Location = config_location;
!       }
!     else if(const char* location = this->GetProperty("IMPORTED_LOCATION"))
!       {
!       info.Location = location;
!       }
!     }
  
    // Get the soname.
***************
*** 3614,3619 ****
  
    // Get the import library.
!   if(this->GetType() == cmTarget::SHARED_LIBRARY ||
!      this->IsExecutableWithExports())
      {
      std::string impProp = "IMPORTED_IMPLIB";
--- 3655,3664 ----
  
    // Get the import library.
!   if(imp)
!     {
!     info.ImportLibrary = imp;
!     }
!   else if(this->GetType() == cmTarget::SHARED_LIBRARY ||
!           this->IsExecutableWithExports())
      {
      std::string impProp = "IMPORTED_IMPLIB";



More information about the Cmake-commits mailing list