ENH: only 5 failing tests for VS 10

This commit is contained in:
Bill Hoffman 2009-07-10 09:12:39 -04:00
parent 3199db4794
commit 5c4208f50e
19 changed files with 349 additions and 117 deletions

View File

@ -5,6 +5,13 @@ IF(NOT CMAKE_CROSSCOMPILING)
SET( _CMAKE_MAKE_PROGRAM_NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} VCExpress) SET( _CMAKE_MAKE_PROGRAM_NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} VCExpress)
ENDIF(NOT CMAKE_CROSSCOMPILING) ENDIF(NOT CMAKE_CROSSCOMPILING)
FIND_PROGRAM(CMAKE_MAKE_PROGRAM
NAMES MSBuild
HINTS
"$ENV{SYSTEMROOT}/Microsoft.NET/Framework/v4.0.20506/"
c:/WINDOWS/Microsoft.NET/Framework/v4.0.20506/
)
FIND_PROGRAM(CMAKE_MAKE_PROGRAM FIND_PROGRAM(CMAKE_MAKE_PROGRAM
NAMES ${_CMAKE_MAKE_PROGRAM_NAMES} NAMES ${_CMAKE_MAKE_PROGRAM_NAMES}
HINTS HINTS
@ -25,6 +32,7 @@ FIND_PROGRAM(CMAKE_MAKE_PROGRAM
"$ENV{ProgramFiles}/Microsoft Visual Studio .NET/Common7/IDE" "$ENV{ProgramFiles}/Microsoft Visual Studio .NET/Common7/IDE"
) )
MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM) MARK_AS_ADVANCED(CMAKE_MAKE_PROGRAM)
SET(MSVC10 1) SET(MSVC10 1)
SET(MSVC_VERSION 1600) SET(MSVC_VERSION 1600)

View File

@ -2767,7 +2767,10 @@ double cmCTest::GetRemainingTimeAllowed()
void cmCTest::OutputTestErrors(std::vector<char> const &process_output) void cmCTest::OutputTestErrors(std::vector<char> const &process_output)
{ {
std::string test_outputs("\n*** Test Failed:\n"); std::string test_outputs("\n*** Test Failed:\n");
test_outputs.append(&*process_output.begin(), process_output.size()); if(process_output.size())
{
test_outputs.append(&*process_output.begin(), process_output.size());
}
cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush); cmCTestLog(this, HANDLER_OUTPUT, test_outputs << std::endl << std::flush);
} }

View File

@ -96,3 +96,64 @@ std::string cmGlobalVisualStudio10Generator::GetUserMacrosRegKeyBase()
{ {
return "Software\\Microsoft\\VisualStudio\\10.0\\vsmacros"; return "Software\\Microsoft\\VisualStudio\\10.0\\vsmacros";
} }
std::string cmGlobalVisualStudio10Generator
::GenerateBuildCommand(const char* makeProgram,
const char *projectName,
const char* additionalOptions, const char *targetName,
const char* config, bool ignoreErrors, bool)
{
// Ingoring errors is not implemented in visual studio 6
(void) ignoreErrors;
// now build the test
std::string makeCommand
= cmSystemTools::ConvertToOutputPath(makeProgram);
std::string lowerCaseCommand = makeCommand;
cmSystemTools::LowerCase(lowerCaseCommand);
// if there are spaces in the makeCommand, assume a full path
// and convert it to a path with no spaces in it as the
// RunSingleCommand does not like spaces
if(makeCommand.find(' ') != std::string::npos)
{
cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
}
// msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
if(!targetName || strlen(targetName) == 0)
{
targetName = "ALL_BUILD";
}
bool clean = false;
if ( targetName && strcmp(targetName, "clean") == 0 )
{
clean = true;
makeCommand += " ";
makeCommand += projectName;
makeCommand += ".sln ";
makeCommand += "/t:Clean ";
}
else
{
makeCommand += " ";
makeCommand += targetName;
makeCommand += ".vcxproj ";
}
makeCommand += "/p:Configuration=";
if(config && strlen(config))
{
makeCommand += config;
}
else
{
makeCommand += "Debug";
}
if ( additionalOptions )
{
makeCommand += " ";
makeCommand += additionalOptions;
}
return makeCommand;
}

