ENH: first pass at VS 10, can bootstrap CMake, but many tests still fail

This commit is contained in:
Bill Hoffman 2009-06-25 16:41:57 -04:00
parent 953439f738
commit 7491f52992
24 changed files with 2591 additions and 47 deletions

View File

@ -10,9 +10,12 @@ ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 6")
INCLUDE (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake)
# Disable deprecation warnings for standard C functions.
IF(MSVC80 OR MSVC90)
# really only needed for newer versions of VS, but should
# not hurt other versions, and this will work into the
# future
IF(MSVC)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
ENDIF(MSVC80 OR MSVC90)
ENDIF(MSVC)
#silence duplicate symbol warnings on AIX
IF(CMAKE_SYSTEM MATCHES "AIX.*")

View File

@ -0,0 +1,31 @@
# VCExpress does not support cross compiling, which is necessary for Win CE
SET( _CMAKE_MAKE_PROGRAM_NAMES devenv)
IF(NOT CMAKE_CROSSCOMPILING)
SET( _CMAKE_MAKE_PROGRAM_NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} VCExpress)
ENDIF(NOT CMAKE_CROSSCOMPILING)
FIND_PROGRAM(CMAKE_MAKE_PROGRAM
NAMES ${_CMAKE_MAKE_PROGRAM_NAMES}
HINTS
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup\\VS;EnvironmentDirectory]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\10.0\\Setup;Dbghelp_path]
"$ENV{ProgramFiles}/Microsoft Visual Studio 10.0/Common7/IDE"
"$ENV{ProgramFiles}/Microsoft Visual Studio10.0/Common7/IDE"
"$ENV{ProgramFiles}/Microsoft Visual Studio 10/Common7/IDE"
"$ENV{ProgramFiles}/Microsoft Visual Studio10/Common7/IDE"
"$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 10.0/Common7/IDE"
"$ENV{ProgramFiles} (x86)/Microsoft Visual Studio10.0/Common7/IDE"
"$ENV{ProgramFiles} (x86)/Microsoft Visual Studio 10/Common7/IDE"
"$ENV{ProgramFiles} (x86)/Microsoft Visual Studio10/Common7/IDE"
"/Program Files/Microsoft Visual Studio 10.0/Common7/IDE/"
"/Program Files/Microsoft Visual Studio 10/Common7/IDE/"
PATHS
"$ENV{ProgramFiles} (x86)/Microsoft Visual Studio .NET/Common7/IDE"
"$ENV{ProgramFiles}/Microsoft Visual Studio .NET/Common7/IDE"
)
MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM)
SET(MSVC10 1)
SET(MSVC_VERSION 1600)

View File

@ -282,6 +282,14 @@ IF (WIN32)
cmGlobalVisualStudio8Win64Generator.h
cmGlobalVisualStudio9Win64Generator.cxx
cmGlobalVisualStudio9Win64Generator.h
cmVisualStudioGeneratorOptions.h
cmVisualStudioGeneratorOptions.cxx
cmVisualStudio10TargetGenerator.h
cmVisualStudio10TargetGenerator.cxx
cmLocalVisualStudio10Generator.cxx
cmLocalVisualStudio10Generator.h
cmGlobalVisualStudio10Generator.h
cmGlobalVisualStudio10Generator.cxx
cmGlobalVisualStudioGenerator.cxx
cmGlobalVisualStudioGenerator.h
cmGlobalWatcomWMakeGenerator.cxx

View File

