[Cmake-commits] [cmake-commits] king committed cmAddLibraryCommand.cxx 1.36 1.37 cmAddLibraryCommand.h 1.22 1.23 cmComputeLinkDepends.cxx 1.20 1.21 cmComputeLinkInformation.cxx 1.42 1.43 cmLocalGenerator.cxx 1.281 1.282 cmTarget.cxx 1.221 1.222 cmTarget.h 1.117 1.118

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Aug 18 11:39:24 EDT 2008


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

Modified Files:
	cmAddLibraryCommand.cxx cmAddLibraryCommand.h 
	cmComputeLinkDepends.cxx cmComputeLinkInformation.cxx 
	cmLocalGenerator.cxx cmTarget.cxx cmTarget.h 
Log Message:
ENH: Add UNKNOWN type for IMPORTED libraries

When creating an IMPORTED target for a library that has been found on
disk, it may not be known whether the library is STATIC or SHARED.
However, the library may still be linked using the file found from disk.
Use of an IMPORTED target is still important to allow per-configuration
files to be specified for the library.

This change creates an UNKNOWN type for IMPORTED library targets.  The
IMPORTED_LOCATION property (and its per-config equivalents) specifies
the location of the library.  CMake makes no assumptions about the
library that cannot be inferred from the file on disk.  This will help
projects and find-modules import targets found on disk or specified by
the user.


Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.281
retrieving revision 1.282
diff -C 2 -d -r1.281 -r1.282
*** cmLocalGenerator.cxx	18 Aug 2008 15:26:50 -0000	1.281
--- cmLocalGenerator.cxx	18 Aug 2008 15:39:22 -0000	1.282
***************
*** 1707,1710 ****
--- 1707,1711 ----
        case cmTarget::SHARED_LIBRARY:
        case cmTarget::MODULE_LIBRARY:
+       case cmTarget::UNKNOWN_LIBRARY:
          {
          // Get the location of the target's output file and depend on it.

Index: cmAddLibraryCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddLibraryCommand.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -C 2 -d -r1.22 -r1.23
*** cmAddLibraryCommand.h	11 Feb 2008 18:35:39 -0000	1.22
--- cmAddLibraryCommand.h	18 Aug 2008 15:39:22 -0000	1.23
***************
*** 101,105 ****
        "The add_library command can also create IMPORTED library "
        "targets using this signature:\n"
!       "  add_library(<name> <SHARED|STATIC|MODULE> IMPORTED)\n"
        "An IMPORTED library target references a library file located "
        "outside the project.  "
--- 101,105 ----
        "The add_library command can also create IMPORTED library "
        "targets using this signature:\n"
!       "  add_library(<name> <SHARED|STATIC|MODULE|UNKNOWN> IMPORTED)\n"
        "An IMPORTED library target references a library file located "
        "outside the project.  "

Index: cmComputeLinkInformation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkInformation.cxx,v
retrieving revision 1.42
retrieving revision 1.43
diff -C 2 -d -r1.42 -r1.43
*** cmComputeLinkInformation.cxx	30 Jul 2008 14:23:41 -0000	1.42
--- cmComputeLinkInformation.cxx	18 Aug 2008 15:39:22 -0000	1.43
***************
*** 582,589 ****
      }
  
!   if(tgt && (tgt->GetType() == cmTarget::STATIC_LIBRARY ||
!              tgt->GetType() == cmTarget::SHARED_LIBRARY ||
!              tgt->GetType() == cmTarget::MODULE_LIBRARY ||
!              impexe))
      {
      // This is a CMake target.  Ask the target for its real name.
--- 582,586 ----
      }
  
!   if(tgt && tgt->IsLinkable())
      {
      // This is a CMake target.  Ask the target for its real name.
***************
*** 1556,1559 ****
--- 1553,1564 ----
                                                  cmTarget* target)
  {
+   // Libraries with unknown type must be handled using just the file
+   // on disk.
+   if(target->GetType() == cmTarget::UNKNOWN_LIBRARY)
+     {
+     this->AddLibraryRuntimeInfo(fullPath);
+     return;
+     }
+ 
    // Skip targets that are not shared libraries (modules cannot be linked).
    if(target->GetType() != cmTarget::SHARED_LIBRARY)

Index: cmAddLibraryCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmAddLibraryCommand.cxx,v
retrieving revision 1.36
retrieving revision 1.37
diff -C 2 -d -r1.36 -r1.37
*** cmAddLibraryCommand.cxx	11 Feb 2008 22:33:46 -0000	1.36
--- cmAddLibraryCommand.cxx	18 Aug 2008 15:39:22 -0000	1.37
***************
*** 69,72 ****
--- 69,78 ----
        haveSpecifiedType = true;
        }
+     else if(libType == "UNKNOWN")
+       {
+       ++s;
+       type = cmTarget::UNKNOWN_LIBRARY;
+       haveSpecifiedType = true;
+       }
      else if(*s == "EXCLUDE_FROM_ALL")
        {
***************
*** 128,131 ****
--- 134,147 ----
      }
  
