Factor cmInstallType out of cmTarget::TargetType

The purpose of the TargetType enumeration was overloaded for install
type because install rules were once recorded as targets.  Factor the
install types out into their own enumeration.
This commit is contained in:
Brad King 2012-02-27 11:26:38 -05:00
parent cffebe643c
commit 573fa3bf13
13 changed files with 81 additions and 70 deletions

View File

@ -392,10 +392,6 @@ void cmExtraCodeBlocksGenerator
make.c_str(), makefile, compiler.c_str()); make.c_str(), makefile, compiler.c_str());
} }
break; break;
// ignore these:
case cmTarget::INSTALL_FILES:
case cmTarget::INSTALL_PROGRAMS:
case cmTarget::INSTALL_DIRECTORY:
default: default:
break; break;
} }

View File

@ -1045,10 +1045,6 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
} }
} }
break; break;
// ignore these:
case cmTarget::INSTALL_FILES:
case cmTarget::INSTALL_PROGRAMS:
case cmTarget::INSTALL_DIRECTORY:
default: default:
break; break;
} }

View File

@ -12,6 +12,7 @@
#include "cmFileCommand.h" #include "cmFileCommand.h"
#include "cmake.h" #include "cmake.h"
#include "cmHexFileConverter.h" #include "cmHexFileConverter.h"
#include "cmInstallType.h"
#include "cmFileTimeComparison.h" #include "cmFileTimeComparison.h"
#include "cmCryptoHash.h" #include "cmCryptoHash.h"
@ -1690,7 +1691,7 @@ struct cmFileInstaller: public cmFileCopier
{ {
cmFileInstaller(cmFileCommand* command): cmFileInstaller(cmFileCommand* command):
cmFileCopier(command, "INSTALL"), cmFileCopier(command, "INSTALL"),
InstallType(cmTarget::INSTALL_FILES), InstallType(cmInstallType_FILES),
Optional(false), Optional(false),
DestDirLength(0) DestDirLength(0)
{ {
@ -1711,7 +1712,7 @@ struct cmFileInstaller: public cmFileCopier
} }
protected: protected:
cmTarget::TargetType InstallType; cmInstallType InstallType;
bool Optional; bool Optional;
int DestDirLength; int DestDirLength;
std::string Rename; std::string Rename;
@ -1745,7 +1746,7 @@ protected:
virtual bool Install(const char* fromFile, const char* toFile) virtual bool Install(const char* fromFile, const char* toFile)
{ {
// Support installing from empty source to make a directory. // Support installing from empty source to make a directory.
if(this->InstallType == cmTarget::INSTALL_DIRECTORY && !*fromFile) if(this->InstallType == cmInstallType_DIRECTORY && !*fromFile)
{ {
return this->InstallDirectory(fromFile, toFile, MatchProperties()); return this->InstallDirectory(fromFile, toFile, MatchProperties());
} }
@ -1767,14 +1768,14 @@ protected:
// Add execute permissions based on the target type. // Add execute permissions based on the target type.
switch(this->InstallType) switch(this->InstallType)
{ {
case cmTarget::SHARED_LIBRARY: case cmInstallType_SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY: case cmInstallType_MODULE_LIBRARY:
if(this->Makefile->IsOn("CMAKE_INSTALL_SO_NO_EXE")) if(this->Makefile->IsOn("CMAKE_INSTALL_SO_NO_EXE"))
{ {
break; break;
} }
case cmTarget::EXECUTABLE: case cmInstallType_EXECUTABLE:
case cmTarget::INSTALL_PROGRAMS: case cmInstallType_PROGRAMS:
this->FilePermissions |= mode_owner_execute; this->FilePermissions |= mode_owner_execute;
this->FilePermissions |= mode_group_execute; this->FilePermissions |= mode_group_execute;
this->FilePermissions |= mode_world_execute; this->FilePermissions |= mode_world_execute;
@ -1796,8 +1797,8 @@ bool cmFileInstaller::Parse(std::vector<std::string> const& args)
if(!this->Rename.empty()) if(!this->Rename.empty())
{ {
if(this->InstallType != cmTarget::INSTALL_FILES && if(this->InstallType != cmInstallType_FILES &&
this->InstallType != cmTarget::INSTALL_PROGRAMS) this->InstallType != cmInstallType_PROGRAMS)
{ {
this->FileCommand->SetError("INSTALL option RENAME may be used " this->FileCommand->SetError("INSTALL option RENAME may be used "
"only with FILES or PROGRAMS."); "only with FILES or PROGRAMS.");
@ -1936,31 +1937,31 @@ bool cmFileInstaller
{ {
if ( stype == "EXECUTABLE" ) if ( stype == "EXECUTABLE" )
{ {
this->InstallType = cmTarget::EXECUTABLE; this->InstallType = cmInstallType_EXECUTABLE;
} }
else if ( stype == "FILE" ) else if ( stype == "FILE" )
{ {
this->InstallType = cmTarget::INSTALL_FILES; this->InstallType = cmInstallType_FILES;
} }
else if ( stype == "PROGRAM" ) else if ( stype == "PROGRAM" )
{ {
this->InstallType = cmTarget::INSTALL_PROGRAMS; this->InstallType = cmInstallType_PROGRAMS;
} }
else if ( stype == "STATIC_LIBRARY" ) else if ( stype == "STATIC_LIBRARY" )
{ {
this->InstallType = cmTarget::STATIC_LIBRARY; this->InstallType = cmInstallType_STATIC_LIBRARY;
} }
else if ( stype == "SHARED_LIBRARY" ) else if ( stype == "SHARED_LIBRARY" )
{ {
this->InstallType = cmTarget::SHARED_LIBRARY; this->InstallType = cmInstallType_SHARED_LIBRARY;
} }
else if ( stype == "MODULE" ) else if ( stype == "MODULE" )
{ {
this->InstallType = cmTarget::MODULE_LIBRARY; this->InstallType = cmInstallType_MODULE_LIBRARY;
} }
else if ( stype == "DIRECTORY" ) else if ( stype == "DIRECTORY" )
{ {
this->InstallType = cmTarget::INSTALL_DIRECTORY; this->InstallType = cmInstallType_DIRECTORY;
} }
else else
{ {

View File

@ -42,7 +42,7 @@ cmInstallDirectoryGenerator::GenerateScriptActions(std::ostream& os,
{ {
// Write code to install the directories. // Write code to install the directories.
const char* no_rename = 0; const char* no_rename = 0;
this->AddInstallRule(os, cmTarget::INSTALL_DIRECTORY, this->AddInstallRule(os, cmInstallType_DIRECTORY,
this->Directories, this->Directories,
this->Optional, this->Optional,
this->FilePermissions.c_str(), this->FilePermissions.c_str(),

View File

@ -16,7 +16,6 @@
#include "cmake.h" #include "cmake.h"
#include "cmInstallTargetGenerator.h" #include "cmInstallTargetGenerator.h"
#include "cmGeneratedFileStream.h" #include "cmGeneratedFileStream.h"
#include "cmTarget.h"
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmLocalGenerator.h" #include "cmLocalGenerator.h"
#include "cmGlobalGenerator.h" #include "cmGlobalGenerator.h"
@ -186,7 +185,7 @@ cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
files.push_back(i->second); files.push_back(i->second);
std::string config_test = this->CreateConfigTest(i->first.c_str()); std::string config_test = this->CreateConfigTest(i->first.c_str());
os << indent << "IF(" << config_test << ")\n"; os << indent << "IF(" << config_test << ")\n";
this->AddInstallRule(os, cmTarget::INSTALL_FILES, files, false, this->AddInstallRule(os, cmInstallType_FILES, files, false,
this->FilePermissions.c_str(), 0, 0, 0, this->FilePermissions.c_str(), 0, 0, 0,
indent.Next()); indent.Next());
os << indent << "ENDIF(" << config_test << ")\n"; os << indent << "ENDIF(" << config_test << ")\n";
@ -225,6 +224,6 @@ void cmInstallExportGenerator::GenerateScriptActions(std::ostream& os,
// Install the main export file. // Install the main export file.
std::vector<std::string> files; std::vector<std::string> files;
files.push_back(this->MainImportFile); files.push_back(this->MainImportFile);
this->AddInstallRule(os, cmTarget::INSTALL_FILES, files, false, this->AddInstallRule(os, cmInstallType_FILES, files, false,
this->FilePermissions.c_str(), 0, 0, 0, indent); this->FilePermissions.c_str(), 0, 0, 0, indent);
} }

View File

@ -11,8 +11,6 @@
============================================================================*/ ============================================================================*/
#include "cmInstallFilesGenerator.h" #include "cmInstallFilesGenerator.h"
#include "cmTarget.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmInstallFilesGenerator cmInstallFilesGenerator
::cmInstallFilesGenerator(std::vector<std::string> const& files, ::cmInstallFilesGenerator(std::vector<std::string> const& files,
@ -43,8 +41,8 @@ void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
const char* no_dir_permissions = 0; const char* no_dir_permissions = 0;
this->AddInstallRule(os, this->AddInstallRule(os,
(this->Programs (this->Programs
? cmTarget::INSTALL_PROGRAMS ? cmInstallType_PROGRAMS
: cmTarget::INSTALL_FILES), : cmInstallType_FILES),
this->Files, this->Files,
this->Optional, this->Optional,
this->FilePermissions.c_str(), no_dir_permissions, this->FilePermissions.c_str(), no_dir_permissions,

View File

@ -12,7 +12,6 @@
#include "cmInstallGenerator.h" #include "cmInstallGenerator.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmTarget.h"
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmInstallGenerator cmInstallGenerator
@ -35,7 +34,7 @@ cmInstallGenerator
void cmInstallGenerator void cmInstallGenerator
::AddInstallRule( ::AddInstallRule(
std::ostream& os, std::ostream& os,
int type, cmInstallType type,
std::vector<std::string> const& files, std::vector<std::string> const& files,
bool optional /* = false */, bool optional /* = false */,
const char* permissions_file /* = 0 */, const char* permissions_file /* = 0 */,
@ -49,14 +48,13 @@ void cmInstallGenerator
std::string stype; std::string stype;
switch(type) switch(type)
{ {
case cmTarget::INSTALL_DIRECTORY:stype = "DIRECTORY"; break; case cmInstallType_DIRECTORY: stype = "DIRECTORY"; break;
case cmTarget::INSTALL_PROGRAMS: stype = "PROGRAM"; break; case cmInstallType_PROGRAMS: stype = "PROGRAM"; break;
case cmTarget::EXECUTABLE: stype = "EXECUTABLE"; break; case cmInstallType_EXECUTABLE: stype = "EXECUTABLE"; break;
case cmTarget::STATIC_LIBRARY: stype = "STATIC_LIBRARY"; break; case cmInstallType_STATIC_LIBRARY: stype = "STATIC_LIBRARY"; break;
case cmTarget::SHARED_LIBRARY: stype = "SHARED_LIBRARY"; break; case cmInstallType_SHARED_LIBRARY: stype = "SHARED_LIBRARY"; break;
case cmTarget::MODULE_LIBRARY: stype = "MODULE"; break; case cmInstallType_MODULE_LIBRARY: stype = "MODULE"; break;
case cmTarget::INSTALL_FILES: case cmInstallType_FILES: stype = "FILE"; break;
default: stype = "FILE"; break;
} }
os << indent; os << indent;
std::string dest = this->GetInstallDestination(); std::string dest = this->GetInstallDestination();

View File

@ -12,6 +12,7 @@
#ifndef cmInstallGenerator_h #ifndef cmInstallGenerator_h
#define cmInstallGenerator_h #define cmInstallGenerator_h
#include "cmInstallType.h"
#include "cmScriptGenerator.h" #include "cmScriptGenerator.h"
class cmLocalGenerator; class cmLocalGenerator;
@ -29,7 +30,7 @@ public:
virtual ~cmInstallGenerator(); virtual ~cmInstallGenerator();
void AddInstallRule( void AddInstallRule(
std::ostream& os, int type, std::ostream& os, cmInstallType type,
std::vector<std::string> const& files, std::vector<std::string> const& files,
bool optional = false, bool optional = false,
const char* permissions_file = 0, const char* permissions_file = 0,

View File

@ -82,8 +82,22 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
std::vector<std::string> filesFrom; std::vector<std::string> filesFrom;
std::vector<std::string> filesTo; std::vector<std::string> filesTo;
std::string literal_args; std::string literal_args;
cmTarget::TargetType type = this->Target->GetType(); cmTarget::TargetType targetType = this->Target->GetType();
if(type == cmTarget::EXECUTABLE) cmInstallType type = cmInstallType();
switch(targetType)
{
case cmTarget::EXECUTABLE: type = cmInstallType_EXECUTABLE; break;
case cmTarget::STATIC_LIBRARY: type = cmInstallType_STATIC_LIBRARY; break;
case cmTarget::SHARED_LIBRARY: type = cmInstallType_SHARED_LIBRARY; break;
case cmTarget::MODULE_LIBRARY: type = cmInstallType_MODULE_LIBRARY; break;
case cmTarget::UTILITY:
case cmTarget::GLOBAL_TARGET:
case cmTarget::UNKNOWN_LIBRARY:
this->Target->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR,
"cmInstallTargetGenerator created with non-installable target.");
return;
}
if(targetType == cmTarget::EXECUTABLE)
{ {
// There is a bug in cmInstallCommand if this fails. // There is a bug in cmInstallCommand if this fails.
assert(this->NamelinkMode == NamelinkModeNone); assert(this->NamelinkMode == NamelinkModeNone);
@ -110,7 +124,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
} }
// An import library looks like a static library. // An import library looks like a static library.
type = cmTarget::STATIC_LIBRARY; type = cmInstallType_STATIC_LIBRARY;
} }
else else
{ {
@ -121,7 +135,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
if(this->Target->IsAppBundleOnApple()) if(this->Target->IsAppBundleOnApple())
{ {
// Install the whole app bundle directory. // Install the whole app bundle directory.
type = cmTarget::INSTALL_DIRECTORY; type = cmInstallType_DIRECTORY;
literal_args += " USE_SOURCE_PERMISSIONS"; literal_args += " USE_SOURCE_PERMISSIONS";
from1 += ".app"; from1 += ".app";
@ -173,7 +187,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
} }
// An import library looks like a static library. // An import library looks like a static library.
type = cmTarget::STATIC_LIBRARY; type = cmInstallType_STATIC_LIBRARY;
} }
else if(this->Target->IsFrameworkOnApple()) else if(this->Target->IsFrameworkOnApple())
{ {
@ -181,7 +195,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
assert(this->NamelinkMode == NamelinkModeNone); assert(this->NamelinkMode == NamelinkModeNone);
// Install the whole framework directory. // Install the whole framework directory.
type = cmTarget::INSTALL_DIRECTORY; type = cmInstallType_DIRECTORY;
literal_args += " USE_SOURCE_PERMISSIONS"; literal_args += " USE_SOURCE_PERMISSIONS";
std::string from1 = fromDirConfig + targetName + ".framework"; std::string from1 = fromDirConfig + targetName + ".framework";

29
Source/cmInstallType.h Normal file
View File

@ -0,0 +1,29 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#ifndef cmInstallType_h
#define cmInstallType_h
/**
* Enumerate types known to file(INSTALL).
*/
enum cmInstallType
{
cmInstallType_EXECUTABLE,
cmInstallType_STATIC_LIBRARY,
cmInstallType_SHARED_LIBRARY,
cmInstallType_MODULE_LIBRARY,
cmInstallType_FILES,
cmInstallType_PROGRAMS,
cmInstallType_DIRECTORY
};
#endif

View File

@ -1916,10 +1916,6 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
// A utility target has no file on which to depend. This was listed // A utility target has no file on which to depend. This was listed
// only to get the target-level dependency. // only to get the target-level dependency.
return false; return false;
case cmTarget::INSTALL_FILES:
case cmTarget::INSTALL_PROGRAMS:
case cmTarget::INSTALL_DIRECTORY:
break;
} }
} }

View File

@ -43,12 +43,6 @@ const char* cmTarget::GetTargetTypeName(TargetType targetType)
return "UTILITY"; return "UTILITY";
case cmTarget::GLOBAL_TARGET: case cmTarget::GLOBAL_TARGET:
return "GLOBAL_TARGET"; return "GLOBAL_TARGET";
case cmTarget::INSTALL_FILES:
return "INSTALL_FILES";
case cmTarget::INSTALL_PROGRAMS:
return "INSTALL_PROGRAMS";
case cmTarget::INSTALL_DIRECTORY:
return "INSTALL_DIRECTORY";
case cmTarget::UNKNOWN_LIBRARY: case cmTarget::UNKNOWN_LIBRARY:
return "UNKNOWN_LIBRARY"; return "UNKNOWN_LIBRARY";
} }
@ -1184,16 +1178,6 @@ void cmTarget::DefineProperties(cmake *cm)
void cmTarget::SetType(TargetType type, const char* name) void cmTarget::SetType(TargetType type, const char* name)
{ {
this->Name = name; this->Name = name;
if(type == cmTarget::INSTALL_FILES ||
type == cmTarget::INSTALL_PROGRAMS ||
type == cmTarget::INSTALL_DIRECTORY)
{
this->Makefile->
IssueMessage(cmake::INTERNAL_ERROR,
"SetType called on cmTarget for INSTALL_FILES, "
"INSTALL_PROGRAMS, or INSTALL_DIRECTORY ");
return;
}
// only add dependency information for library targets // only add dependency information for library targets
this->TargetTypeValue = type; this->TargetTypeValue = type;
if(this->TargetTypeValue >= STATIC_LIBRARY if(this->TargetTypeValue >= STATIC_LIBRARY

View File

@ -60,7 +60,6 @@ public:
cmTarget(); cmTarget();
enum TargetType { EXECUTABLE, STATIC_LIBRARY, enum TargetType { EXECUTABLE, STATIC_LIBRARY,
SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET, SHARED_LIBRARY, MODULE_LIBRARY, UTILITY, GLOBAL_TARGET,
INSTALL_FILES, INSTALL_PROGRAMS, INSTALL_DIRECTORY,
UNKNOWN_LIBRARY}; UNKNOWN_LIBRARY};
static const char* GetTargetTypeName(TargetType targetType); static const char* GetTargetTypeName(TargetType targetType);
enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD }; enum CustomCommandType { PRE_BUILD, PRE_LINK, POST_BUILD };