@ -2068,9 +2068,14 @@ void cmGlobalGenerator::CheckRuleHashes()
#else
std::ifstream fin(pfile.c_str(), std::ios::in);
#endif
bool goodStream = true;
if(!fin)
{
goodStream = false;
}
std::string line;
std::string fname;
while(cmSystemTools::GetLineFromStream(fin, line))
while(goodStream && cmSystemTools::GetLineFromStream(fin, line))
{
// Line format is a 32-byte hex string followed by a space
// followed by a file name (with no escaping).

View File

@ -0,0 +1,98 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "windows.h" // this must be first to define GetCurrentDirectory
#include "cmGlobalVisualStudio10Generator.h"
#include "cmLocalVisualStudio10Generator.h"
#include "cmMakefile.h"
#include "cmake.h"
cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator()
{
this->FindMakeProgramFile = "CMakeVS10FindMake.cmake";
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator::AddPlatformDefinitions(cmMakefile* mf)
{
mf->AddDefinition("MSVC10", "1");
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator::WriteSLNHeader(std::ostream& fout)
{
fout << "Microsoft Visual Studio Solution File, Format Version 11.00\n";
fout << "# Visual Studio 10\n";
}
///! Create a local generator appropriate to this Global Generator
cmLocalGenerator *cmGlobalVisualStudio10Generator::CreateLocalGenerator()
{
cmLocalGenerator*lg = new cmLocalVisualStudio10Generator;
lg->SetGlobalGenerator(this);
return lg;
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator
::GetDocumentation(cmDocumentationEntry& entry) const
{
entry.Name = this->GetName();
entry.Brief = "Generates Visual Studio 10 project files.";
entry.Full = "";
}
//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator
::EnableLanguage(std::vector<std::string>const & lang,
cmMakefile *mf, bool optional)
{
cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio10Generator::GetUserMacrosDirectory()
{
std::string base;
std::string path;
// base begins with the VisualStudioProjectsLocation reg value...
if (cmSystemTools::ReadRegistryValue(
"HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\10.0;"
"VisualStudioProjectsLocation",
base))
{
cmSystemTools::ConvertToUnixSlashes(base);
// 9.0 macros folder:
path = base + "/VSMacros80";
// *NOT* a typo; right now in Visual Studio 2008 beta the macros
// folder is VSMacros80... They may change it to 90 before final
// release of 2008 or they may not... we'll have to keep our eyes
// on it
}
// path is (correctly) still empty if we did not read the base value from
// the Registry value
return path;
}
//----------------------------------------------------------------------------
std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase()
{
return "Software\\Microsoft\\VisualStudio\\10.0\\vsmacros";
}

View File

@ -0,0 +1,70 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmGlobalVisualStudio10Generator_h
#define cmGlobalVisualStudio10Generator_h
#include "cmGlobalVisualStudio8Generator.h"
/** \class cmGlobalVisualStudio10Generator
* \brief Write a Unix makefiles.
*
* cmGlobalVisualStudio10Generator manages UNIX build process for a tree
*/
class cmGlobalVisualStudio10Generator :
public cmGlobalVisualStudio8Generator
{
public:
cmGlobalVisualStudio10Generator();
static cmGlobalGenerator* New() {
return new cmGlobalVisualStudio10Generator; }
///! Get the name for the generator.
virtual const char* GetName() const {
return cmGlobalVisualStudio10Generator::GetActualName();}
static const char* GetActualName() {return "Visual Studio 10";}
virtual void AddPlatformDefinitions(cmMakefile* mf);
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry) const;
///! create the correct local generator
virtual cmLocalGenerator *CreateLocalGenerator();
/**
* Try to determine system infomation such as shared library
* extension, pthreads, byte order etc.
*/
virtual void EnableLanguage(std::vector<std::string>const& languages,
cmMakefile *, bool optional);
virtual void WriteSLNHeader(std::ostream& fout);
/**
* Where does this version of Visual Studio look for macros for the
* current user? Returns the empty string if this version of Visual
* Studio does not implement support for VB macros.
*/
virtual std::string GetUserMacrosDirectory();
/**
* What is the reg key path to "vsmacros" for this version of Visual
* Studio?
*/
virtual std::string GetUserMacrosRegKeyBase();
virtual const char* GetCMakeCFGInitDirectory() { return "$(ConfigurationName)";}
};
#endif

View File

@ -164,7 +164,12 @@ cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
ext = ".vfproj";
project = "Project(\"{6989167D-11E4-40FE-8C1A-2192A86A7E90}\") = \"";
}
const char* targetExt = t.GetProperty("GENERATOR_FILE_NAME_EXT");
if(targetExt)
{
ext = targetExt;
}
fout << project
<< dspname << "\", \""
<< this->ConvertToSolutionPath(dir)

View File

@ -2127,7 +2127,7 @@ static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
}
/* We need to extend the buffer. */
temp = malloc(newSize);
temp = (char*)malloc(newSize);
if(lexer->token.text)
{
memcpy(temp, lexer->token.text, lexer->token.length);

View File

@ -299,11 +299,11 @@ public:
void GenerateFrameworkInfoPList(cmTarget* target,
const char* targetName,
const char* fname);
protected:
/** Construct a comment for a custom command. */
std::string ConstructComment(const cmCustomCommand& cc,
const char* default_comment = "");
protected:
/** Fill out these strings for the given target. Libraries to link,
* flags, and linkflags. */
void GetTargetFlags(std::string& linkLibs,

View File

@ -0,0 +1,64 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmLocalVisualStudio10Generator.h"
#include "cmTarget.h"
#include "cmMakefile.h"
#include "cmVisualStudio10TargetGenerator.h"
#include "cmGlobalVisualStudio7Generator.h"
//----------------------------------------------------------------------------
cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator()
{
}
cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator()
{
}
void cmLocalVisualStudio10Generator::Generate()
{
cmTargets &tgts = this->Makefile->GetTargets();
// Create the regeneration custom rule.
if(!this->Makefile->IsOn("CMAKE_SUPPRESS_REGENERATION"))
{
// Create a rule to regenerate the build system when the target
// specification source changes.
if(cmSourceFile* sf = this->CreateVCProjBuildRule())
{
// Add the rule to targets that need it.
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l)
{
if(l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
{
l->second.AddSourceFile(sf);
}
}
}
}
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); ++l)
{
cmVisualStudio10TargetGenerator tg(&l->second,
(cmGlobalVisualStudio7Generator*)
this->GetGlobalGenerator());
tg.Generate();
}
this->WriteStampFiles();
}

View File

@ -0,0 +1,45 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmLocalVisualStudio10Generator_h
#define cmLocalVisualStudio10Generator_h
#include "cmLocalVisualStudio7Generator.h"
/** \class cmLocalVisualStudio10Generator
* \brief Write Visual Studio 10 project files.
*
* cmLocalVisualStudio10Generator produces a Visual Studio 10 project
* file for each target in its directory.
*/
class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator
{
public:
///! Set cache only and recurse to false by default.
cmLocalVisualStudio10Generator();
virtual ~cmLocalVisualStudio10Generator();
/**
* Generate the makefile for this directory.
*/
virtual void Generate();
private:
};
#endif

View File

@ -18,12 +18,13 @@
#define cmLocalVisualStudio7Generator_h
#include "cmLocalVisualStudioGenerator.h"
#include "cmVisualStudioGeneratorOptions.h" // to get cmVS7FlagTable
class cmTarget;
class cmSourceFile;
class cmCustomCommand;
class cmSourceGroup;
struct cmVS7FlagTable;
class cmLocalVisualStudio7GeneratorOptions;
class cmLocalVisualStudio7GeneratorFCInfo;
@ -68,6 +69,10 @@ public:
void SetExtraFlagTable(cmVS7FlagTable const* table)
{ this->ExtraFlagTable = table; }
virtual std::string GetTargetDirectory(cmTarget const&) const;
cmSourceFile* CreateVCProjBuildRule();
void WriteStampFiles();
private:
typedef cmLocalVisualStudio7GeneratorOptions Options;
typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo;
@ -77,14 +82,12 @@ private:
const char* configName);
void FixGlobalTargets();
void WriteProjectFiles();
void WriteStampFiles();
void WriteVCProjHeader(std::ostream& fout, const char *libName,
cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
void WriteVCProjFooter(std::ostream& fout);
void CreateSingleVCProj(const char *lname, cmTarget &tgt);
void WriteVCProjFile(std::ostream& fout, const char *libName,
cmTarget &tgt);
cmSourceFile* CreateVCProjBuildRule();
void WriteConfigurations(std::ostream& fout,
const char *libName, cmTarget &tgt);
void WriteConfiguration(std::ostream& fout,
@ -118,7 +121,6 @@ private:
void WriteGroup(const cmSourceGroup *sg,
cmTarget& target, std::ostream &fout,
const char *libName, std::vector<std::string> *configs);
virtual std::string GetTargetDirectory(cmTarget const&) const;
friend class cmLocalVisualStudio7GeneratorFCInfo;
friend class cmLocalVisualStudio7GeneratorInternals;
@ -134,30 +136,6 @@ private:
cmLocalVisualStudio7GeneratorInternals* Internal;
};
// This is a table mapping XML tag IDE names to command line options
struct cmVS7FlagTable
{
const char* IDEName; // name used in the IDE xml file
const char* commandFlag; // command line flag
const char* comment; // comment
const char* value; // string value
unsigned int special; // flags for special handling requests
enum
{
UserValue = (1<<0), // flag contains a user-specified value
UserIgnored = (1<<1), // ignore any user value
UserRequired = (1<<2), // match only when user value is non-empty
Continue = (1<<3), // continue looking for matching entries
SemicolonAppendable = (1<<4), // a flag that if specified multiple times
// should have its value appended to the
// old value with semicolons (e.g.
// /NODEFAULTLIB: =>
// IgnoreDefaultLibraryNames)
UserValueIgnored = UserValue | UserIgnored,
UserValueRequired = UserValue | UserRequired
};
};
#endif

View File

@ -35,12 +35,6 @@ class cmLocalVisualStudioGenerator : public cmLocalGenerator
public:
cmLocalVisualStudioGenerator();
virtual ~cmLocalVisualStudioGenerator();
protected:
/** Construct a custom command to make exe import lib dir. */
cmsys::auto_ptr<cmCustomCommand>
MaybeCreateImplibDir(cmTarget& target, const char* config);
/** Construct a script from the given list of command lines. */
std::string ConstructScript(const cmCustomCommandLines& commandLines,
const char* workingDirectory,
@ -49,6 +43,12 @@ protected:
bool escapeAllowMakeVars,
const char* newline = "\n");
protected:
/** Construct a custom command to make exe import lib dir. */
cmsys::auto_ptr<cmCustomCommand>
MaybeCreateImplibDir(cmTarget& target, const char* config);
// Safe object file name generation.
void ComputeObjectNameRequirements(std::vector<cmSourceGroup> const&);
bool SourceFileCompiles(const cmSourceFile* sf);

View File

@ -897,7 +897,6 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
// Construct a rule file associated with the first output produced.
std::string outName = outputs[0];
outName += ".rule";
// Check if the rule file already exists.
file = this->GetSource(outName.c_str());
if(file && file->GetCustomCommand() && !replace)
@ -2715,7 +2714,8 @@ void cmMakefile::EnableLanguage(std::vector<std::string> const & lang,
bool optional)
{
this->AddDefinition("CMAKE_CFG_INTDIR",
this->LocalGenerator->GetGlobalGenerator()->GetCMakeCFGInitDirectory());
this->LocalGenerator->GetGlobalGenerator()
->GetCMakeCFGInitDirectory());
this->LocalGenerator->GetGlobalGenerator()->EnableLanguage(lang, this,
optional);
}

152
Source/cmVS10CLFlagTable.h Normal file
View File

@ -0,0 +1,152 @@
static cmVS7FlagTable cmVS10CLFlagTable[] =
{
//Enum Properties
{"DebugInformationFormat", "Z7", "C7 compatible", "OldStyle", 0},
{"DebugInformationFormat", "Zi", "Program Database", "ProgramDatabase", 0},
{"DebugInformationFormat", "ZI", "Program Database for Edit And Continue", "EditAndContinue", 0},
{"WarningLevel", "W0", "Turn Off All Warnings", "TurnOffAllWarnings", 0},
{"WarningLevel", "W1", "Level1", "Level1", 0},
{"WarningLevel", "W2", "Level2", "Level2", 0},
{"WarningLevel", "W3", "Level3", "Level3", 0},
{"WarningLevel", "W4", "Level4", "Level4", 0},
{"WarningLevel", "Wall", "EnableAllWarnings", "EnableAllWarnings", 0},
{"Optimization", "Od", "Disabled", "Disabled", 0},
{"Optimization", "O1", "Minimize Size", "MinSpace", 0},
{"Optimization", "O2", "Maximize Speed", "MaxSpeed", 0},
{"Optimization", "Ox", "Full Optimization", "Full", 0},
{"InlineFunctionExpansion", "", "Default", "Default", 0},
{"InlineFunctionExpansion", "Ob0", "Disabled", "Disabled", 0},
{"InlineFunctionExpansion", "Ob1", "Only __inline", "OnlyExplicitInline", 0},
{"InlineFunctionExpansion", "Ob2", "Any Suitable", "AnySuitable", 0},
{"FavorSizeOrSpeed", "Os", "Favor small code", "Size", 0},
{"FavorSizeOrSpeed", "Ot", "Favor fast code", "Speed", 0},
{"FavorSizeOrSpeed", "", "Neither", "Neither", 0},
{"ExceptionHandling", "EHa", "Yes with SEH Exceptions", "Async", 0},
{"ExceptionHandling", "EHsc", "Yes", "Sync", 0},
{"ExceptionHandling", "EHs", "Yes with Extern C functions", "SyncCThrow", 0},
{"ExceptionHandling", "", "No", "false", 0},
{"BasicRuntimeChecks", "RTCs", "Stack Frames", "StackFrameRuntimeCheck", 0},
{"BasicRuntimeChecks", "RTCu", "Uninitialized variables", "UninitializedLocalUsageCheck", 0},
{"BasicRuntimeChecks", "RTC1", "Both (/RTC1, equiv. to /RTCsu)", "EnableFastChecks", 0},
{"BasicRuntimeChecks", "", "Default", "Default", 0},
{"RuntimeLibrary", "MT", "Multi-threaded", "MultiThreaded", 0},
{"RuntimeLibrary", "MTd", "Multi-threaded Debug", "MultiThreadedDebug", 0},
{"RuntimeLibrary", "MD", "Multi-threaded DLL", "MultiThreadedDLL", 0},
{"RuntimeLibrary", "MDd", "Multi-threaded Debug DLL", "MultiThreadedDebugDLL", 0},
{"StructMemberAlignment", "Zp1", "1 Byte", "1Byte", 0},
{"StructMemberAlignment", "Zp2", "2 Bytes", "2Bytes", 0},
{"StructMemberAlignment", "Zp4", "4 Byte", "4Bytes", 0},
{"StructMemberAlignment", "Zp8", "8 Bytes", "8Bytes", 0},
{"StructMemberAlignment", "Zp16", "16 Bytes", "16Bytes", 0},
{"StructMemberAlignment", "", "Default", "Default", 0},
{"EnableEnhancedInstructionSet", "arch:SSE", "Streaming SIMD Extensions (/arch:SSE)", "StreamingSIMDExtensions", 0},
{"EnableEnhancedInstructionSet", "arch:SSE2", "Streaming SIMD Extensions 2 (/arch:SSE2)", "StreamingSIMDExtensions2", 0},
{"EnableEnhancedInstructionSet", "", "Not Set", "NotSet", 0},
{"FloatingPointModel", "fp:precise", "Precise", "Precise", 0},
{"FloatingPointModel", "fp:strict", "Strict", "Strict", 0},
{"FloatingPointModel", "fp:fast", "Fast", "Fast", 0},
{"PrecompiledHeader", "Yc", "Create", "Create", 0},
{"PrecompiledHeader", "Yu", "Use", "Use", 0},
{"PrecompiledHeader", "", "Not Using Precompiled Headers", "NotUsing", 0},
{"AssemblerOutput", "", "No Listing", "NoListing", 0},
{"AssemblerOutput", "FA", "Assembly-Only Listing", "AssemblyCode", 0},
{"AssemblerOutput", "FAc", "Assembly With Machine Code", "AssemblyAndMachineCode", 0},
{"AssemblerOutput", "FAs", "Assembly With Source Code", "AssemblyAndSourceCode", 0},
{"AssemblerOutput", "FAcs", "Assembly, Machine Code and Source", "All", 0},
{"CallingConvention", "Gd", "__cdecl", "Cdecl", 0},
{"CallingConvention", "Gr", "__fastcall", "FastCall", 0},
{"CallingConvention", "Gz", "__stdcall", "StdCall", 0},
{"CompileAs", "", "Default", "Default", 0},
{"CompileAs", "TC", "Compile as C Code", "CompileAsC", 0},
{"CompileAs", "TP", "Compile as C++ Code", "CompileAsCpp", 0},
{"ErrorReporting", "errorReport:none", "Do Not Send Report", "None", 0},
{"ErrorReporting", "errorReport:prompt", "Prompt Immediatelly", "Prompt", 0},
{"ErrorReporting", "errorReport:queue", "Queue For Next Login", "Queue", 0},
{"ErrorReporting", "errorReport:send", "Send Automatically", "Send", 0},
{"CompileAsManaged", "", "No Common Language RunTime Support", "false", 0},
{"CompileAsManaged", "clr", "Common Language RunTime Support", "true", 0},
{"CompileAsManaged", "clr:pure", "Pure MSIL Common Language RunTime Support", "Pure", 0},
{"CompileAsManaged", "clr:safe", "Safe MSIL Common Language RunTime Support", "Safe", 0},
{"CompileAsManaged", "clr:oldSyntax", "Common Language RunTime Support, Old Syntax", "OldSyntax", 0},
//Bool Properties
{"SuppressStartupBanner", "nologo-", "", "false", 0},
{"SuppressStartupBanner", "nologo", "", "true", 0},
{"TreatWarningAsError", "WX-", "", "false", 0},
{"TreatWarningAsError", "WX", "", "true", 0},
{"IntrinsicFunctions", "Oi", "", "true", 0},
{"OmitFramePointers", "Oy-", "", "false", 0},
{"OmitFramePointers", "Oy", "", "true", 0},
{"EnableFiberSafeOptimizations", "GT", "", "true", 0},
{"WholeProgramOptimization", "GL", "", "true", 0},
{"UndefineAllPreprocessorDefinitions", "u", "", "true", 0},
{"IgnoreStandardIncludePath", "X", "", "true", 0},
{"PreprocessToFile", "P", "", "true", 0},
{"PreprocessSuppressLineNumbers", "EP", "", "true", 0},
{"PreprocessKeepComments", "C", "", "true", 0},
{"StringPooling", "GF-", "", "false", 0},
{"StringPooling", "GF", "", "true", 0},
{"MinimalRebuild", "Gm-", "", "false", 0},
{"MinimalRebuild", "Gm", "", "true", 0},
{"SmallerTypeCheck", "RTCc", "", "true", 0},
{"BufferSecurityCheck", "GS-", "", "false", 0},
{"BufferSecurityCheck", "GS", "", "true", 0},
{"FunctionLevelLinking", "Gy-", "", "false", 0},
{"FunctionLevelLinking", "Gy", "", "true", 0},
{"FloatingPointExceptions", "fp:except-", "", "false", 0},
{"FloatingPointExceptions", "fp:except", "", "true", 0},
{"CodeGeneration", "hotpatch", "", "true", 0},
{"DisableLanguageExtensions", "Za", "", "true", 0},
{"TreatWChar_tAsBuiltInType", "Zc:wchar_t-", "", "false", 0},
{"TreatWChar_tAsBuiltInType", "Zc:wchar_t", "", "true", 0},
{"ForceConformanceInForLoopScope", "Zc:forScope-", "", "false", 0},
{"ForceConformanceInForLoopScope", "Zc:forScope", "", "true", 0},
{"RuntimeTypeInfo", "GR-", "", "false", 0},
{"RuntimeTypeInfo", "GR", "", "true", 0},
{"OpenMPSupport", "openmp-", "", "false", 0},
{"OpenMPSupport", "openmp", "", "true", 0},
{"ExpandAttributedSource", "Fx", "", "true", 0},
{"ShowIncludes", "showIncludes", "", "true", 0},
{"EnablePREfast", "analyze-", "", "false", 0},
{"EnablePREfast", "analyze", "", "true", 0},
{"UseFullPaths", "FC", "", "true", 0},
{"OmitDefaultLibName", "Zl", "", "true", 0},
{"UseUnicodeForAssemblerListing", "FAu", "", "true", 0},
//Bool Properties With Argument
{"MultiProcessorCompilation", "MP", "", "true", cmVS7FlagTable::Continue},
{"ProcessorNumber", "MP", "Multi-processor Compilation", "", cmVS7FlagTable::UserValueRequired},
{"GenerateXMLDocumentationFiles", "doc", "", "true", cmVS7FlagTable::Continue},
{"XMLDocumentationFileName", "doc", "Generate XML Documentation Files", "", cmVS7FlagTable::UserValueRequired},
{"BrowseInformation", "FR", "", "true", cmVS7FlagTable::Continue},
{"BrowseInformationFile", "FR", "Enable Browse Information", "", cmVS7FlagTable::UserValueRequired},
//String List Properties
{"AdditionalIncludeDirectories", "I", "Additional Include Directories", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"AdditionalUsingDirectories", "AI", "Resolve #using References", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"PreprocessorDefinitions", "D ", "Preprocessor Definitions", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"UndefinePreprocessorDefinitions", "U", "Undefine Preprocessor Definitions", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"DisableSpecificWarnings", "wd", "Disable Specific Warnings", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"ForcedIncludeFiles", "FI", "Forced Include File", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"ForcedUsingFiles", "FU", "Forced #using File", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"TreatSpecificWarningsAsErrors", "we", "Treat Specific Warnings As Errors", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{0,0,0,0,0}
};

View File

@ -0,0 +1,50 @@
static cmVS7FlagTable cmVS10LibFlagTable[] =
{
//Enum Properties
{"ErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately", "PromptImmediately", 0},
{"ErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login", "QueueForNextLogin", 0},
{"ErrorReporting", "ERRORREPORT:SEND", "Send Error Report", "SendErrorReport", 0},
{"ErrorReporting", "ERRORREPORT:NONE", "No Error Report", "NoErrorReport", 0},
{"TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0},
{"TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0},
{"TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0},
{"TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0},
{"TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0},
{"TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU", 0},
{"TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16", "MachineMIPSFPU16", 0},
{"TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0},
{"TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0},
{"TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0},
{"TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0},
{"SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0},
{"SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0},
{"SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0},
{"SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application", "EFI Application", 0},
{"SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER", "EFI Boot Service Driver", "EFI Boot Service Driver", 0},
{"SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0},
{"SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime", 0},
{"SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0},
{"SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0},
//Bool Properties
{"SuppressStartupBanner", "NOLOGO", "", "true", 0},
{"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0},
{"TreatLibWarningAsErrors", "WX:NO", "", "false", 0},
{"TreatLibWarningAsErrors", "WX", "", "true", 0},
{"Verbose", "VERBOSE", "", "true", 0},
{"LinkTimeCodeGeneration", "LTCG", "", "true", 0},
//Bool Properties With Argument
//String List Properties
{"AdditionalDependencies", "", "Additional Dependencies", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"AdditionalLibraryDirectories", "LIBPATH:", "Additional Library Directories", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:", "Ignore Specific Default Libraries", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"ExportNamedFunctions", "EXPORT:", "Export Named Functions", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"RemoveObjects", "REMOVE:", "Remove Objects", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{0,0,0,0,0}
};

View File

@ -0,0 +1,150 @@
static cmVS7FlagTable cmVS10LinkFlagTable[] =
{
//Enum Properties
{"ShowProgress", "", "Not Set", "NotSet", 0},
{"ShowProgress", "VERBOSE", "Display all progress messages", "LinkVerbose", 0},
{"ShowProgress", "VERBOSE:Lib", "For Libraries Searched", "LinkVerboseLib", 0},
{"ShowProgress", "VERBOSE:ICF", "About COMDAT folding during optimized linking", "LinkVerboseICF", 0},
{"ShowProgress", "VERBOSE:REF", "About data removed during optimized linking", "LinkVerboseREF", 0},
{"ShowProgress", "VERBOSE:SAFESEH", "About Modules incompatible with SEH", "LinkVerboseSAFESEH", 0},
{"ShowProgress", "VERBOSE:CLR", "About linker activity related to managed code", "LinkVerboseCLR", 0},
{"ForceFileOutput", "FORCE", "Enabled", "Enabled", 0},
{"ForceFileOutput", "FORCE:MULTIPLE", "Multiply Defined Symbol Only", "MultiplyDefinedSymbolOnly", 0},
{"ForceFileOutput", "FORCE:UNRESOLVED", "Undefined Symbol Only", "UndefinedSymbolOnly", 0},
{"CreateHotPatchableImage", "FUNCTIONPADMIN", "Enabled", "Enabled", 0},
{"CreateHotPatchableImage", "FUNCTIONPADMIN:5", "X86 Image Only", "X86Image", 0},
{"CreateHotPatchableImage", "FUNCTIONPADMIN:6", "X64 Image Only", "X64Image", 0},
{"CreateHotPatchableImage", "FUNCTIONPADMIN:16", "Itanium Image Only", "ItaniumImage", 0},
{"UACExecutionLevel", "level='asInvoker'", "asInvoker", "AsInvoker", 0},
{"UACExecutionLevel", "level='highestAvailable'", "highestAvailable", "HighestAvailable", 0},
{"UACExecutionLevel", "level='requireAdministrator'", "requireAdministrator", "RequireAdministrator", 0},
{"SubSystem", "", "Not Set", "NotSet", 0},
{"SubSystem", "SUBSYSTEM:CONSOLE", "Console", "Console", 0},
{"SubSystem", "SUBSYSTEM:WINDOWS", "Windows", "Windows", 0},
{"SubSystem", "SUBSYSTEM:NATIVE", "Native", "Native", 0},
{"SubSystem", "SUBSYSTEM:EFI_APPLICATION", "EFI Application", "EFI Application", 0},
{"SubSystem", "SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER", "EFI Boot Service Driver", "EFI Boot Service Driver", 0},
{"SubSystem", "SUBSYSTEM:EFI_ROM", "EFI ROM", "EFI ROM", 0},
{"SubSystem", "SUBSYSTEM:EFI_RUNTIME_DRIVER", "EFI Runtime", "EFI Runtime", 0},
{"SubSystem", "SUBSYSTEM:WINDOWSCE", "WindowsCE", "WindowsCE", 0},
{"SubSystem", "SUBSYSTEM:POSIX", "POSIX", "POSIX", 0},
{"Driver", "", "Not Set", "NotSet", 0},
{"Driver", "Driver", "Driver", "Driver", 0},
{"Driver", "DRIVER:UPONLY", "UP Only", "UpOnly", 0},
{"Driver", "DRIVER:WDM", "WDM", "WDM", 0},
{"LinkTimeCodeGeneration", "", "Default", "Default", 0},
{"LinkTimeCodeGeneration", "LTCG", "Use Link Time Code Generation", "UseLinkTimeCodeGeneration", 0},
{"LinkTimeCodeGeneration", "LTCG:PGInstrument", "Profile Guided Optimization - Instrument", "PGInstrument", 0},
{"LinkTimeCodeGeneration", "LTCG:PGOptimize", "Profile Guided Optimization - Optimization", "PGOptimization", 0},
{"LinkTimeCodeGeneration", "LTCG:PGUpdate", "Profile Guided Optimization - Update", "PGUpdate", 0},
{"TargetMachine", "", "Not Set", "NotSet", 0},
{"TargetMachine", "MACHINE:ARM", "MachineARM", "MachineARM", 0},
{"TargetMachine", "MACHINE:EBC", "MachineEBC", "MachineEBC", 0},
{"TargetMachine", "MACHINE:IA64", "MachineIA64", "MachineIA64", 0},
{"TargetMachine", "MACHINE:MIPS", "MachineMIPS", "MachineMIPS", 0},
{"TargetMachine", "MACHINE:MIPS16", "MachineMIPS16", "MachineMIPS16", 0},
{"TargetMachine", "MACHINE:MIPSFPU", "MachineMIPSFPU", "MachineMIPSFPU", 0},
{"TargetMachine", "MACHINE:MIPSFPU16", "MachineMIPSFPU16", "MachineMIPSFPU16", 0},
{"TargetMachine", "MACHINE:SH4", "MachineSH4", "MachineSH4", 0},
{"TargetMachine", "MACHINE:THUMB", "MachineTHUMB", "MachineTHUMB", 0},
{"TargetMachine", "MACHINE:X64", "MachineX64", "MachineX64", 0},
{"TargetMachine", "MACHINE:X86", "MachineX86", "MachineX86", 0},
{"CLRThreadAttribute", "CLRTHREADATTRIBUTE:MTA", "MTA threading attribute", "MTAThreadingAttribute", 0},
{"CLRThreadAttribute", "CLRTHREADATTRIBUTE:STA", "STA threading attribute", "STAThreadingAttribute", 0},
{"CLRThreadAttribute", "CLRTHREADATTRIBUTE:NONE", "Default threading attribute", "DefaultThreadingAttribute", 0},
{"CLRImageType", "CLRIMAGETYPE:IJW", "Force IJW image", "ForceIJWImage", 0},
{"CLRImageType", "CLRIMAGETYPE:PURE", "Force Pure IL Image", "ForcePureILImage", 0},
{"CLRImageType", "CLRIMAGETYPE:SAFE", "Force Safe IL Image", "ForceSafeILImage", 0},
{"CLRImageType", "", "Default image type", "Default", 0},
{"LinkErrorReporting", "ERRORREPORT:PROMPT", "PromptImmediately", "PromptImmediately", 0},
{"LinkErrorReporting", "ERRORREPORT:QUEUE", "Queue For Next Login", "QueueForNextLogin", 0},
{"LinkErrorReporting", "ERRORREPORT:SEND", "Send Error Report", "SendErrorReport", 0},
{"LinkErrorReporting", "ERRORREPORT:NONE", "No Error Report", "NoErrorReport", 0},
{"CLRSupportLastError", "CLRSupportLastError", "Enabled", "Enabled", 0},
{"CLRSupportLastError", "CLRSupportLastError:NO", "Disabled", "Disabled", 0},
{"CLRSupportLastError", "CLRSupportLastError:SYSTEMDLL", "System Dlls Only", "SystemDlls", 0},
//Bool Properties
{"LinkIncremental", "INCREMENTAL:NO", "", "false", 0},
{"LinkIncremental", "INCREMENTAL", "", "true", 0},
{"SuppressStartupBanner", "NOLOGO", "", "true", 0},
{"LinkStatus", "LTCG:NOSTATUS", "", "false", 0},
{"LinkStatus", "LTCG:STATUS", "", "true", 0},
{"PreventDllBinding", "ALLOWBIND:NO", "", "false", 0},
{"PreventDllBinding", "ALLOWBIND", "", "true", 0},
{"TreatLinkerWarningAsErrors", "WX:NO", "", "false", 0},
{"TreatLinkerWarningAsErrors", "WX", "", "true", 0},
{"IgnoreAllDefaultLibraries", "NODEFAULTLIB", "", "true", 0},
{"GenerateManifest", "MANIFEST:NO", "", "false", 0},
{"GenerateManifest", "MANIFEST", "", "true", 0},
{"AllowIsolation", "ALLOWISOLATION:NO", "", "false", 0},
{"UACUIAccess", "uiAccess='false'", "", "false", 0},
{"UACUIAccess", "uiAccess='true'", "", "true", 0},
{"GenerateDebugInformation", "DEBUG", "", "true", 0},
{"MapExports", "MAPINFO:EXPORTS", "", "true", 0},
{"AssemblyDebug", "ASSEMBLYDEBUG:DISABLE", "", "false", 0},
{"AssemblyDebug", "ASSEMBLYDEBUG", "", "true", 0},
{"LargeAddressAware", "LARGEADDRESSAWARE:NO", "", "false", 0},
{"LargeAddressAware", "LARGEADDRESSAWARE", "", "true", 0},
{"TerminalServerAware", "TSAWARE:NO", "", "false", 0},
{"TerminalServerAware", "TSAWARE", "", "true", 0},
{"SwapRunFromCD", "SWAPRUN:CD", "", "true", 0},
{"SwapRunFromNET", "SWAPRUN:NET", "", "true", 0},
{"OptimizeReferences", "OPT:NOREF", "", "false", 0},
{"OptimizeReferences", "OPT:REF", "", "true", 0},
{"EnableCOMDATFolding", "OPT:NOICF", "", "false", 0},
{"EnableCOMDATFolding", "OPT:ICF", "", "true", 0},
{"IgnoreEmbeddedIDL", "IGNOREIDL", "", "true", 0},
{"NoEntryPoint", "NOENTRY", "", "true", 0},
{"SetChecksum", "RELEASE", "", "true", 0},
{"RandomizedBaseAddress", "DYNAMICBASE:NO", "", "false", 0},
{"RandomizedBaseAddress", "DYNAMICBASE", "", "true", 0},
{"FixedBaseAddress", "FIXED:NO", "", "false", 0},
{"FixedBaseAddress", "FIXED", "", "true", 0},
{"DataExecutionPrevention", "NXCOMPAT:NO", "", "false", 0},
{"DataExecutionPrevention", "NXCOMPAT", "", "true", 0},
{"TurnOffAssemblyGeneration", "NOASSEMBLY", "", "true", 0},
{"SupportUnloadOfDelayLoadedDLL", "DELAY:UNLOAD", "", "true", 0},
{"SupportNobindOfDelayLoadedDLL", "DELAY:NOBIND", "", "true", 0},
{"Profile", "PROFILE", "", "true", 0},
{"DelaySign", "DELAYSIGN:NO", "", "false", 0},
{"DelaySign", "DELAYSIGN", "", "true", 0},
{"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK:NO", "", "false", 0},
{"CLRUnmanagedCodeCheck", "CLRUNMANAGEDCODECHECK", "", "true", 0},
{"ImageHasSafeExceptionHandlers", "SAFESEH:NO", "", "false", 0},
{"ImageHasSafeExceptionHandlers", "SAFESEH", "", "true", 0},
{"LinkDLL", "DLL", "", "true", 0},
//Bool Properties With Argument
{"EnableUAC", "MANIFESTUAC:NO", "", "false", cmVS7FlagTable::Continue},
{"EnableUAC", "MANIFESTUAC:NO", "Enable User Account Control (UAC)", "", cmVS7FlagTable::UserValueRequired},
{"EnableUAC", "MANIFESTUAC:", "", "true", cmVS7FlagTable::Continue},
{"UACUIAccess", "MANIFESTUAC:", "Enable User Account Control (UAC)", "", cmVS7FlagTable::UserValueRequired},
{"GenerateMapFile", "MAP", "", "true", cmVS7FlagTable::Continue},
{"MapFileName", "MAP", "Generate Map File", "", cmVS7FlagTable::UserValueRequired},
//String List Properties
{"AdditionalLibraryDirectories", "LIBPATH:", "Additional Library Directories", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
// {"AdditionalDependencies", "", "Additional Dependencies", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"IgnoreSpecificDefaultLibraries", "NODEFAULTLIB:", "Ignore Specific Default Libraries", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"AddModuleNamesToAssembly", "ASSEMBLYMODULE:", "Add Module to Assembly", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"EmbedManagedResourceFile", "ASSEMBLYRESOURCE:", "Embed Managed Resource File", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"ForceSymbolReferences", "INCLUDE:", "Force Symbol References", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"DelayLoadDLLs", "DELAYLOAD:", "Delay Loaded Dlls", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"AssemblyLinkResource", "ASSEMBLYLINKRESOURCE:", "Assembly Link Resource", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{"AdditionalManifestDependencies", "MANIFESTDEPENDENCY:", "Additional Manifest Dependencies", "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
{0,0,0,0,0}
};

View File

@ -0,0 +1,965 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#include "cmVisualStudio10TargetGenerator.h"
#include "cmGlobalVisualStudio7Generator.h"
#include "cmTarget.h"
#include "cmComputeLinkInformation.h"
#include "cmGeneratedFileStream.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmVisualStudioGeneratorOptions.h"
#include "cmLocalVisualStudio7Generator.h"
#include "cmVS10CLFlagTable.h"
#include "cmVS10LinkFlagTable.h"
cmVisualStudio10TargetGenerator::
cmVisualStudio10TargetGenerator(cmTarget* target,
cmGlobalVisualStudio7Generator* gg)
{
this->GlobalGenerator = gg;
this->GlobalGenerator->CreateGUID(target->GetName());
this->GUID = this->GlobalGenerator->GetGUID(target->GetName());
this->Target = target;
this->Makefile = target->GetMakefile();
this->LocalGenerator =
(cmLocalVisualStudio7Generator*)
this->Makefile->GetLocalGenerator();
this->Platform = "|Win32";
}
cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
{
delete this->BuildFileStream;
}
void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
const char* tag,
const char* config,
int indentLevel,
const char* attribute,
const char* end,
std::ostream* stream)
{
if(!stream)
{
stream = this->BuildFileStream;
}
stream->fill(' ');
stream->width(indentLevel*2 );
(*stream ) << "";
(*stream ) << "<" << tag
<< " Condition=\"'$(Configuration)|$(Platform)'=='";
(*stream ) << config << this->Platform << "'\"";
if(attribute)
{
(*stream ) << attribute;
}
// close the tag
(*stream ) << ">";
if(end)
{
(*stream ) << end;
}
}
void cmVisualStudio10TargetGenerator::WriteString(const char* line,
int indentLevel)
{
this->BuildFileStream->fill(' ');
this->BuildFileStream->width(indentLevel*2 );
// write an empty string to get the fill level indent to print
(*this->BuildFileStream ) << "";
(*this->BuildFileStream ) << line;
}
void cmVisualStudio10TargetGenerator::Generate()
{
// Tell the global generator the name of the project file
this->Target->SetProperty("GENERATOR_FILE_NAME",this->Target->GetName());
this->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
".vcxproj");
cmMakefile* mf = this->Target->GetMakefile();
std::string path = mf->GetStartOutputDirectory();
path += "/";
path += this->Target->GetName();
path += ".vcxproj";
this->BuildFileStream =
new cmGeneratedFileStream(path.c_str());
this->BuildFileStream->SetCopyIfDifferent(true);
// Write the encoding header into the file
char magic[] = {0xEF,0xBB, 0xBF};
this->BuildFileStream->write(magic, 3);
this->WriteString("<Project DefaultTargets=\"Build\" "
"ToolsVersion=\"4.0\" "
"xmlns=\"http://schemas.microsoft.com/"
"developer/msbuild/2003\">\n",
0);
this->WriteProjectConfigurations();
this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1);
this->WriteString("<ProjectGUID>", 2);
(*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGUID>\n";
this->WriteString("<SccProjectName />\n", 2);
this->WriteString("<SccLocalPath />\n", 2);
this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2);
this->WriteString("</PropertyGroup>\n", 1);
this->WriteString("<Import Project="
"\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n",
1);
this->WriteProjectConfigurationValues();
this->WriteString(
"<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n", 1);
this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1);
this->WriteString("</ImportGroup>\n", 1);
this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1);
this->WriteString("<Import Project="
"\"$(LocalAppData)\\Microsoft\\VisualStudio\\10.0\\"
"Microsoft.Cpp.$(Platform).user.props\" "
"Condition=\"exists('$(LocalAppData)\\Microsoft"
"\\VisualStudio\\10.0\\"
"Microsoft.Cpp.$(Platform).user.props')\" />\n", 2);
this->WriteString("</ImportGroup>\n", 1);
this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1);
this->WritePathAndIncrementalLinkOptions();
this->WriteItemDefinitionGroups();
this->WriteCustomCommands();
this->WriteSources();
this->WriteProjectReferences();
this->WriteString(
"<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\""
" />\n", 1);
this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1);
this->WriteString("</ImportGroup>\n", 1);
this->WriteString("</Project>", 0);
// The groups are stored in a separate file for VS 10
this->WriteGroups();
}
// ConfigurationType Application, Utility StaticLibrary DynamicLibrary
void cmVisualStudio10TargetGenerator::WriteProjectConfigurations()
{
this->WriteString("<ItemGroup Label=\"ProjectConfigurations\">\n", 1);
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i)
{
this->WriteString("<ProjectConfiguration Include=\"", 2);
(*this->BuildFileStream ) << *i << this->Platform << "\">\n";
this->WriteString("<Configuration>", 3);
(*this->BuildFileStream ) << *i << "</Configuration>\n";
this->WriteString("<Platform>Win32</Platform>\n", 3);
this->WriteString("</ProjectConfiguration>\n", 2);
}
this->WriteString("</ItemGroup>\n", 1);
}
void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
{
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i)
{
this->WritePlatformConfigTag("PropertyGroup",
i->c_str(),
1, " Label=\"Configuration\"", "\n");
std::string configType = "<ConfigurationType>";
switch(this->Target->GetType())
{
case cmTarget::SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY:
configType += "DynamicLibrary";
break;
case cmTarget::STATIC_LIBRARY:
configType += "StaticLibrary";
break;
case cmTarget::EXECUTABLE:
configType += "Application";
break;
case cmTarget::UTILITY:
configType += "Utility";
break;
}
configType += "</ConfigurationType>\n";
this->WriteString(configType.c_str(), 2);
const char* mfcFlag =
this->Target->GetMakefile()->GetDefinition("CMAKE_MFC_FLAG");
if(mfcFlag)
{
this->WriteString("<UseOfMfc>true</UseOfMfc>\n", 2);
}
else
{
this->WriteString("<UseOfMfc>false</UseOfMfc>\n", 2);
}
this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
this->WriteString("</PropertyGroup>\n", 1);
}
}
void cmVisualStudio10TargetGenerator::WriteCustomCommands()
{
this->WriteString("<ItemGroup>\n", 1);
std::vector<cmSourceFile*>const & sources = this->Target->GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source)
{
if(cmCustomCommand const* command = (*source)->GetCustomCommand())
{
this->WriteCustomRule(*source, *command);
}
}
this->WriteString("</ItemGroup>\n", 1);
}
void
cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
cmCustomCommand const &
command)
{
std::string sourcePath = source->GetFullPath();
// the rule file seems to need to exist for vs10
if (source->GetExtension() == "rule")
{
if(!cmSystemTools::FileExists(sourcePath.c_str()))
{
std::ofstream fout(sourcePath.c_str());
if(fout)
{
fout << "# generated from CMake\n";
fout.flush();
fout.close();
}
}
}
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
std::string comment = lg->ConstructComment(command);
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
this->WriteString("<CustomBuild Include=\"", 2);
(*this->BuildFileStream ) <<
cmSystemTools::RelativePath(this->Makefile->GetCurrentOutputDirectory(),
sourcePath.c_str()) << "\">\n";
for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i)
{
std::string script = lg->ConstructScript(command.GetCommandLines(),
command.GetWorkingDirectory(),
i->c_str(),
command.GetEscapeOldStyle(),
command.GetEscapeAllowMakeVars());
this->WritePlatformConfigTag("Message",i->c_str(), 3);
(*this->BuildFileStream ) << comment << "</Message>\n";
this->WritePlatformConfigTag("Command", i->c_str(), 3);
(*this->BuildFileStream ) << script << "</Command>\n";
this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3);
(*this->BuildFileStream ) << source->GetFullPath();
for(std::vector<std::string>::const_iterator d =
command.GetDepends().begin();
d != command.GetDepends().end();
++d)
{
std::string dep = this->LocalGenerator->
GetRealDependency(d->c_str(), i->c_str());
this->ConvertToWindowsSlash(dep);
(*this->BuildFileStream ) << ";" << dep;
}
(*this->BuildFileStream ) << ";%(AdditionalInputs)</AdditionalInputs>\n";
this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
const char* sep = "";
for(std::vector<std::string>::const_iterator o =
command.GetOutputs().begin();
o != command.GetOutputs().end();
++o)
{
std::string out = *o;
this->ConvertToWindowsSlash(out);
(*this->BuildFileStream ) << sep << out;
sep = ";";
}
(*this->BuildFileStream ) << ";%(Outputs)</Outputs>\n";
}
this->WriteString("</CustomBuild>\n", 2);
}
void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s)
{
// first convert all of the slashes
std::string::size_type pos = 0;
while((pos = s.find('/', pos)) != std::string::npos)
{
s[pos] = '\\';
pos++;
}
}
void cmVisualStudio10TargetGenerator::WriteGroups()
{
// This should create a target.vcxproj.filters file
// something like this:
/*
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<CustomBuild Include="..\CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{05072589-c7be-439a-8fd7-5db6ee5008a9}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\foo.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\testCCompiler.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
*/
}
void cmVisualStudio10TargetGenerator::WriteSources()
{
this->WriteString("<ItemGroup>\n", 1);
if(this->Target->GetType() > cmTarget::MODULE_LIBRARY)
{
this->WriteString("<None Include=\"", 2);
(*this->BuildFileStream ) << this->Target->GetDirectory()
<< "\\" << this->Target->GetName()
<< "\" />\n";
}
else
{
std::vector<cmSourceFile*>const & sources = this->Target->GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source)
{
// if it is not a custom command then add it as a c file,
// TODO: need to check for idl or rc, or exclude from build
if(!(*source)->GetCustomCommand()
&& !(*source)->GetPropertyAsBool("HEADER_FILE_ONLY")
&& !this->GlobalGenerator->IgnoreFile
((*source)->GetExtension().c_str()))
{
const char* lang = (*source)->GetLanguage();
if(lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0))
{
std::string sourceFile = (*source)->GetFullPath();
// output the source file
this->WriteString("<ClCompile Include=\"", 2);
(*this->BuildFileStream ) << sourceFile << "\"";
// ouput any flags specific to this source file
if(this->OutputSourceSpecificFlags(*source))
{
// if the source file has specific flags the tag
// is ended on a new line
this->WriteString("</ClCompile>\n", 2);
}
else
{
(*this->BuildFileStream ) << " />\n";
}
}
}
}
}
this->WriteString("</ItemGroup>\n", 1);
}
bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
cmSourceFile* source)
{
cmSourceFile& sf = *source;
std::string flags;
std::string defines;
if(const char* cflags = sf.GetProperty("COMPILE_FLAGS"))
{
flags += cflags;
}
if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS"))
{
defines += cdefs;
}
const char* lang =
this->GlobalGenerator->GetLanguageFromExtension
(sf.GetExtension().c_str());
const char* sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
const char* linkLanguage = this->Target->GetLinkerLanguage
(this->LocalGenerator->GetGlobalGenerator());
bool needForceLang = false;
// source file does not match its extension language
if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
{
needForceLang = true;
lang = sourceLang;
}
// if the source file does not match the linker language
// then force c or c++
if(needForceLang || (linkLanguage && lang
&& strcmp(lang, linkLanguage) != 0))
{
if(strcmp(lang, "CXX") == 0)
{
// force a C++ file type
flags += " /TP ";
}
else if(strcmp(lang, "C") == 0)
{
// force to c
flags += " /TC ";
}
}
// for the first time we need a new line if there is something
// produced here.
const char* firstString = ">\n";
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
bool hasFlags = false;
for( std::vector<std::string>::iterator config = configs->begin();
config != configs->end(); ++config)
{
std::string configUpper = cmSystemTools::UpperCase(*config);
std::string configDefines = defines;
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper;
if(const char* ccdefs = sf.GetProperty(defPropName.c_str()))
{
if(configDefines.size())
{
configDefines += ",";
}
configDefines += ccdefs;
}
// if we have flags or defines for this config then
// use them
if(flags.size() || configDefines.size())
{
(*this->BuildFileStream ) << firstString;
firstString = ""; // only do firstString once
hasFlags = true;
cmVisualStudioGeneratorOptions
clOptions(this->LocalGenerator,
10, cmVisualStudioGeneratorOptions::Compiler,
cmVS10CLFlagTable, 0, this);
clOptions.Parse(flags.c_str());
clOptions.AddDefines(configDefines.c_str());
clOptions.SetConfiguration((*config).c_str());
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n");
}
}
return hasFlags;
}
void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
{
this->WriteString("<PropertyGroup>\n", 2);
this->WriteString("<_ProjectFileVersion>10.0.20506.1"
"</_ProjectFileVersion>\n", 3);
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
for(std::vector<std::string>::iterator config = configs->begin();
config != configs->end(); ++config)
{
std::string targetNameFull =
this->Target->GetFullName(config->c_str());
std::string intermediateDir = this->LocalGenerator->
GetTargetDirectory(*this->Target);
intermediateDir += "/";
intermediateDir += *config;
intermediateDir += "/";
this->ConvertToWindowsSlash(intermediateDir);
std::string outDir = this->Target->GetDirectory(config->c_str());
this->ConvertToWindowsSlash(outDir);
this->WritePlatformConfigTag("OutDir", config->c_str(), 3);
*this->BuildFileStream << outDir
<< "\\"
<< "</OutDir>\n";
this->WritePlatformConfigTag("IntDir", config->c_str(), 3);
*this->BuildFileStream << intermediateDir
<< "</IntDir>\n";
this->WritePlatformConfigTag("TargetName", config->c_str(), 3);
*this->BuildFileStream << cmSystemTools::GetFilenameWithoutExtension(
targetNameFull.c_str())
<< "</TargetName>\n";
this->WritePlatformConfigTag("TargetExt", config->c_str(), 3);
*this->BuildFileStream << cmSystemTools::GetFilenameLastExtension(
targetNameFull.c_str())
<< "</TargetExt>\n";
this->OutputLinkIncremental(*config);
}
this->WriteString("</PropertyGroup>\n", 2);
}
void
cmVisualStudio10TargetGenerator::
OutputLinkIncremental(std::string const& configName)
{
std::string CONFIG = cmSystemTools::UpperCase(configName);
// static libraries and things greater than modules do not need
// to set this option
if(this->Target->GetType() == cmTarget::STATIC_LIBRARY
|| this->Target->GetType() > cmTarget::MODULE_LIBRARY)
{
return;
}
const char* linkType = "SHARED";
if(this->Target->GetType() == cmTarget::EXECUTABLE)
{
linkType = "EXE";
}
// assume incremental linking
const char* incremental = "true";
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
if(!linkLanguage)
{
cmSystemTools::Error
("CMake can not determine linker language for target:",
this->Target->GetName());
return;
}
std::string linkFlagVarBase = "CMAKE_";
linkFlagVarBase += linkType;
linkFlagVarBase += "_LINKER_FLAGS";
std::string flags = this->
Target->GetMakefile()->GetRequiredDefinition(linkFlagVarBase.c_str());
std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
flags += this->
Target->GetMakefile()->GetRequiredDefinition(linkFlagVar.c_str());
if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
|| strcmp(linkLanguage, "Fortran") == 0)
{
std::string baseFlagVar = "CMAKE_";
baseFlagVar += linkLanguage;
baseFlagVar += "_FLAGS";
flags += this->
Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str());
std::string flagVar = baseFlagVar + std::string("_") + CONFIG;
flags +=
Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
}
if(flags.find("INCREMENTAL:NO") != flags.npos)
{
incremental = "false";
}
this->WritePlatformConfigTag("LinkIncremental", configName.c_str(), 3);
*this->BuildFileStream << incremental
<< "</LinkIncremental>\n";
}
void
cmVisualStudio10TargetGenerator::
WriteClOptions(std::string const&
configName,
std::vector<std::string> const & includes)
{
// much of this was copied from here:
// copied from cmLocalVisualStudio7Generator.cxx 805
this->WriteString("<ClCompile>\n", 2);
cmVisualStudioGeneratorOptions
clOptions(this->LocalGenerator,
10, cmVisualStudioGeneratorOptions::Compiler,
cmVS10CLFlagTable);
std::string flags;
// collect up flags for
if(this->Target->GetType() < cmTarget::UTILITY)
{
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
if(!linkLanguage)
{
cmSystemTools::Error
("CMake can not determine linker language for target:",
this->Target->GetName());
return;
}
if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
|| strcmp(linkLanguage, "Fortran") == 0)
{
std::string baseFlagVar = "CMAKE_";
baseFlagVar += linkLanguage;
baseFlagVar += "_FLAGS";
flags = this->
Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str());
std::string flagVar = baseFlagVar + std::string("_") +
cmSystemTools::UpperCase(configName);
flags += " ";
flags += this->
Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
}
// set the correct language
if(strcmp(linkLanguage, "C") == 0)
{
flags += " /TC ";
}
if(strcmp(linkLanguage, "CXX") == 0)
{
flags += " /TP ";
}
}
std::string configUpper = cmSystemTools::UpperCase(configName);
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper;
// Get preprocessor definitions for this directory.
std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags();
clOptions.FixExceptionHandlingDefault();
clOptions.Parse(flags.c_str());
clOptions.Parse(defineFlags.c_str());
clOptions.AddDefines
(this->Makefile->GetProperty("COMPILE_DEFINITIONS"));
clOptions.AddDefines(this->Target->GetProperty("COMPILE_DEFINITIONS"));
clOptions.AddDefines(this->Makefile->GetProperty(defPropName.c_str()));
clOptions.AddDefines(this->Target->GetProperty(defPropName.c_str()));
clOptions.SetVerboseMakefile(
this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
// Add a definition for the configuration name.
std::string configDefine = "CMAKE_INTDIR=\"";
configDefine += configName;
configDefine += "\"";
clOptions.AddDefine(configDefine);
if(const char* exportMacro = this->Target->GetExportMacro())
{
clOptions.AddDefine(exportMacro);
}
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
this->OutputIncludes(includes);
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n");
this->WriteString("<AssemblerListingLocation>", 3);
*this->BuildFileStream << configName
<< "</AssemblerListingLocation>\n";
this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
this->WriteString("<ProgramDataBaseFileName>", 3);
*this->BuildFileStream << this->Target->GetDirectory(configName.c_str())
<< "/"
<< this->Target->GetPDBName(configName.c_str())
<< "</ProgramDataBaseFileName>\n";
this->WriteString("</ClCompile>\n", 2);
}
void cmVisualStudio10TargetGenerator::
OutputIncludes(std::vector<std::string> const & includes)
{
this->WriteString("<AdditionalIncludeDirectories>", 3);
for(std::vector<std::string>::const_iterator i = includes.begin();
i != includes.end(); ++i)
{
*this->BuildFileStream << *i << ";";
}
this->WriteString("%(AdditionalIncludeDirectories)"
"</AdditionalIncludeDirectories>\n", 0);
}
void cmVisualStudio10TargetGenerator::
WriteRCOptions(std::string const& config,
std::vector<std::string> const & includes)
{
this->WriteString("<ResourceCompile>\n", 2);
this->OutputIncludes(includes);
this->WriteString("</ResourceCompile>\n", 2);
}
void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&
config)
{
// static libraries and things greater than modules do not need
// to set this option
if(this->Target->GetType() == cmTarget::STATIC_LIBRARY
|| this->Target->GetType() > cmTarget::MODULE_LIBRARY)
{
return;
}
const char* linkLanguage =
this->Target->GetLinkerLanguage(this->GlobalGenerator);
if(!linkLanguage)
{
cmSystemTools::Error
("CMake can not determine linker language for target:",
this->Target->GetName());
return;
}
this->WriteString("<Link>\n", 2);
std::string CONFIG = cmSystemTools::UpperCase(config);
const char* linkType = "SHARED";
if(this->Target->GetType() == cmTarget::MODULE_LIBRARY)
{
linkType = "MODULE";
}
if(this->Target->GetType() == cmTarget::EXECUTABLE)
{
linkType = "EXE";
}
std::string stackVar = "CMAKE_";
stackVar += linkLanguage;
stackVar += "_STACK_SIZE";
const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
std::string flags;
if(stackVal)
{
flags += " ";
flags += stackVal;
}
// assume incremental linking
std::string linkFlagVarBase = "CMAKE_";
linkFlagVarBase += linkType;
linkFlagVarBase += "_LINKER_FLAGS";
flags += " ";
flags += this->
Target->GetMakefile()->GetRequiredDefinition(linkFlagVarBase.c_str());
std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
flags += " ";
flags += this->
Target->GetMakefile()->GetRequiredDefinition(linkFlagVar.c_str());
const char* targetLinkFlags = this->Target->GetProperty("LINK_FLAGS");
if(targetLinkFlags)
{
flags += " ";
flags += targetLinkFlags;
}
cmVisualStudioGeneratorOptions
linkOptions(this->LocalGenerator,
10, cmVisualStudioGeneratorOptions::Compiler,
cmVS10LinkFlagTable);
if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") )
{
flags += " /SUBSYSTEM:WINDOWS";
}
else
{
flags += " /SUBSYSTEM:CONSOLE";
}
cmSystemTools::ReplaceString(flags, "/INCREMENTAL:YES", "");
cmSystemTools::ReplaceString(flags, "/INCREMENTAL:NO", "");
std::string standardLibsVar = "CMAKE_";
standardLibsVar += linkLanguage;
standardLibsVar += "_STANDARD_LIBRARIES";
std::string
libs = this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
// Remove trailing spaces from libs
std::string::size_type pos = libs.size()-1;
if(libs.size() != 0)
{
while(libs[pos] == ' ')
{
pos--;
}
}
if(pos != libs.size()-1)
{
libs = libs.substr(0, pos+1);
}
// Replace spaces in libs with ;
cmSystemTools::ReplaceString(libs, " ", ";");
cmComputeLinkInformation* pcli =
this->Target->GetLinkInformation(config.c_str());
if(!pcli)
{
cmSystemTools::Error
("CMake can not compute cmComputeLinkInformation for target:",
this->Target->GetName());
return;
}
// add the libraries for the target to libs string
cmComputeLinkInformation& cli = *pcli;
this->AddLibraries(cli, libs);
linkOptions.AddFlag("AdditionalDependencies", libs.c_str());
std::vector<std::string> const& ldirs = cli.GetDirectories();
const char* sep = "";
std::string linkDirs;
for(std::vector<std::string>::const_iterator d = ldirs.begin();
d != ldirs.end(); ++d)
{
linkDirs += sep;
linkDirs += *d;
sep = ";";
}
linkDirs += "%(AdditionalLibraryDirectories)";
linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs.c_str());
linkOptions.AddFlag("AdditionalDependencies", libs.c_str());
linkOptions.AddFlag("Version", "0.0");
if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos)
{
linkOptions.AddFlag("GenerateDebugInformation", "true");
}
else
{
linkOptions.AddFlag("GenerateDebugInformation", "false");
}
std::string targetName;
std::string targetNameSO;
std::string targetNameFull;
std::string targetNameImport;
std::string targetNamePDB;
if(this->Target->GetType() == cmTarget::EXECUTABLE)
{
this->Target->GetExecutableNames(targetName, targetNameFull,
targetNameImport, targetNamePDB,
config.c_str());
}
else
{
this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull,
targetNameImport, targetNamePDB,
config.c_str());
}
std::string dir = this->Target->GetDirectory(config.c_str());
dir += "/";
std::string imLib = dir;
imLib += targetNameImport;
std::string pdb = dir;
pdb += targetNamePDB;
linkOptions.AddFlag("ImportLibrary", imLib.c_str());
linkOptions.AddFlag("ProgramDataBaseFileName", pdb.c_str());
linkOptions.Parse(flags.c_str());
linkOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
linkOptions.OutputFlagMap(*this->BuildFileStream, " ");
this->WriteString("</Link>\n", 2);
}
void cmVisualStudio10TargetGenerator::AddLibraries(
cmComputeLinkInformation& cli,
std::string& libstring)
{
typedef cmComputeLinkInformation::ItemVector ItemVector;
ItemVector libs = cli.GetItems();
const char* sep = ";";
for(ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l)
{
if(l->IsPath)
{
std::string path = this->LocalGenerator->
Convert(l->Value.c_str(),
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED);
libstring += sep;
libstring += path;
}
else
{
libstring += sep;
libstring += l->Value;
}
}
}
void cmVisualStudio10TargetGenerator::
WriteMidlOptions(std::string const&
config,
std::vector<std::string> const & includes)
{
this->WriteString("<Midl>\n", 2);
this->OutputIncludes(includes);
// Need this stuff, but there is an midl.xml file...
// should we look for .idl language?, and flags?
/*
<MkTypLibCompatible>false</MkTypLibCompatible>
<TargetEnvironment>Win32</TargetEnvironment>
<GenerateStublessProxies>true</GenerateStublessProxies>
<TypeLibraryName>%(FileName).tlb</TypeLibraryName>
<OutputDirectory>$(IntDir)\</OutputDirectory>
<HeaderFileName>%(FileName).h</HeaderFileName>
<DllDataFileName>
</DllDataFileName>
<InterfaceIdentifierFileName>%(FileName)_i.c</InterfaceIdentifierFileName>
<ProxyFileName>%(FileName)_p.c</ProxyFileName>
*/
this->WriteString("</Midl>\n", 2);
}
void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
{
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes);
for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i)
{
this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1);
*this->BuildFileStream << "\n";
// output cl compile flags <ClCompile></ClCompile>
if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY)
{
this->WriteClOptions(*i, includes);
// output rc compile flags <ResourceCompile></ResourceCompile>
this->WriteRCOptions(*i, includes);
}
// output midl flags <Midl></Midl>
this->WriteMidlOptions(*i, includes);
// output link flags <Link></Link> or <Lib></Lib>
this->WriteLinkOptions(*i);
// TODO: need a WriteLibOptions for static
this->WriteString("</ItemDefinitionGroup>\n", 1);
}
}
// TODO handle .obj file direct stuff
void cmVisualStudio10TargetGenerator::WriteProjectReferences()
{
// TODO
// This should have dependent targets listed like this:
/*
<ItemGroup>
<ProjectReference Include="ZERO_CHECK.vcxproj">
<Project>{2f1e4f3c-0a51-46c3-aaf9-e486599604f2}</Project>
</ProjectReference>
</ItemGroup>
*/
}

