Commit 7491f529 authored by Bill Hoffman's avatar Bill Hoffman
Browse files

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

parent 953439f7
......@@ -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.*")
......
# 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)
......@@ -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
......
......@@ -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).
......
/*=========================================================================
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";
}
/*=========================================================================
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
......@@ -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)
......
......@@ -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);
......
......@@ -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,
......
/*=========================================================================
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();
}
/*=========================================================================
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
......@@ -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
......@@ -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);
......
......@@ -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);
}
......
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},