+   // A non-imported target may not have UNKNOWN type.
+   if(type == cmTarget::UNKNOWN_LIBRARY)
+     {
+     this->Makefile->IssueMessage(
+       cmake::FATAL_ERROR,
+       "The UNKNOWN library type may be used only for IMPORTED libraries."
+       );
+     return true;
+     }
+ 
    // Enforce name uniqueness.
    {

Index: cmComputeLinkDepends.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmComputeLinkDepends.cxx,v
retrieving revision 1.20
retrieving revision 1.21
diff -C 2 -d -r1.20 -r1.21
*** cmComputeLinkDepends.cxx	6 Aug 2008 21:48:53 -0000	1.20
--- cmComputeLinkDepends.cxx	18 Aug 2008 15:39:22 -0000	1.21
***************
*** 892,895 ****
--- 892,903 ----
  
  //----------------------------------------------------------------------------
+ static bool cmComputeLinkDependsNotStatic(cmTarget* tgt)
+ {
+   return (tgt &&
+           tgt->GetType() != cmTarget::STATIC_LIBRARY &&
+           tgt->GetType() != cmTarget::UNKNOWN_LIBRARY);
+ }
+ 
+ //----------------------------------------------------------------------------
  void cmComputeLinkDepends::PreserveOriginalEntries()
  {
***************
*** 902,906 ****
      {
      cmTarget* tgt = this->EntryList[*in].Target;
!     if(tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY)
        {
        // Skip input items known to not be static libraries.
--- 910,914 ----
      {
      cmTarget* tgt = this->EntryList[*in].Target;
!     if(cmComputeLinkDependsNotStatic(tgt))
        {
        // Skip input items known to not be static libraries.
***************
*** 925,929 ****
      {
      cmTarget* tgt = this->EntryList[*in].Target;
!     if(tgt && tgt->GetType() != cmTarget::STATIC_LIBRARY)
        {
        // Skip input items known to not be static libraries.
--- 933,937 ----
      {
      cmTarget* tgt = this->EntryList[*in].Target;
!     if(cmComputeLinkDependsNotStatic(tgt))
        {
        // Skip input items known to not be static libraries.

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.117
retrieving revision 1.118
diff -C 2 -d -r1.117 -r1.118
*** cmTarget.h	23 Jul 2008 16:59:14 -0000	1.117
--- cmTarget.h	18 Aug 2008 15:39:22 -0000	1.118
***************
*** 81,85 ****
    enum TargetType { EXECUTABLE, STATIC_LIBRARY,
                      SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET,
!                     INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY};
    static const char* TargetTypeNames[];
    enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD };
--- 81,86 ----
    enum TargetType { EXECUTABLE, STATIC_LIBRARY,
                      SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET,
!                     INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY,
!                     UNKNOWN_LIBRARY};
    static const char* TargetTypeNames[];
    enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD };
***************
*** 394,397 ****
--- 395,401 ----
    bool IsExecutableWithExports();
  
+   /** Return whether this target may be used to link another target.  */
+   bool IsLinkable();
+ 
    /** Return whether this target is a shared library Framework on
        Apple.  */

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.221
retrieving revision 1.222
diff -C 2 -d -r1.221 -r1.222
*** cmTarget.cxx	18 Aug 2008 15:26:51 -0000	1.221
--- cmTarget.cxx	18 Aug 2008 15:39:22 -0000	1.222
***************
*** 31,35 ****
    "EXECUTABLE", "STATIC_LIBRARY",
    "SHARED_LIBRARY", "MODULE_LIBRARY", "UTILITY", "GLOBAL_TARGET",
!   "INSTALL_FILES", "INSTALL_PROGRAMS", "INSTALL_DIRECTORY"
  };
  
--- 31,36 ----
    "EXECUTABLE", "STATIC_LIBRARY",
    "SHARED_LIBRARY", "MODULE_LIBRARY", "UTILITY", "GLOBAL_TARGET",
!   "INSTALL_FILES", "INSTALL_PROGRAMS", "INSTALL_DIRECTORY",
!   "UNKNOWN_LIBRARY"
  };
  
***************
*** 278,281 ****
--- 279,283 ----
       "symlink just inside the framework folder.  "
       "For DLLs this is the location of the \".dll\" part of the library.  "
+      "For UNKNOWN libraries this is the location of the file to be linked.  "
       "Ignored for non-imported targets.");
  
***************
*** 788,791 ****
--- 790,803 ----
  
  //----------------------------------------------------------------------------
+ bool cmTarget::IsLinkable()
+ {
+   return (this->GetType() == cmTarget::STATIC_LIBRARY ||
+           this->GetType() == cmTarget::SHARED_LIBRARY ||
+           this->GetType() == cmTarget::MODULE_LIBRARY ||
+           this->GetType() == cmTarget::UNKNOWN_LIBRARY ||
+           this->IsExecutableWithExports());
+ }
+ 
+ //----------------------------------------------------------------------------
  bool cmTarget::IsFrameworkOnApple()
  {
***************
*** 1861,1865 ****
       this->GetType() == cmTarget::STATIC_LIBRARY ||
       this->GetType() == cmTarget::SHARED_LIBRARY ||
!      this->GetType() == cmTarget::MODULE_LIBRARY)
      {
      if(!this->IsImported() && strcmp(prop,"LOCATION") == 0)
--- 1873,1878 ----
       this->GetType() == cmTarget::STATIC_LIBRARY ||
       this->GetType() == cmTarget::SHARED_LIBRARY ||
!      this->GetType() == cmTarget::MODULE_LIBRARY ||
!      this->GetType() == cmTarget::UNKNOWN_LIBRARY)
      {
      if(!this->IsImported() && strcmp(prop,"LOCATION") == 0)
***************
*** 1958,1961 ****
--- 1971,1977 ----
          return "INSTALL_DIRECTORY";
          // break; /* unreachable */
+       case cmTarget::UNKNOWN_LIBRARY:
+         return "UNKNOWN_LIBRARY";
+         // break; /* unreachable */
        }
      return 0;



More information about the Cmake-commits mailing list