View File

@ -0,0 +1,81 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmVisualStudioTargetGenerator_h
#define cmVisualStudioTargetGenerator_h
#include "cmStandardIncludes.h"
class cmTarget;
class cmMakefile;
class cmGeneratedFileStream;
class cmGlobalVisualStudio7Generator;
class cmSourceFile;
class cmCustomCommand;
class cmLocalVisualStudio7Generator;
class cmComputeLinkInformation;
class cmVisualStudio10TargetGenerator
{
public:
cmVisualStudio10TargetGenerator(cmTarget* target,
cmGlobalVisualStudio7Generator* gg);
~cmVisualStudio10TargetGenerator();
void Generate();
// used by cmVisualStudioGeneratorOptions
void WritePlatformConfigTag(
const char* tag,
const char* config,
int indentLevel,
const char* attribute = 0,
const char* end = 0,
std::ostream* strm = 0
);
private:
void ConvertToWindowsSlash(std::string& s);
void WriteString(const char* line, int indentLevel);
void WriteProjectConfigurations();
void WriteProjectConfigurationValues();
void WriteSources();
void WritePathAndIncrementalLinkOptions();
void WriteItemDefinitionGroups();
void WriteClOptions(std::string const& config,
std::vector<std::string> const & includes);
void WriteRCOptions(std::string const& config,
std::vector<std::string> const & includes);
void WriteLinkOptions(std::string const& config);
void WriteMidlOptions(std::string const& config,
std::vector<std::string> const & includes);
void OutputIncludes(std::vector<std::string> const & includes);
void OutputLinkIncremental(std::string const& configName);
void WriteCustomRule(cmSourceFile* source,
cmCustomCommand const & command);
void WriteCustomCommands();
void WriteGroups();
void WriteProjectReferences();
bool OutputSourceSpecificFlags(cmSourceFile* source);
void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring);
private:
cmTarget* Target;
cmMakefile* Makefile;
std::string Platform;
std::string GUID;
cmGlobalVisualStudio7Generator* GlobalGenerator;
cmGeneratedFileStream* BuildFileStream;
cmLocalVisualStudio7Generator* LocalGenerator;
};
#endif

