Merge topic 'factor-install-type'

573fa3b Factor cmInstallType out of cmTarget::TargetType
This commit is contained in:
David Cole 2012-03-02 11:47:42 -05:00 committed by CMake Topic Stage
commit 881dc35579
13 changed files with 81 additions and 70 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -12,6 +12,7 @@
#ifndef cmInstallGenerator_h
#define cmInstallGenerator_h
#include "cmInstallType.h"
#include "cmScriptGenerator.h"
class cmLocalGenerator;
@ -29,7 +30,7 @@ public:
virtual ~cmInstallGenerator();
void AddInstallRule(
std::ostream& os, int type,
std::ostream& os, cmInstallType type,
std::vector<std::string> const& files,
bool optional = false,
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> filesTo;
std::string literal_args;
cmTarget::TargetType type = this->Target->GetType();
if(type == cmTarget::EXECUTABLE)
cmTarget::TargetType targetType = this->Target->GetType();
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.
assert(this->NamelinkMode == NamelinkModeNone);
@ -110,7 +124,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
}
// An import library looks like a static library.
type = cmTarget::STATIC_LIBRARY;
type = cmInstallType_STATIC_LIBRARY;
}
else
{
@ -121,7 +135,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
if(this->Target->IsAppBundleOnApple())
{
// Install the whole app bundle directory.
type = cmTarget::INSTALL_DIRECTORY;
type = cmInstallType_DIRECTORY;
literal_args += " USE_SOURCE_PERMISSIONS";
from1 += ".app";
@ -173,7 +187,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
}
// An import library looks like a static library.
type = cmTarget::STATIC_LIBRARY;
type = cmInstallType_STATIC_LIBRARY;
}
else if(this->Target->IsFrameworkOnApple())
{
@ -181,7 +195,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
assert(this->NamelinkMode == NamelinkModeNone);
// Install the whole framework directory.
type = cmTarget::INSTALL_DIRECTORY;
type = cmInstallType_DIRECTORY;
literal_args += " USE_SOURCE_PERMISSIONS";
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

@ -1909,10 +1909,6 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
// A utility target has no file on which to depend. This was listed
// only to get the target-level dependency.
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";
case cmTarget::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:
return "UNKNOWN_LIBRARY";
}
@ -1184,16 +1178,6 @@ void cmTarget::DefineProperties(cmake *cm)
void cmTarget::SetType(TargetType type, const char* 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
this->TargetTypeValue = type;
if(this->TargetTypeValue >= STATIC_LIBRARY

View File

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