View File

@ -33,6 +33,12 @@ public:
static cmGlobalGenerator* New() { static cmGlobalGenerator* New() {
return new cmGlobalVisualStudio10Generator; } return new cmGlobalVisualStudio10Generator; }
virtual std::string
GenerateBuildCommand(const char* makeProgram,
const char *projectName,
const char* additionalOptions, const char *targetName,
const char* config, bool ignoreErrors, bool);
///! Get the name for the generator. ///! Get the name for the generator.
virtual const char* GetName() const { virtual const char* GetName() const {
return cmGlobalVisualStudio10Generator::GetActualName();} return cmGlobalVisualStudio10Generator::GetActualName();}

View File

@ -116,8 +116,7 @@ void cmGlobalVisualStudio71Generator
originalTargets, originalTargets,
root, generators); root, generators);
OrderedTargetDependSet orderedProjectTargets(projectTargets); OrderedTargetDependSet orderedProjectTargets(projectTargets);
this->WriteTargetsToSolution(fout, root, orderedProjectTargets, this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
originalTargets);
// Write out the configurations information for the solution // Write out the configurations information for the solution
fout << "Global\n"; fout << "Global\n";
// Write out the configurations for the solution // Write out the configurations for the solution
@ -257,7 +256,6 @@ void cmGlobalVisualStudio71Generator
const char* location, const char* location,
const std::vector<std::string>& depends) const std::vector<std::string>& depends)
{ {
std::cout << "WriteExternalProject vs71\n";
fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
<< name << "\", \"" << name << "\", \""
<< this->ConvertToSolutionPath(location) << "\", \"{" << this->ConvertToSolutionPath(location) << "\", \"{"

View File

@ -194,7 +194,6 @@ void cmGlobalVisualStudio7Generator::Generate()
// Now write out the DSW // Now write out the DSW
this->OutputSLNFile(); this->OutputSLNFile();
// If any solution or project files changed during the generation, // If any solution or project files changed during the generation,
// tell Visual Studio to reload them... // tell Visual Studio to reload them...
if(!cmSystemTools::GetErrorOccuredFlag()) if(!cmSystemTools::GetErrorOccuredFlag())
@ -240,24 +239,6 @@ void cmGlobalVisualStudio7Generator::OutputSLNFile()
} }
void cmGlobalVisualStudio7Generator::AddAllBuildDepends(
cmLocalGenerator* root,
cmTarget* target,
cmGlobalGenerator::TargetDependSet& originalTargets)
{
// if this is the special ALL_BUILD utility, then
// make it depend on every other non UTILITY project.
for(cmGlobalGenerator::TargetDependSet::iterator ot =
originalTargets.begin(); ot != originalTargets.end(); ++ot)
{
cmTarget* t = const_cast<cmTarget*>(*ot);
if(!this->IsExcluded(root, *t))
{
target->AddUtility(t->GetName());
}
}
}
void cmGlobalVisualStudio7Generator::WriteTargetConfigurations( void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
std::ostream& fout, std::ostream& fout,
cmLocalGenerator* root, cmLocalGenerator* root,
@ -296,9 +277,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
void cmGlobalVisualStudio7Generator::WriteTargetsToSolution( void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
std::ostream& fout, std::ostream& fout,
cmLocalGenerator* root, cmLocalGenerator* root,
OrderedTargetDependSet const& projectTargets, OrderedTargetDependSet const& projectTargets)
cmGlobalGenerator::TargetDependSet& originalTargets
)
{ {
std::string rootdir = root->GetMakefile()->GetStartOutputDirectory(); std::string rootdir = root->GetMakefile()->GetStartOutputDirectory();
rootdir += "/"; rootdir += "/";
@ -306,14 +285,6 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
projectTargets.begin(); tt != projectTargets.end(); ++tt) projectTargets.begin(); tt != projectTargets.end(); ++tt)
{ {
cmTarget* target = *tt; cmTarget* target = *tt;
cmMakefile* mf = target->GetMakefile();
// look for the all_build rule and add depends to all
// of the original targets (none that were "pulled" into this project)
if(mf == root->GetMakefile() &&
strcmp(target->GetName(), "ALL_BUILD") == 0)
{
this->AddAllBuildDepends(root, target, originalTargets);
}
// handle external vc project files // handle external vc project files
if (strncmp(target->GetName(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0) if (strncmp(target->GetName(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
{ {
@ -427,8 +398,7 @@ void cmGlobalVisualStudio7Generator
originalTargets, originalTargets,
root, generators); root, generators);
OrderedTargetDependSet orderedProjectTargets(projectTargets); OrderedTargetDependSet orderedProjectTargets(projectTargets);
this->WriteTargetsToSolution(fout, root, orderedProjectTargets, this->WriteTargetsToSolution(fout, root, orderedProjectTargets);
originalTargets);
// Write out the configurations information for the solution // Write out the configurations information for the solution
fout << "Global\n" fout << "Global\n"
<< "\tGlobalSection(SolutionConfiguration) = preSolution\n"; << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
@ -594,7 +564,6 @@ void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
const char* location, const char* location,
const std::vector<std::string>&) const std::vector<std::string>&)
{ {
std::cout << "WriteExternalProject vs7\n";
std::string d = cmSystemTools::ConvertToOutputPath(location); std::string d = cmSystemTools::ConvertToOutputPath(location);
fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"" fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
<< name << "\", \"" << name << "\", \""

View File

@ -128,8 +128,7 @@ protected:
virtual void WriteTargetsToSolution( virtual void WriteTargetsToSolution(
std::ostream& fout, std::ostream& fout,
cmLocalGenerator* root, cmLocalGenerator* root,
OrderedTargetDependSet const& projectTargets, OrderedTargetDependSet const& projectTargets);
cmGlobalGenerator::TargetDependSet& originalTargets);
virtual void WriteTargetDepends( virtual void WriteTargetDepends(
std::ostream& fout, std::ostream& fout,
OrderedTargetDependSet const& projectTargets); OrderedTargetDependSet const& projectTargets);
@ -138,10 +137,6 @@ protected:
cmLocalGenerator* root, cmLocalGenerator* root,
OrderedTargetDependSet const& projectTargets); OrderedTargetDependSet const& projectTargets);
void AddAllBuildDepends(cmLocalGenerator* root,
cmTarget* target,
cmGlobalGenerator::TargetDependSet& targets);
void GenerateConfigurations(cmMakefile* mf); void GenerateConfigurations(cmMakefile* mf);
virtual void WriteExternalProject(std::ostream& fout, virtual void WriteExternalProject(std::ostream& fout,

View File

@ -48,10 +48,26 @@ void cmGlobalVisualStudioGenerator::Generate()
{ {
// Use no actual command lines so that the target itself is not // Use no actual command lines so that the target itself is not
// considered always out of date. // considered always out of date.
gen[0]->GetMakefile()-> cmTarget* allBuild =
gen[0]->GetMakefile()->
AddUtilityCommand("ALL_BUILD", true, no_working_dir, AddUtilityCommand("ALL_BUILD", true, no_working_dir,
no_depends, no_commands, false, no_depends, no_commands, false,
"Build all projects"); "Build all projects");
// Now make all targets depend on the ALL_BUILD target
cmTargets targets;
for(std::vector<cmLocalGenerator*>::iterator i = gen.begin();
i != gen.end(); ++i)
{
cmTargets& targets = (*i)->GetMakefile()->GetTargets();
for(cmTargets::iterator t = targets.begin();
t != targets.end(); ++t)
{
if(!this->IsExcluded(gen[0], t->second))
{
allBuild->AddUtility(t->second.GetName());
}
}
}
} }
} }

View File

@ -23,7 +23,7 @@
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator() cmLocalVisualStudio10Generator::cmLocalVisualStudio10Generator()
{ {
this->NeedXMLEscape = true;
} }
cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator() cmLocalVisualStudio10Generator::~cmLocalVisualStudio10Generator()

View File

@ -1405,26 +1405,14 @@ cmLocalVisualStudio7GeneratorFCInfo
} }
} }
void cmLocalVisualStudio7Generator void cmLocalVisualStudio7Generator
::WriteGroup(const cmSourceGroup *sg, cmTarget& target, ::ComputeMaxDirectoryLength(std::string& maxdir,
std::ostream &fout, const char *libName, cmTarget& target)
std::vector<std::string> *configs) {
{ std::vector<std::string> *configs =
const std::vector<const cmSourceFile *> &sourceFiles = static_cast<cmGlobalVisualStudio7Generator *>
sg->GetSourceFiles(); (this->GlobalGenerator)->GetConfigurations();
// If the group is empty, don't write it at all.
if(sourceFiles.empty() && sg->GetGroupChildren().empty())
{
return;
}
// If the group has a name, write the header.
std::string name = sg->GetName();
if(name != "")
{
this->WriteVCProjBeginGroup(fout, name.c_str(), "");
}
// Compute the maximum length configuration name. // Compute the maximum length configuration name.
std::string config_max; std::string config_max;
for(std::vector<std::string>::iterator i = configs->begin(); for(std::vector<std::string>::iterator i = configs->begin();
@ -1446,6 +1434,34 @@ void cmLocalVisualStudio7Generator
dir_max += "/"; dir_max += "/";
dir_max += config_max; dir_max += config_max;
dir_max += "/"; dir_max += "/";
maxdir = dir_max;
}
void cmLocalVisualStudio7Generator
::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
std::ostream &fout, const char *libName,
std::vector<std::string> *configs)
{
const std::vector<const cmSourceFile *> &sourceFiles =
sg->GetSourceFiles();
// If the group is empty, don't write it at all.
if(sourceFiles.empty() && sg->GetGroupChildren().empty())
{
return;
}
// If the group has a name, write the header.
std::string name = sg->GetName();
if(name != "")
{
this->WriteVCProjBeginGroup(fout, name.c_str(), "");
}
// Compute the maximum length full path to the intermediate
// files directory for any configuration. This is used to construct
// object file names that do not produce paths that are too long.
std::string dir_max;
this->ComputeMaxDirectoryLength(dir_max, target);
// Loop through each source in the source group. // Loop through each source in the source group.
std::string objectName; std::string objectName;

View File

@ -72,10 +72,15 @@ public:
virtual std::string GetTargetDirectory(cmTarget const&) const; virtual std::string GetTargetDirectory(cmTarget const&) const;
cmSourceFile* CreateVCProjBuildRule(); cmSourceFile* CreateVCProjBuildRule();
void WriteStampFiles(); void WriteStampFiles();
void ComputeMaxDirectoryLength(std::string& maxdir,
cmTarget& target);
private: private:
typedef cmLocalVisualStudio7GeneratorOptions Options; typedef cmLocalVisualStudio7GeneratorOptions Options;
typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo; typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo;
// Compute the maximum length full path to the intermediate
// files directory for any configuration. This is used to construct
// object file names that do not produce paths that are too long.
void ReadAndStoreExternalGUID(const char* name, void ReadAndStoreExternalGUID(const char* name,
const char* path); const char* path);
std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags, std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,

View File

@ -26,6 +26,7 @@ cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator()
{ {
this->WindowsShell = true; this->WindowsShell = true;
this->WindowsVSIDE = true; this->WindowsVSIDE = true;
this->NeedXMLEscape = false;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -231,8 +232,26 @@ cmLocalVisualStudioGenerator
} }
else else
{ {
script += this->EscapeForShell(commandLine[j].c_str(), if(this->NeedXMLEscape)
{
std::string arg = commandLine[j];
cmSystemTools::ReplaceString(arg, "&", "&amp;");
cmSystemTools::ReplaceString(arg, "<", "&lt;");
cmSystemTools::ReplaceString(arg, ">", "&gt;");
if(arg.find(" ") != arg.npos)
{
std::string q("\"");
arg = q + arg +q;
}
script += arg;
//script += this->EscapeForShell(arg.c_str(),
//escapeAllowMakeVars);
}
else
{
script += this->EscapeForShell(commandLine[j].c_str(),
escapeAllowMakeVars); escapeAllowMakeVars);
}
} }
} }
} }