View File

@ -0,0 +1,420 @@
#include "cmVisualStudioGeneratorOptions.h"
#include "cmSystemTools.h"
#include <cmsys/System.h>
#include "cmVisualStudio10TargetGenerator.h"
inline std::string cmVisualStudioGeneratorOptionsEscapeForXML(const char* s)
{
std::string ret = s;
cmSystemTools::ReplaceString(ret, "&", "&amp;");
cmSystemTools::ReplaceString(ret, "\"", "&quot;");
cmSystemTools::ReplaceString(ret, "<", "&lt;");
cmSystemTools::ReplaceString(ret, ">", "&gt;");
cmSystemTools::ReplaceString(ret, "\n", "&#x0D;&#x0A;");
return ret;
}
//----------------------------------------------------------------------------
cmVisualStudioGeneratorOptions
::cmVisualStudioGeneratorOptions(cmLocalGenerator* lg,
int version,
Tool tool,
cmVS7FlagTable const* table,
cmVS7FlagTable const* extraTable,
cmVisualStudio10TargetGenerator* g):
LocalGenerator(lg), Version(version), CurrentTool(tool),
DoingDefine(false), FlagTable(table), ExtraFlagTable(extraTable),
TargetGenerator(g)
{
}
//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault()
{
// Exception handling is on by default because the platform file has
// "/EHsc" in the flags. Normally, that will override this
// initialization to off, but the user has the option of removing
// the flag to disable exception handling. When the user does
// remove the flag we need to override the IDE default of on.
switch (this->Version)
{
case 7:
case 71:
this->FlagMap["ExceptionHandling"] = "FALSE";
break;
case 10:
// by default VS puts <ExceptionHandling></ExceptionHandling> empty
// for a project, to make our projects look the same put a new line
// and space over for the closing </ExceptionHandling> as the default
// value
this->FlagMap["ExceptionHandling"] = "\n ";
break;
default:
this->FlagMap["ExceptionHandling"] = "0";
break;
}
}
//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::SetVerboseMakefile(bool verbose)
{
// If verbose makefiles have been requested and the /nologo option
// was not given explicitly in the flags we want to add an attribute
// to the generated project to disable logo suppression. Otherwise
// the GUI default is to enable suppression.
if(verbose &&
this->FlagMap.find("SuppressStartupBanner") == this->FlagMap.end())
{
if(this->Version == 10)
{
this->FlagMap["SuppressStartupBanner"] = "false";
}
else
{
this->FlagMap["SuppressStartupBanner"] = "FALSE";
}
}
}
//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::AddDefine(const std::string& def)
{
this->Defines.push_back(def);
}
//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::AddDefines(const char* defines)
{
if(defines)
{
// Expand the list of definitions.
cmSystemTools::ExpandListArgument(defines, this->Defines);
}
}
//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::AddFlag(const char* flag,
const char* value)
{
this->FlagMap[flag] = value;
}
bool cmVisualStudioGeneratorOptions::IsDebug()
{
return this->FlagMap.find("DebugInformationFormat") != this->FlagMap.end();
}
//----------------------------------------------------------------------------
bool cmVisualStudioGeneratorOptions::UsingUnicode()
{
// Look for the a _UNICODE definition.
for(std::vector<std::string>::const_iterator di = this->Defines.begin();
di != this->Defines.end(); ++di)
{
if(*di == "_UNICODE")
{
return true;
}
}
return false;
}
//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::Parse(const char* flags)
{
// Parse the input string as a windows command line since the string
// is intended for writing directly into the build files.
std::vector<std::string> args;
cmSystemTools::ParseWindowsCommandLine(flags, args);
// Process flags that need to be represented specially in the IDE
// project file.
for(std::vector<std::string>::iterator ai = args.begin();
ai != args.end(); ++ai)
{
this->HandleFlag(ai->c_str());
}
}
//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::HandleFlag(const char* flag)
{
// If the last option was -D then this option is the definition.
if(this->DoingDefine)
{
this->DoingDefine = false;
this->Defines.push_back(flag);
return;
}
// Look for known arguments.
if(flag[0] == '-' || flag[0] == '/')
{
// Look for preprocessor definitions.
if(this->CurrentTool == Compiler && flag[1] == 'D')
{
if(flag[2] == '\0')
{
// The next argument will have the definition.
this->DoingDefine = true;
}
else
{
// Store this definition.
this->Defines.push_back(flag+2);
}
return;
}
// Look through the available flag tables.
bool flag_handled = false;
if(this->FlagTable &&
this->CheckFlagTable(this->FlagTable, flag, flag_handled))
{
return;
}
if(this->ExtraFlagTable &&
this->CheckFlagTable(this->ExtraFlagTable, flag, flag_handled))
{
return;
}
// If any map entry handled the flag we are done.
if(flag_handled)
{
return;
}
}
// This option is not known. Store it in the output flags.
this->FlagString += " ";
this->FlagString +=
cmSystemTools::EscapeWindowsShellArgument(
flag,
cmsysSystem_Shell_Flag_AllowMakeVariables |
cmsysSystem_Shell_Flag_VSIDE);
}
//----------------------------------------------------------------------------
bool
cmVisualStudioGeneratorOptions
::CheckFlagTable(cmVS7FlagTable const* table, const char* flag,
bool& flag_handled)
{
// Look for an entry in the flag table matching this flag.
for(cmVS7FlagTable const* entry = table; entry->IDEName; ++entry)
{
bool entry_found = false;
if(entry->special & cmVS7FlagTable::UserValue)
{
// This flag table entry accepts a user-specified value. If
// the entry specifies UserRequired we must match only if a
// non-empty value is given.
int n = static_cast<int>(strlen(entry->commandFlag));
if(strncmp(flag+1, entry->commandFlag, n) == 0 &&
(!(entry->special & cmVS7FlagTable::UserRequired) ||
static_cast<int>(strlen(flag+1)) > n))
{
if(entry->special & cmVS7FlagTable::UserIgnored)
{
// Ignore the user-specified value.
this->FlagMap[entry->IDEName] = entry->value;
}
else if(entry->special & cmVS7FlagTable::SemicolonAppendable)
{
const char *new_value = flag+1+n;
std::map<cmStdString,cmStdString>::iterator itr;
itr = this->FlagMap.find(entry->IDEName);
if(itr != this->FlagMap.end())
{
// Append to old value (if present) with semicolons;
itr->second += ";";
itr->second += new_value;
}
else
{
this->FlagMap[entry->IDEName] = new_value;
}
}
else
{
// Use the user-specified value.
this->FlagMap[entry->IDEName] = flag+1+n;
}
entry_found = true;
}
}
else if(strcmp(flag+1, entry->commandFlag) == 0)
{
// This flag table entry provides a fixed value.
this->FlagMap[entry->IDEName] = entry->value;
entry_found = true;
}
// If the flag has been handled by an entry not requesting a
// search continuation we are done.
if(entry_found && !(entry->special & cmVS7FlagTable::Continue))
{
return true;
}
// If the entry was found the flag has been handled.
flag_handled = flag_handled || entry_found;
}
return false;
}
void cmVisualStudioGeneratorOptions::SetConfiguration(const char* config)
{
this->Configuration = config;
}
//----------------------------------------------------------------------------
void
cmVisualStudioGeneratorOptions
::OutputPreprocessorDefinitions(std::ostream& fout,
const char* prefix,
const char* suffix)
{
if(this->Defines.empty())
{
return;
}
if(this->Version == 10)
{
// if there are configuration specifc flags, then
// use the configuration specific tag for PreprocessorDefinitions
if(this->Configuration.size())
{
fout << prefix;
this->TargetGenerator->WritePlatformConfigTag(
"PreprocessorDefinitions",
this->Configuration.c_str(),
0,
0, 0, &fout);
}
else
{
fout << prefix << "<PreprocessorDefinitions>";
}
}
else
{
fout << prefix << "PreprocessorDefinitions=\"";
}
const char* comma = "";
for(std::vector<std::string>::const_iterator di = this->Defines.begin();
di != this->Defines.end(); ++di)
{
// Escape the definition for the compiler.
std::string define;
if(this->Version != 10)
{
define =
this->LocalGenerator->EscapeForShell(di->c_str(), true);
}
else
{
define = *di;
}
// Escape this flag for the IDE.
if(this->Version != 10)
{
define = cmVisualStudioGeneratorOptionsEscapeForXML(define.c_str());
}
// Store the flag in the project file.
fout << comma << define;
if(this->Version == 10)
{
comma = ";";
}
else
{
comma = ",";
}
}
if(this->Version == 10)
{
fout << ";%(PreprocessorDefinitions)</PreprocessorDefinitions>" << suffix;
}
else
{
fout << "\"" << suffix;
}
}
//----------------------------------------------------------------------------
void
cmVisualStudioGeneratorOptions
::OutputFlagMap(std::ostream& fout, const char* indent)
{
if(this->Version == 10)
{
for(std::map<cmStdString, cmStdString>::iterator m = this->FlagMap.begin();
m != this->FlagMap.end(); ++m)
{
fout << indent;
if(this->Configuration.size())
{
this->TargetGenerator->WritePlatformConfigTag(
m->first.c_str(),
this->Configuration.c_str(),
0,
0, 0, &fout);
}
else
{
fout << "<" << m->first << ">";
}
fout << m->second << "</" << m->first << ">\n";
}
}
else
{
for(std::map<cmStdString, cmStdString>::iterator m = this->FlagMap.begin();
m != this->FlagMap.end(); ++m)
{
fout << indent << m->first << "=\"" << m->second << "\"\n";
}
}
}
//----------------------------------------------------------------------------
void
cmVisualStudioGeneratorOptions
::OutputAdditionalOptions(std::ostream& fout,
const char* prefix,
const char* suffix)
{
if(!this->FlagString.empty())
{
if(this->Version == 10)
{
fout << prefix;
if(this->Configuration.size())
{
this->TargetGenerator->WritePlatformConfigTag(
"AdditionalOptions",
this->Configuration.c_str(),
0,
0, 0, &fout);
}
else
{
fout << "<AdditionalOptions>";
}
fout << this->FlagString.c_str()
<< " %(AdditionalOptions)</AdditionalOptions>\n";
}
else
{
fout << prefix << "AdditionalOptions=\"";
fout <<
cmVisualStudioGeneratorOptionsEscapeForXML(this->FlagString.c_str());
fout << "\"" << suffix;
}
}
}

