[Cmake-commits] [cmake-commits] king committed cmTarget.cxx 1.239 1.240 cmTarget.h 1.121 1.122

cmake-commits at cmake.org cmake-commits at cmake.org
Fri May 1 09:45:21 EDT 2009


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

Modified Files:
	cmTarget.cxx cmTarget.h 
Log Message:
ENH: Refactor target output file type computation

This creates method cmTarget::GetOutputTargetType to compute the output
file type 'ARCHIVE', 'LIBRARY', or 'RUNTIME' from the platform and
target type.  It factors out logic from the target output directory
computation code for later re-use.


Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.121
retrieving revision 1.122
diff -C 2 -d -r1.121 -r1.122
*** cmTarget.h	10 Feb 2009 13:50:09 -0000	1.121
--- cmTarget.h	1 May 2009 13:45:19 -0000	1.122
***************
*** 495,498 ****
--- 495,501 ----
    void SetPropertyDefault(const char* property, const char* default_value);
  
+   // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
+   const char* GetOutputTargetType(bool implib);
+ 
    // Get the full path to the target output directory.
    std::string GetOutputDir(bool implib);

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.239
retrieving revision 1.240
diff -C 2 -d -r1.239 -r1.240
*** cmTarget.cxx	8 Apr 2009 20:29:03 -0000	1.239
--- cmTarget.cxx	1 May 2009 13:45:19 -0000	1.240
***************
*** 3168,3171 ****
--- 3168,3227 ----
  
  //----------------------------------------------------------------------------
+ const char* cmTarget::GetOutputTargetType(bool implib)
+ {
+   switch(this->GetType())
+     {
+     case cmTarget::SHARED_LIBRARY:
+       if(this->DLLPlatform)
+         {
+         if(implib)
+           {
+           // A DLL import library is treated as an archive target.
+           return "ARCHIVE";
+           }
+         else
+           {
+           // A DLL shared library is treated as a runtime target.
+           return "RUNTIME";
+           }
+         }
+       else
+         {
+         // For non-DLL platforms shared libraries are treated as
+         // library targets.
+         return "LIBRARY";
+         }
+     case cmTarget::STATIC_LIBRARY:
+       // Static libraries are always treated as archive targets.
+       return "ARCHIVE";
+     case cmTarget::MODULE_LIBRARY:
+       if(implib)
+         {
+         // Module libraries are always treated as library targets.
+         return "ARCHIVE";
+         }
+       else
+         {
+         // Module import libraries are treated as archive targets.
+         return "LIBRARY";
+         }
+     case cmTarget::EXECUTABLE:
+       if(implib)
+         {
+         // Executable import libraries are treated as archive targets.
+         return "ARCHIVE";
+         }
+       else
+         {
+         // Executables are always treated as runtime targets.
+         return "RUNTIME";
+         }
+     default:
+       break;
+     }
+   return "";
+ }
+ 
+ //----------------------------------------------------------------------------
  std::string cmTarget::GetOutputDir(bool implib)
  {
***************
*** 3221,3281 ****
    // based on the target type.
    const char* propertyName = 0;
!   switch(this->GetType())
      {
!     case cmTarget::SHARED_LIBRARY:
!       {
!       // For non-DLL platforms shared libraries are treated as
!       // library targets.  For DLL platforms the DLL part of a
!       // shared library is treated as a runtime target and the
!       // corresponding import library is treated as an archive
!       // target.
!       if(this->DLLPlatform)
!         {
!         if(implib)
!           {
!           propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
!           }
!         else
!           {
!           propertyName = "RUNTIME_OUTPUT_DIRECTORY";
!           }
!         }
!       else
!         {
!         propertyName = "LIBRARY_OUTPUT_DIRECTORY";
!         }
!       } break;
!     case cmTarget::STATIC_LIBRARY:
!       {
!       // Static libraries are always treated as archive targets.
!       propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
!       } break;
!     case cmTarget::MODULE_LIBRARY:
!       {
!       // Module libraries are always treated as library targets.
!       // Module import libraries are treated as archive targets.
!       if(implib)
!         {
!         propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
!         }
!       else
!         {
!         propertyName = "LIBRARY_OUTPUT_DIRECTORY";
!         }
!       } break;
!     case cmTarget::EXECUTABLE:
!       {
!       // Executables are always treated as runtime targets.
!       // Executable import libraries are treated as archive targets.
!       if(implib)
!         {
!         propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
!         }
!       else
!         {
!         propertyName = "RUNTIME_OUTPUT_DIRECTORY";
!         }
!       } break;
!     default: break;
      }
  
--- 3277,3285 ----
    // based on the target type.
    const char* propertyName = 0;
!   std::string propertyNameStr = this->GetOutputTargetType(implib);
!   if(!propertyNameStr.empty())
      {
!     propertyNameStr += "_OUTPUT_DIRECTORY";
!     propertyName = propertyNameStr.c_str();
      }
  



More information about the Cmake-commits mailing list