View File

@ -56,8 +56,9 @@ protected:
std::map<cmStdString, int>& count); std::map<cmStdString, int>& count);
void InsertNeedObjectNames(const std::vector<cmSourceGroup>& groups, void InsertNeedObjectNames(const std::vector<cmSourceGroup>& groups,
std::map<cmStdString, int>& count); std::map<cmStdString, int>& count);
bool NeedXMLEscape;
std::set<const cmSourceFile*> NeedObjectName; std::set<const cmSourceFile*> NeedObjectName;
friend class cmVisualStudio10TargetGenerator;
}; };
#endif #endif

View File

@ -1992,6 +1992,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config)
msg += " which has type "; msg += " which has type ";
msg += cmTarget::TargetTypeNames[this->GetType()]; msg += cmTarget::TargetTypeNames[this->GetType()];
this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg);
abort();
return 0; return 0;
} }

View File

@ -43,10 +43,16 @@ cmVisualStudio10TargetGenerator(cmTarget* target,
(cmLocalVisualStudio7Generator*) (cmLocalVisualStudio7Generator*)
this->Makefile->GetLocalGenerator(); this->Makefile->GetLocalGenerator();
this->Platform = "|Win32"; this->Platform = "|Win32";
this->ComputeObjectNames();
} }
cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator() cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
{ {
if (this->BuildFileStream->Close())
{
this->GlobalGenerator
->FileReplacedDuringGenerate(this->PathToVcxproj);
}
delete this->BuildFileStream; delete this->BuildFileStream;
} }
@ -104,6 +110,7 @@ void cmVisualStudio10TargetGenerator::Generate()
path += ".vcxproj"; path += ".vcxproj";
this->BuildFileStream = this->BuildFileStream =
new cmGeneratedFileStream(path.c_str()); new cmGeneratedFileStream(path.c_str());
this->PathToVcxproj = path;
this->BuildFileStream->SetCopyIfDifferent(true); this->BuildFileStream->SetCopyIfDifferent(true);
// Write the encoding header into the file // Write the encoding header into the file
@ -382,45 +389,39 @@ void cmVisualStudio10TargetGenerator::WriteObjSources()
void cmVisualStudio10TargetGenerator::WriteCLSources() void cmVisualStudio10TargetGenerator::WriteCLSources()
{ {
this->WriteString("<ItemGroup>\n", 1);
if(this->Target->GetType() > cmTarget::MODULE_LIBRARY) if(this->Target->GetType() > cmTarget::MODULE_LIBRARY)
{ {
this->WriteString("<None Include=\"", 2); return;
(*this->BuildFileStream ) << this->Target->GetDirectory()
<< "\\" << this->Target->GetName()
<< "\" />\n";
} }
else 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)
{ {
std::vector<cmSourceFile*>const& sources = this->Target->GetSourceFiles(); // if it is not a custom command then add it as a c/c++ file,
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin(); // TODO: need to check for idl or rc
source != sources.end(); ++source) if(!(*source)->GetCustomCommand()
&& !(*source)->GetPropertyAsBool("HEADER_FILE_ONLY")
&& !this->GlobalGenerator->IgnoreFile
((*source)->GetExtension().c_str()))
{ {
// if it is not a custom command then add it as a c/c++ file, const char* lang = (*source)->GetLanguage();
// TODO: need to check for idl or rc if(lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0))
if(!(*source)->GetCustomCommand()
&& !(*source)->GetPropertyAsBool("HEADER_FILE_ONLY")
&& !this->GlobalGenerator->IgnoreFile
((*source)->GetExtension().c_str()))
{ {
const char* lang = (*source)->GetLanguage(); std::string sourceFile = (*source)->GetFullPath();
if(lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0)) // output the source file
this->WriteString("<ClCompile Include=\"", 2);
(*this->BuildFileStream ) << sourceFile << "\"";
// ouput any flags specific to this source file
if(this->OutputSourceSpecificFlags(*source))
{ {
std::string sourceFile = (*source)->GetFullPath(); // if the source file has specific flags the tag
// output the source file // is ended on a new line
this->WriteString("<ClCompile Include=\"", 2); this->WriteString("</ClCompile>\n", 2);
(*this->BuildFileStream ) << sourceFile << "\""; }
// ouput any flags specific to this source file else
if(this->OutputSourceSpecificFlags(*source)) {
{ (*this->BuildFileStream ) << " />\n";
// if the source file has specific flags the tag
// is ended on a new line
this->WriteString("</ClCompile>\n", 2);
}
else
{
(*this->BuildFileStream ) << " />\n";
}
} }
} }
} }
@ -428,10 +429,48 @@ void cmVisualStudio10TargetGenerator::WriteCLSources()
this->WriteString("</ItemGroup>\n", 1); this->WriteString("</ItemGroup>\n", 1);
} }
void cmVisualStudio10TargetGenerator::ComputeObjectNames()
{
// We may be modifying the source groups temporarily, so make a copy.
std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
// get the classes from the source lists then add them to the groups
std::vector<cmSourceFile*>const & classes = this->Target->GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); i++)
{
// Add the file to the list of sources.
std::string source = (*i)->GetFullPath();
if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF")
{
this->ModuleDefinitionFile = (*i)->GetFullPath();
}
cmSourceGroup& sourceGroup =
this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
sourceGroup.AssignSource(*i);
}
// Compute which sources need unique object computation.
this->LocalGenerator->ComputeObjectNameRequirements(sourceGroups);
}
bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
cmSourceFile* source) cmSourceFile* source)
{ {
cmSourceFile& sf = *source; cmSourceFile& sf = *source;
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
// Compute the maximum length full path to the intermediate
// files directory for any configuration. This is used to construct
// object file names that do not produce paths that are too long.
std::string dir_max;
lg->ComputeMaxDirectoryLength(dir_max, *this->Target);
std::string objectName;
if(lg->NeedObjectName.find(&sf) != lg->NeedObjectName.end())
{
objectName = lg->GetObjectFileNameWithoutTarget(sf, dir_max);
}
std::string flags; std::string flags;
std::string defines; std::string defines;
if(const char* cflags = sf.GetProperty("COMPILE_FLAGS")) if(const char* cflags = sf.GetProperty("COMPILE_FLAGS"))
@ -470,13 +509,22 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
flags += " /TC "; flags += " /TC ";
} }
} }
bool hasFlags = false;
// for the first time we need a new line if there is something // for the first time we need a new line if there is something
// produced here. // produced here.
const char* firstString = ">\n"; const char* firstString = ">\n";
if(objectName.size())
{
(*this->BuildFileStream ) << firstString;
firstString = "";
hasFlags = true;
this->WriteString("<ObjectFileName>", 3);
(*this->BuildFileStream )
<< "$(Configuration)/" << objectName << "</ObjectFileName>\n";
}
std::vector<std::string> *configs = std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *> static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations(); (this->GlobalGenerator)->GetConfigurations();
bool hasFlags = false;
for( std::vector<std::string>::iterator config = configs->begin(); for( std::vector<std::string>::iterator config = configs->begin();
config != configs->end(); ++config) config != configs->end(); ++config)
{ {
@ -519,6 +567,10 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
{ {
if(this->Target->GetType() > cmTarget::MODULE_LIBRARY)
{
return;
}
this->WriteString("<PropertyGroup>\n", 2); this->WriteString("<PropertyGroup>\n", 2);
this->WriteString("<_ProjectFileVersion>10.0.20506.1" this->WriteString("<_ProjectFileVersion>10.0.20506.1"
"</_ProjectFileVersion>\n", 3); "</_ProjectFileVersion>\n", 3);
@ -672,6 +724,12 @@ WriteClOptions(std::string const& configName,
flags += " /TP "; flags += " /TP ";
} }
} }
// Add the target-specific flags.
if(const char* targetFlags = this->Target->GetProperty("COMPILE_FLAGS"))
{
flags += " ";
flags += targetFlags;
}
std::string configUpper = cmSystemTools::UpperCase(configName); std::string configUpper = cmSystemTools::UpperCase(configName);
std::string defPropName = "COMPILE_DEFINITIONS_"; std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper; defPropName += configUpper;
@ -877,8 +935,13 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&
for(std::vector<std::string>::const_iterator d = ldirs.begin(); for(std::vector<std::string>::const_iterator d = ldirs.begin();
d != ldirs.end(); ++d) d != ldirs.end(); ++d)
{ {
// first just full path
linkDirs += sep; linkDirs += sep;
linkDirs += *d; linkDirs += *d;
linkDirs += sep;
// next path with configuration type Debug, Release, etc
linkDirs += *d;
linkDirs += "/$(Configuration)";
sep = ";"; sep = ";";
} }
linkDirs += "%(AdditionalLibraryDirectories)"; linkDirs += "%(AdditionalLibraryDirectories)";
@ -910,9 +973,10 @@ void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&
targetNameImport, targetNamePDB, targetNameImport, targetNamePDB,
config.c_str()); config.c_str());
} }
std::string dir = this->Target->GetDirectory(config.c_str()); std::string imLib = this->Target->GetDirectory(config.c_str(), true);
std::string dir = this->Target->GetDirectory(config.c_str(), true);
dir += "/"; dir += "/";
std::string imLib = dir; imLib += "/";
imLib += targetNameImport; imLib += targetNameImport;
std::string pdb = dir; std::string pdb = dir;
pdb += targetNamePDB; pdb += targetNamePDB;
@ -997,6 +1061,8 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
} }
// output midl flags <Midl></Midl> // output midl flags <Midl></Midl>
this->WriteMidlOptions(*i, includes); this->WriteMidlOptions(*i, includes);
// write events
this->WriteEvents(*i);
// output link flags <Link></Link> // output link flags <Link></Link>
this->WriteLinkOptions(*i); this->WriteLinkOptions(*i);
// output lib flags <Lib></Lib> // output lib flags <Lib></Lib>
@ -1005,16 +1071,78 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
} }
} }
void
cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
{
this->WriteEvent("PreLinkEvent",
this->Target->GetPreLinkCommands(), configName);
this->WriteEvent("PreBuildEvent",
this->Target->GetPreBuildCommands(), configName);
this->WriteEvent("PostBuildEvent",
this->Target->GetPostBuildCommands(), configName);
}
void cmVisualStudio10TargetGenerator::WriteEvent(
const char* name,
std::vector<cmCustomCommand> & commands,
std::string const& configName)
{
if(commands.size() == 0)
{
return;
}
this->WriteString("<", 2);
(*this->BuildFileStream ) << name << ">\n";
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
std::string script;
const char* pre = "";
std::string comment;
for(std::vector<cmCustomCommand>::iterator i = commands.begin();
i != commands.end(); ++i)
{
cmCustomCommand& command = *i;
comment += pre;
comment += lg->ConstructComment(command);
script += pre;
pre = "\n";
script +=
lg->ConstructScript(command.GetCommandLines(),
command.GetWorkingDirectory(),
configName.c_str(),
command.GetEscapeOldStyle(),
command.GetEscapeAllowMakeVars());
}
this->WriteString("<Message>",3);
(*this->BuildFileStream ) << comment << "</Message>\n";
this->WriteString("<Command>", 3);
(*this->BuildFileStream ) << script;
(*this->BuildFileStream ) << "</Command>" << "\n";
this->WriteString("</", 2);
(*this->BuildFileStream ) << name << ">\n";
}
void cmVisualStudio10TargetGenerator::WriteProjectReferences() void cmVisualStudio10TargetGenerator::WriteProjectReferences()
{ {
// TODO cmGlobalGenerator::TargetDependSet& depends
// This should have dependent targets listed like this: = this->GlobalGenerator->GetTargetDirectDepends(*this->Target);
/* this->WriteString("<ItemGroup>\n", 1);
<ItemGroup> for( cmGlobalGenerator::TargetDependSet::const_iterator i = depends.begin();
<ProjectReference Include="ZERO_CHECK.vcxproj"> i != depends.end(); ++i)
<Project>{2f1e4f3c-0a51-46c3-aaf9-e486599604f2}</Project> {
</ProjectReference> cmTarget* dt = *i;
</ItemGroup> this->WriteString("<ProjectReference Include=\"", 2);
*/ cmMakefile* mf = dt->GetMakefile();
std::string path = mf->GetStartOutputDirectory();
path += "/";
path += dt->GetName();
path += ".vcxproj";
(*this->BuildFileStream) << path << "\">\n";
this->WriteString("<Project>", 3);
(*this->BuildFileStream)
<< this->GlobalGenerator->GetGUID(dt->GetName())
<< "</Project>\n";
this->WriteString("</ProjectReference>\n", 2);
}
this->WriteString("</ItemGroup>\n", 1);
} }