View File

@ -0,0 +1,122 @@
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notices for more information.
=========================================================================*/
#ifndef cmVisualStudioGeneratorOptions_h
#define cmVisualStudioGeneratorOptions_h
#include "cmLocalGenerator.h"
class cmVisualStudio10TargetGenerator;
// This is a table mapping XML tag IDE names to command line options
struct cmVS7FlagTable
{
const char* IDEName; // name used in the IDE xml file
const char* commandFlag; // command line flag
const char* comment; // comment
const char* value; // string value
unsigned int special; // flags for special handling requests
enum
{
UserValue = (1<<0), // flag contains a user-specified value
UserIgnored = (1<<1), // ignore any user value
UserRequired = (1<<2), // match only when user value is non-empty
Continue = (1<<3), // continue looking for matching entries
SemicolonAppendable = (1<<4), // a flag that if specified multiple times
// should have its value appended to the
// old value with semicolons (e.g.
// /NODEFAULTLIB: =>
// IgnoreDefaultLibraryNames)
UserValueIgnored = UserValue | UserIgnored,
UserValueRequired = UserValue | UserRequired
};
};
//----------------------------------------------------------------------------
class cmVisualStudioGeneratorOptions
{
public:
// Construct an options table for a given tool.
enum Tool
{
Compiler,
Linker,
FortranCompiler
};
cmVisualStudioGeneratorOptions(cmLocalGenerator* lg,
int version,
Tool tool,
cmVS7FlagTable const* table,
cmVS7FlagTable const* extraTable = 0,
cmVisualStudio10TargetGenerator* g = 0);
// Store options from command line flags.
void Parse(const char* flags);
// Fix the ExceptionHandling option to default to off.
void FixExceptionHandlingDefault();
// Store options for verbose builds.
void SetVerboseMakefile(bool verbose);
// Store definitions and flags.
void AddDefine(const std::string& define);
void AddDefines(const char* defines);
void AddFlag(const char* flag, const char* value);
// Check for specific options.
bool UsingUnicode();
bool IsDebug();
// Write options to output.
void OutputPreprocessorDefinitions(std::ostream& fout,
const char* prefix,
const char* suffix);
void OutputFlagMap(std::ostream& fout, const char* indent);
void OutputAdditionalOptions(std::ostream& fout,
const char* prefix,
const char* suffix);
void SetConfiguration(const char* config);
private:
cmLocalGenerator* LocalGenerator;
int Version;
// create a map of xml tags to the values they should have in the output
// for example, "BufferSecurityCheck" = "TRUE"
// first fill this table with the values for the configuration
// Debug, Release, etc,
// Then parse the command line flags specified in CMAKE_CXX_FLAGS
// and CMAKE_C_FLAGS
// and overwrite or add new values to this map
std::map<cmStdString, cmStdString> FlagMap;
// Preprocessor definitions.
std::vector<std::string> Defines;
// Unrecognized flags that get no special handling.
cmStdString FlagString;
std::string Configuration;
cmVisualStudio10TargetGenerator* TargetGenerator;
Tool CurrentTool;
bool DoingDefine;
cmVS7FlagTable const* FlagTable;
cmVS7FlagTable const* ExtraFlagTable;
void HandleFlag(const char* flag);
bool CheckFlagTable(cmVS7FlagTable const* table, const char* flag,
bool& flag_handled);
};
#endif

View File

@ -67,6 +67,7 @@
# include "cmGlobalVisualStudio8Generator.h"
# include "cmGlobalVisualStudio9Generator.h"
# include "cmGlobalVisualStudio9Win64Generator.h"
# include "cmGlobalVisualStudio10Generator.h"
# include "cmGlobalVisualStudio8Win64Generator.h"
# include "cmGlobalBorlandMakefileGenerator.h"
# include "cmGlobalNMakeMakefileGenerator.h"
@ -2412,6 +2413,8 @@ void cmake::AddDefaultGenerators()
&cmGlobalVisualStudio6Generator::New;
this->Generators[cmGlobalVisualStudio7Generator::GetActualName()] =
&cmGlobalVisualStudio7Generator::New;
this->Generators[cmGlobalVisualStudio10Generator::GetActualName()] =
&cmGlobalVisualStudio10Generator::New;
this->Generators[cmGlobalVisualStudio71Generator::GetActualName()] =
&cmGlobalVisualStudio71Generator::New;
this->Generators[cmGlobalVisualStudio8Generator::GetActualName()] =

294
Source/cmparseMSBuildXML.py Executable file
View File

@ -0,0 +1,294 @@
# This python script parses the spec files from MSBuild to create
# mappings from compiler options to IDE XML specifications. For
# more information see here:
# http://blogs.msdn.com/vcblog/archive/2008/12/16/msbuild-task.aspx
# cl.xml
#
# BoolProperty <Name>true|false</Name>
# simple example:
# <BoolProperty ReverseSwitch="Oy-" Name="OmitFramePointers"
# Category="Optimization" Switch="Oy">
# <BoolProperty.DisplayName> <BoolProperty.Description>
# <CLCompile>
# <OmitFramePointers>true</OmitFramePointers>
# </ClCompile>
#
# argument means it might be this: /MP3
# example with argument:
# <BoolProperty Name="MultiProcessorCompilation" Category="General" Switch="MP">
# <BoolProperty.DisplayName>
# <sys:String>Multi-processor Compilation</sys:String>
# </BoolProperty.DisplayName>
# <BoolProperty.Description>
# <sys:String>Multi-processor Compilation</sys:String>
# </BoolProperty.Description>
# <Argument Property="ProcessorNumber" IsRequired="false" />
# </BoolProperty>
# <CLCompile>
# <MultiProcessorCompilation>true</MultiProcessorCompilation>
# <ProcessorNumber>4</ProcessorNumber>
# </ClCompile>
# IntProperty
# not used AFIT
# <IntProperty Name="ProcessorNumber" Category="General" Visible="false">
# per config options example
# <EnableFiberSafeOptimizations Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</EnableFiberSafeOptimizations>
#
# EnumProperty
# <EnumProperty Name="Optimization" Category="Optimization">
# <EnumProperty.DisplayName>
# <sys:String>Optimization</sys:String>
# </EnumProperty.DisplayName>
# <EnumProperty.Description>
# <sys:String>Select option for code optimization; choose Custom to use specific optimization options. (/Od, /O1, /O2, /Ox)</sys:String>
# </EnumProperty.Description>
# <EnumValue Name="MaxSpeed" Switch="O2">
# <EnumValue.DisplayName>
# <sys:String>Maximize Speed</sys:String>
# </EnumValue.DisplayName>
# <EnumValue.Description>
# <sys:String>Equivalent to /Og /Oi /Ot /Oy /Ob2 /Gs /GF /Gy</sys:String>
# </EnumValue.Description>
# </EnumValue>
# <EnumValue Name="MinSpace" Switch="O1">
# <EnumValue.DisplayName>
# <sys:String>Minimize Size</sys:String>
# </EnumValue.DisplayName>
# <EnumValue.Description>
# <sys:String>Equivalent to /Og /Os /Oy /Ob2 /Gs /GF /Gy</sys:String>
# </EnumValue.Description>
# </EnumValue>
# example for O2 would be this:
# <Optimization>MaxSpeed</Optimization>
# example for O1 would be this:
# <Optimization>MinSpace</Optimization>
#
# StringListProperty
# <StringListProperty Name="PreprocessorDefinitions" Category="Preprocessor" Switch="D ">
# <StringListProperty.DisplayName>
# <sys:String>Preprocessor Definitions</sys:String>
# </StringListProperty.DisplayName>
# <StringListProperty.Description>
# <sys:String>Defines a preprocessing symbols for your source file.</sys:String>
# </StringListProperty.Description>
# </StringListProperty>
# <StringListProperty Subtype="folder" Name="AdditionalIncludeDirectories" Category="General" Switch="I">
# <StringListProperty.DisplayName>
# <sys:String>Additional Include Directories</sys:String>
# </StringListProperty.DisplayName>
# <StringListProperty.Description>
# <sys:String>Specifies one or more directories to add to the include path; separate with semi-colons if more than one. (/I[path])</sys:String>
# </StringListProperty.Description>
# </StringListProperty>
# StringProperty
# Example add bill include:
# <AdditionalIncludeDirectories>..\..\..\..\..\..\bill;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
import sys
from xml.dom.minidom import parse, parseString
def getText(node):
nodelist = node.childNodes
rc = ""
for child in nodelist:
if child.nodeType == child.TEXT_NODE:
rc = rc + child.data
return rc
def print_tree(document, spaces=""):
for i in range(len(document.childNodes)):
if document.childNodes[i].nodeType == document.childNodes[i].ELEMENT_NODE:
print spaces+str(document.childNodes[i].nodeName )
print_tree(document.childNodes[i],spaces+"----")
pass
###########################################################################################
#Data structure that stores a property of MSBuild
class Property:
#type = type of MSBuild property (ex. if the property is EnumProperty type should be "Enum")
#attributeNames = a list of any attributes that this property could have (ex. if this was a EnumProperty it should be ["Name","Category"])
#document = the dom file that's root node is the Property node (ex. if you were parsing a BoolProperty the root node should be something like <BoolProperty Name="RegisterOutput" Category="General" IncludeInCommandLine="false">
def __init__(self,type,attributeNames,document=None):
self.suffix_type = "Property"
self.prefix_type = type
self.attributeNames = attributeNames
self.attributes = {}
self.DisplayName = ""
self.Description = ""
self.argumentProperty = ""
self.argumentIsRequired = ""
self.values = []
if document is not None:
self.populate(document)
pass
#document = the dom file that's root node is the Property node (ex. if you were parsing a BoolProperty the root node should be something like <BoolProperty Name="RegisterOutput" Category="General" IncludeInCommandLine="false">
#spaces = do not use
def populate(self,document, spaces = ""):
if document.nodeName == self.prefix_type+self.suffix_type:
for i in self.attributeNames:
self.attributes[i] = document.getAttribute(i)
for i in range(len(document.childNodes)):
child = document.childNodes[i]
if child.nodeType == child.ELEMENT_NODE:
if child.nodeName == self.prefix_type+self.suffix_type+".DisplayName":
self.DisplayName = getText(child.childNodes[1])
if child.nodeName == self.prefix_type+self.suffix_type+".Description":
self.Description = getText(child.childNodes[1])
if child.nodeName == "Argument":
self.argumentProperty = child.getAttribute("Property")
self.argumentIsRequired = child.getAttribute("IsRequired")
if child.nodeName == self.prefix_type+"Value":
va = Property(self.prefix_type,["Name","Switch"])
va.suffix_type = "Value"
va.populate(child)
self.values.append(va)
self.populate(child,spaces+"----")
pass
#toString function
def __str__(self):
toReturn = self.prefix_type+self.suffix_type+":"
for i in self.attributeNames:
toReturn += "\n "+i+": "+self.attributes[i]
if self.argumentProperty != "":
toReturn += "\n Argument:\n Property: "+self.argumentProperty+"\n IsRequired: "+self.argumentIsRequired
for i in self.values:
toReturn+="\n "+str(i).replace("\n","\n ")
return toReturn
###########################################################################################
###########################################################################################
#Class that populates itself from an MSBuild file and outputs it in CMake
#format
class MSBuildToCMake:
#document = the entire MSBuild xml file
def __init__(self,document=None):
self.enumProperties = []
self.stringProperties = []
self.stringListProperties = []
self.boolProperties = []
self.intProperties = []
if document!=None :
self.populate(document)
pass
#document = the entire MSBuild xml file
#spaces = don't use
#To add a new property (if they exist) copy and paste this code and fill in appropriate places
#
#if child.nodeName == "<Name>Property":
# self.<Name>Properties.append(Property("<Name>",[<List of attributes>],child))
#
#Replace <Name> with the name of the new property (ex. if property is StringProperty replace <Name> with String)
#Replace <List of attributes> with a list of attributes in your property's root node
#in the __init__ function add the line self.<Name>Properties = []
#
#That is all that is required to add new properties
#
def populate(self,document, spaces=""):
for i in range(len(document.childNodes)):
child = document.childNodes[i]
if child.nodeType == child.ELEMENT_NODE:
if child.nodeName == "EnumProperty":
self.enumProperties.append(Property("Enum",["Name","Category"],child))
if child.nodeName == "StringProperty":
self.stringProperties.append(Property("String",["Name","Subtype","Separator","Category","Visible","IncludeInCommandLine","Switch","ReadOnly"],child))
if child.nodeName == "StringListProperty":
self.stringListProperties.append(Property("StringList",["Name","Category","Switch","Subtype"],child))
if child.nodeName == "BoolProperty":
self.boolProperties.append(Property("Bool",["ReverseSwitch","Name","Category","Switch","SwitchPrefix","IncludeInCommandLine"],child))
if child.nodeName == "IntProperty":
self.intProperties.append(Property("Int",["Name","Category","Visible"],child))
self.populate(child,spaces+"----")
pass
#outputs information that CMake needs to know about MSBuild xml files
def toCMake(self):
toReturn = "static cmVS7FlagTable cmVS10CxxTable[] =\n{\n"
toReturn += "\n //Enum Properties\n"
for i in self.enumProperties:
for j in i.values:
toReturn+=" {\""+i.attributes["Name"]+"\", \""+j.attributes["Switch"]+"\", \""+j.DisplayName+"\", \""+j.attributes["Name"]+"\", 0},\n"
toReturn += "\n"
toReturn += "\n //Bool Properties\n"
for i in self.boolProperties:
if i.argumentProperty == "":
if i.attributes["ReverseSwitch"] != "":
toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \"\", \"false\", 0},\n"
if i.attributes["Switch"] != "":
toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+"\", \"\", \"true\", 0},\n"
toReturn += "\n //Bool Properties With Argument\n"
for i in self.boolProperties:
if i.argumentProperty != "":
if i.attributes["ReverseSwitch"] != "":
toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \"\", \"false\", cmVS7FlagTable::Continue},\n"
toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["ReverseSwitch"]+"\", \""+i.DisplayName+"\", \"\", cmVS7FlagTable::UserValueRequired},\n"
if i.attributes["Switch"] != "":
toReturn += " {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+"\", \"\", \"true\", cmVS7FlagTable::Continue},\n"
toReturn += " {\""+i.argumentProperty+"\", \""+i.attributes["Switch"]+"\", \""+i.DisplayName+"\", \"\", cmVS7FlagTable::UserValueRequired},\n"
toReturn += "\n //String List Properties\n"
for i in self.stringListProperties:
toReturn+=" {\""+i.attributes["Name"]+"\", \""+i.attributes["Switch"]+"\", \""+i.DisplayName+"\", \"\", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},\n"
toReturn += " {0,0,0,0,0}\n};"
return toReturn
pass
#toString function
def __str__(self):
toReturn = ""
allList = [self.enumProperties,self.stringProperties,self.stringListProperties,self.boolProperties,self.intProperties]
for p in allList:
for i in p:
toReturn += "==================================================\n"+str(i).replace("\n","\n ")+"\n==================================================\n"
return toReturn
###########################################################################################
###########################################################################################
# main function
def main(argv):
xml_file = None
help = """
Please specify an input xml file with -x
Exiting...
Have a nice day :)"""
for i in range(0,len(argv)):
if argv[i] == "-x":
xml_file = argv[i+1]
if argv[i] == "-h":
print help
sys.exit(0)
pass
if xml_file == None:
print help
sys.exit(1)
f = open(xml_file,"r")
xml_str = f.read()
xml_dom = parseString(xml_str)
convertor = MSBuildToCMake(xml_dom)
print convertor.toCMake()
xml_dom.unlink()
###########################################################################################
# main entry point
if __name__ == "__main__":
main(sys.argv)
sys.exit(0)