View File

@ -70,7 +70,13 @@ private:
bool OutputSourceSpecificFlags(cmSourceFile* source); bool OutputSourceSpecificFlags(cmSourceFile* source);
void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring); void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring);
void WriteLibOptions(std::string const& config); void WriteLibOptions(std::string const& config);
void WriteEvents(std::string const& configName);
void WriteEvent(const char* name, std::vector<cmCustomCommand> & commands,
std::string const& configName);
void ComputeObjectNames();
private: private:
std::string ModuleDefinitionFile;
std::string PathToVcxproj;
cmTarget* Target; cmTarget* Target;
cmMakefile* Makefile; cmMakefile* Makefile;
std::string Platform; std::string Platform;

View File

@ -52,9 +52,9 @@ DEFINE_PROPERTY(
FULL_DOCS "A simple etst proerty that means nothign and is used for nothing" FULL_DOCS "A simple etst proerty that means nothign and is used for nothing"
) )
SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES FOO BAR) SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES FOO BAR)
IF(NOT BEOS) # No libm on BeOS. IF(NOT BEOS AND NOT WIN32) # No libm on BeOS.
SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES LINK_FLAGS "-lm") SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES LINK_FLAGS "-lm")
ENDIF(NOT BEOS) ENDIF(NOT BEOS AND NOT WIN32)
GET_TARGET_PROPERTY(FOO_BAR_VAR CMakeTestCLibraryShared FOO) GET_TARGET_PROPERTY(FOO_BAR_VAR CMakeTestCLibraryShared FOO)
IF(${FOO_BAR_VAR} MATCHES "BAR") IF(${FOO_BAR_VAR} MATCHES "BAR")
ELSE(${FOO_BAR_VAR} MATCHES "BAR") ELSE(${FOO_BAR_VAR} MATCHES "BAR")