View File

@ -806,7 +806,7 @@ int kwsysProcess_SetPipeFile(kwsysProcess* cp, int pipe, const char* file)
}
if(file)
{
*pfile = malloc(strlen(file)+1);
*pfile = (char*)malloc(strlen(file)+1);
if(!*pfile)
{
return 0;
@ -1666,7 +1666,7 @@ int kwsysProcessInitialize(kwsysProcess* cp)
cp->RealWorkingDirectoryLength = GetCurrentDirectory(0, 0);
if(cp->RealWorkingDirectoryLength > 0)
{
cp->RealWorkingDirectory = malloc(cp->RealWorkingDirectoryLength);
cp->RealWorkingDirectory = (char*)malloc(cp->RealWorkingDirectoryLength);
if(!cp->RealWorkingDirectory)
{
return 0;
@ -1834,7 +1834,7 @@ int kwsysProcessCreate(kwsysProcess* cp, int index,
/* The forwarding executable is given a handle to the error pipe
and resume and kill events. */
realCommand = malloc(strlen(cp->Win9x)+strlen(cp->Commands[index])+100);
realCommand = (char*)malloc(strlen(cp->Win9x)+strlen(cp->Commands[index])+100);
if(!realCommand)
{
return 0;
@ -2672,7 +2672,7 @@ static int kwsysProcess_List__New_NT4(kwsysProcess_List* self)
loaded in this program. This does not actually increment the
reference count to the module so we do not need to close the
handle. */
HANDLE hNT = GetModuleHandle("ntdll.dll");
HMODULE hNT = GetModuleHandle("ntdll.dll");
if(hNT)
{
/* Get pointers to the needed API functions. */
@ -2776,7 +2776,7 @@ static int kwsysProcess_List__New_Snapshot(kwsysProcess_List* self)
loaded in this program. This does not actually increment the
reference count to the module so we do not need to close the
handle. */
HANDLE hKernel = GetModuleHandle("kernel32.dll");
HMODULE hKernel = GetModuleHandle("kernel32.dll");
if(hKernel)
{
self->P_CreateToolhelp32Snapshot =