View File

@ -52,9 +52,9 @@ DEFINE_PROPERTY(
FULL_DOCS "A simple etst proerty that means nothign and is used for nothing" FULL_DOCS "A simple etst proerty that means nothign and is used for nothing"
) )
SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES FOO BAR) SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES FOO BAR)
IF(NOT BEOS) # No libm on BeOS. IF(NOT BEOS AND NOT WIN32) # No libm on BeOS.
SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES LINK_FLAGS "-lm") SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES LINK_FLAGS "-lm")
ENDIF(NOT BEOS) ENDIF(NOT BEOS AND NOT WIN32)
GET_TARGET_PROPERTY(FOO_BAR_VAR CMakeTestCLibraryShared FOO) GET_TARGET_PROPERTY(FOO_BAR_VAR CMakeTestCLibraryShared FOO)
IF(${FOO_BAR_VAR} MATCHES "BAR") IF(${FOO_BAR_VAR} MATCHES "BAR")
ELSE(${FOO_BAR_VAR} MATCHES "BAR") ELSE(${FOO_BAR_VAR} MATCHES "BAR")

View File

@ -52,9 +52,9 @@ DEFINE_PROPERTY(
FULL_DOCS "A simple etst proerty that means nothign and is used for nothing" FULL_DOCS "A simple etst proerty that means nothign and is used for nothing"
) )
SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES FOO BAR) SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES FOO BAR)
IF(NOT BEOS) # No libm on BeOS. IF(NOT BEOS AND NOT WIN32) # No libm on BeOS.
SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES LINK_FLAGS "-lm") SET_TARGET_PROPERTIES(CMakeTestCLibraryShared PROPERTIES LINK_FLAGS "-lm")
ENDIF(NOT BEOS) ENDIF(NOT BEOS AND NOT WIN32)
GET_TARGET_PROPERTY(FOO_BAR_VAR CMakeTestCLibraryShared FOO) GET_TARGET_PROPERTY(FOO_BAR_VAR CMakeTestCLibraryShared FOO)
IF(${FOO_BAR_VAR} MATCHES "BAR") IF(${FOO_BAR_VAR} MATCHES "BAR")
ELSE(${FOO_BAR_VAR} MATCHES "BAR") ELSE(${FOO_BAR_VAR} MATCHES "BAR")