2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2009-06-26 00:41:57 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2009-06-26 00:41:57 +04:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2009-06-26 00:41:57 +04:00
|
|
|
#include "cmVisualStudio10TargetGenerator.h"
|
2009-10-22 16:24:11 +04:00
|
|
|
#include "cmGlobalVisualStudio10Generator.h"
|
2012-03-07 20:56:21 +04:00
|
|
|
#include "cmGeneratorTarget.h"
|
2009-06-26 00:41:57 +04:00
|
|
|
#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"
|
2009-06-28 16:59:56 +04:00
|
|
|
#include "cmVS10LibFlagTable.h"
|
2009-06-26 00:41:57 +04:00
|
|
|
|
2009-10-23 19:34:37 +04:00
|
|
|
#include <cmsys/auto_ptr.hxx>
|
|
|
|
|
2009-09-07 18:11:20 +04:00
|
|
|
static std::string cmVS10EscapeXML(std::string arg)
|
|
|
|
{
|
|
|
|
cmSystemTools::ReplaceString(arg, "&", "&");
|
|
|
|
cmSystemTools::ReplaceString(arg, "<", "<");
|
|
|
|
cmSystemTools::ReplaceString(arg, ">", ">");
|
|
|
|
return arg;
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
|
2010-10-02 00:12:00 +04:00
|
|
|
static std::string cmVS10EscapeComment(std::string comment)
|
|
|
|
{
|
|
|
|
// MSBuild takes the CDATA of a <Message></Message> element and just
|
|
|
|
// does "echo $CDATA" with no escapes. We must encode the string.
|
|
|
|
// http://technet.microsoft.com/en-us/library/cc772462%28WS.10%29.aspx
|
|
|
|
std::string echoable;
|
|
|
|
for(std::string::iterator c = comment.begin(); c != comment.end(); ++c)
|
|
|
|
{
|
|
|
|
switch (*c)
|
|
|
|
{
|
|
|
|
case '\r': break;
|
|
|
|
case '\n': echoable += '\t'; break;
|
|
|
|
case '"': /* no break */
|
|
|
|
case '|': /* no break */
|
|
|
|
case '&': /* no break */
|
|
|
|
case '<': /* no break */
|
|
|
|
case '>': /* no break */
|
|
|
|
case '^': echoable += '^'; /* no break */
|
|
|
|
default: echoable += *c; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return echoable;
|
|
|
|
}
|
|
|
|
|
2009-06-26 00:41:57 +04:00
|
|
|
cmVisualStudio10TargetGenerator::
|
|
|
|
cmVisualStudio10TargetGenerator(cmTarget* target,
|
2009-10-22 16:24:11 +04:00
|
|
|
cmGlobalVisualStudio10Generator* gg)
|
2009-06-26 00:41:57 +04:00
|
|
|
{
|
|
|
|
this->GlobalGenerator = gg;
|
|
|
|
this->Target = target;
|
2012-03-07 20:56:21 +04:00
|
|
|
this->GeneratorTarget = gg->GetGeneratorTarget(target);
|
2009-06-26 00:41:57 +04:00
|
|
|
this->Makefile = target->GetMakefile();
|
|
|
|
this->LocalGenerator =
|
|
|
|
(cmLocalVisualStudio7Generator*)
|
|
|
|
this->Makefile->GetLocalGenerator();
|
2009-07-14 22:16:46 +04:00
|
|
|
this->Name = this->Target->GetName();
|
|
|
|
this->GlobalGenerator->CreateGUID(this->Name.c_str());
|
|
|
|
this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
|
2009-10-22 16:24:11 +04:00
|
|
|
this->Platform = gg->GetPlatformName();
|
2009-07-14 00:58:24 +04:00
|
|
|
this->BuildFileStream = 0;
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
|
|
|
|
{
|
2009-10-23 19:34:37 +04:00
|
|
|
for(OptionsMap::iterator i = this->ClOptions.begin();
|
|
|
|
i != this->ClOptions.end(); ++i)
|
|
|
|
{
|
|
|
|
delete i->second;
|
|
|
|
}
|
2009-07-14 00:58:24 +04:00
|
|
|
if(!this->BuildFileStream)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2009-07-10 17:12:39 +04:00
|
|
|
if (this->BuildFileStream->Close())
|
|
|
|
{
|
|
|
|
this->GlobalGenerator
|
|
|
|
->FileReplacedDuringGenerate(this->PathToVcxproj);
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
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
|
2009-06-26 19:50:09 +04:00
|
|
|
<< " Condition=\"'$(Configuration)|$(Platform)'=='";
|
2009-10-22 16:24:11 +04:00
|
|
|
(*stream ) << config << "|" << this->Platform << "'\"";
|
2009-06-26 00:41:57 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2009-10-22 18:21:35 +04:00
|
|
|
#define VS10_USER_PROPS "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props"
|
2009-07-14 00:58:24 +04:00
|
|
|
|
2009-06-26 00:41:57 +04:00
|
|
|
void cmVisualStudio10TargetGenerator::Generate()
|
2009-07-14 22:16:46 +04:00
|
|
|
{
|
|
|
|
// do not generate external ms projects
|
|
|
|
if(this->Target->GetProperty("EXTERNAL_MSPROJECT"))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
// Tell the global generator the name of the project file
|
2009-07-14 00:58:24 +04:00
|
|
|
this->Target->SetProperty("GENERATOR_FILE_NAME",this->Name.c_str());
|
2009-06-26 00:41:57 +04:00
|
|
|
this->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
|
|
|
|
".vcxproj");
|
2012-03-12 18:55:07 +04:00
|
|
|
if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
|
2009-10-23 19:34:37 +04:00
|
|
|
{
|
2010-09-30 16:48:38 +04:00
|
|
|
if(!this->ComputeClOptions())
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2009-10-23 19:34:37 +04:00
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
cmMakefile* mf = this->Target->GetMakefile();
|
|
|
|
std::string path = mf->GetStartOutputDirectory();
|
|
|
|
path += "/";
|
2009-07-14 00:58:24 +04:00
|
|
|
path += this->Name;
|
2009-06-26 00:41:57 +04:00
|
|
|
path += ".vcxproj";
|
|
|
|
this->BuildFileStream =
|
|
|
|
new cmGeneratedFileStream(path.c_str());
|
2009-07-10 17:12:39 +04:00
|
|
|
this->PathToVcxproj = path;
|
2009-06-26 00:41:57 +04:00
|
|
|
this->BuildFileStream->SetCopyIfDifferent(true);
|
|
|
|
|
|
|
|
// Write the encoding header into the file
|
|
|
|
char magic[] = {0xEF,0xBB, 0xBF};
|
|
|
|
this->BuildFileStream->write(magic, 3);
|
2011-02-09 20:59:09 +03:00
|
|
|
this->WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",0);
|
2009-06-26 00:41:57 +04:00
|
|
|
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";
|
|
|
|
|
2011-11-23 23:11:00 +04:00
|
|
|
const char* vsProjectTypes =
|
|
|
|
this->Target->GetProperty("VS_GLOBAL_PROJECT_TYPES");
|
|
|
|
if(vsProjectTypes)
|
|
|
|
{
|
|
|
|
this->WriteString("<ProjectTypes>", 2);
|
|
|
|
(*this->BuildFileStream) << cmVS10EscapeXML(vsProjectTypes) <<
|
|
|
|
"</ProjectTypes>\n";
|
|
|
|
}
|
|
|
|
|
2011-06-14 17:45:52 +04:00
|
|
|
const char* vsProjectName = this->Target->GetProperty("VS_SCC_PROJECTNAME");
|
|
|
|
const char* vsLocalPath = this->Target->GetProperty("VS_SCC_LOCALPATH");
|
|
|
|
const char* vsProvider = this->Target->GetProperty("VS_SCC_PROVIDER");
|
|
|
|
|
2011-11-01 04:04:08 +04:00
|
|
|
if( vsProjectName && vsLocalPath && vsProvider )
|
2011-06-14 17:45:52 +04:00
|
|
|
{
|
|
|
|
this->WriteString("<SccProjectName>", 2);
|
|
|
|
(*this->BuildFileStream) << cmVS10EscapeXML(vsProjectName) <<
|
|
|
|
"</SccProjectName>\n";
|
|
|
|
this->WriteString("<SccLocalPath>", 2);
|
|
|
|
(*this->BuildFileStream) << cmVS10EscapeXML(vsLocalPath) <<
|
|
|
|
"</SccLocalPath>\n";
|
|
|
|
this->WriteString("<SccProvider>", 2);
|
|
|
|
(*this->BuildFileStream) << cmVS10EscapeXML(vsProvider) <<
|
|
|
|
"</SccProvider>\n";
|
2011-11-01 04:04:08 +04:00
|
|
|
|
|
|
|
const char* vsAuxPath = this->Target->GetProperty("VS_SCC_AUXPATH");
|
|
|
|
if( vsAuxPath )
|
|
|
|
{
|
|
|
|
this->WriteString("<SccAuxPath>", 2);
|
|
|
|
(*this->BuildFileStream) << cmVS10EscapeXML(vsAuxPath) <<
|
|
|
|
"</SccAuxPath>\n";
|
|
|
|
}
|
2011-06-14 17:45:52 +04:00
|
|
|
}
|
|
|
|
|
2011-11-23 23:11:00 +04:00
|
|
|
const char* vsGlobalKeyword =
|
|
|
|
this->Target->GetProperty("VS_GLOBAL_KEYWORD");
|
|
|
|
if(!vsGlobalKeyword)
|
|
|
|
{
|
|
|
|
this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->WriteString("<Keyword>", 2);
|
|
|
|
(*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword) <<
|
|
|
|
"</Keyword>\n";
|
|
|
|
}
|
|
|
|
|
2009-10-22 16:24:11 +04:00
|
|
|
this->WriteString("<Platform>", 2);
|
|
|
|
(*this->BuildFileStream) << this->Platform << "</Platform>\n";
|
2010-09-10 00:21:57 +04:00
|
|
|
const char* projLabel = this->Target->GetProperty("PROJECT_LABEL");
|
|
|
|
if(!projLabel)
|
|
|
|
{
|
|
|
|
projLabel = this->Name.c_str();
|
|
|
|
}
|
|
|
|
this->WriteString("<ProjectName>", 2);
|
|
|
|
(*this->BuildFileStream) << projLabel << "</ProjectName>\n";
|
2009-06-26 00:41:57 +04:00
|
|
|
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);
|
2009-10-22 18:21:35 +04:00
|
|
|
this->WriteString("<Import Project=\"" VS10_USER_PROPS "\""
|
|
|
|
" Condition=\"exists('" VS10_USER_PROPS "')\""
|
|
|
|
" Label=\"LocalAppDataPlatform\" />", 2);
|
2009-06-26 00:41:57 +04:00
|
|
|
this->WriteString("</ImportGroup>\n", 1);
|
|
|
|
this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1);
|
|
|
|
this->WritePathAndIncrementalLinkOptions();
|
|
|
|
this->WriteItemDefinitionGroups();
|
|
|
|
this->WriteCustomCommands();
|
2009-06-26 06:53:02 +04:00
|
|
|
this->WriteObjSources();
|
|
|
|
this->WriteCLSources();
|
2011-11-23 23:11:00 +04:00
|
|
|
this->WriteDotNetReferences();
|
2012-02-03 18:07:12 +04:00
|
|
|
this->WriteWinRTReferences();
|
2009-06-26 00:41:57 +04:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
|
2011-11-23 23:11:00 +04:00
|
|
|
void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
|
|
|
|
{
|
2012-02-03 23:32:17 +04:00
|
|
|
std::vector<std::string> references;
|
|
|
|
if(const char* vsDotNetReferences =
|
|
|
|
this->Target->GetProperty("VS_DOTNET_REFERENCES"))
|
|
|
|
{
|
|
|
|
cmSystemTools::ExpandListArgument(vsDotNetReferences, references);
|
|
|
|
}
|
|
|
|
if(!references.empty())
|
2011-11-23 23:11:00 +04:00
|
|
|
{
|
|
|
|
this->WriteString("<ItemGroup>\n", 1);
|
2012-02-03 23:32:17 +04:00
|
|
|
for(std::vector<std::string>::iterator ri = references.begin();
|
|
|
|
ri != references.end(); ++ri)
|
2011-11-23 23:11:00 +04:00
|
|
|
{
|
|
|
|
this->WriteString("<Reference Include=\"", 2);
|
2012-02-03 23:32:17 +04:00
|
|
|
(*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\">\n";
|
2011-11-23 23:11:00 +04:00
|
|
|
this->WriteString("<CopyLocalSatelliteAssemblies>true"
|
|
|
|
"</CopyLocalSatelliteAssemblies>\n", 3);
|
|
|
|
this->WriteString("<ReferenceOutputAssembly>true"
|
|
|
|
"</ReferenceOutputAssembly>\n", 3);
|
|
|
|
this->WriteString("</Reference>\n", 2);
|
|
|
|
}
|
|
|
|
this->WriteString("</ItemGroup>\n", 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-03 18:07:12 +04:00
|
|
|
void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
|
|
|
|
{
|
2012-02-03 23:32:17 +04:00
|
|
|
std::vector<std::string> references;
|
|
|
|
if(const char* vsWinRTReferences =
|
|
|
|
this->Target->GetProperty("VS_WINRT_REFERENCES"))
|
|
|
|
{
|
|
|
|
cmSystemTools::ExpandListArgument(vsWinRTReferences, references);
|
|
|
|
}
|
|
|
|
if(!references.empty())
|
2012-02-03 18:07:12 +04:00
|
|
|
{
|
|
|
|
this->WriteString("<ItemGroup>\n", 1);
|
2012-02-03 23:32:17 +04:00
|
|
|
for(std::vector<std::string>::iterator ri = references.begin();
|
|
|
|
ri != references.end(); ++ri)
|
2012-02-03 18:07:12 +04:00
|
|
|
{
|
|
|
|
this->WriteString("<Reference Include=\"", 2);
|
2012-02-03 23:32:17 +04:00
|
|
|
(*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\">\n";
|
2012-02-03 18:07:12 +04:00
|
|
|
this->WriteString("<IsWinMDFile>true</IsWinMDFile>\n", 3);
|
|
|
|
this->WriteString("</Reference>\n", 2);
|
|
|
|
}
|
|
|
|
this->WriteString("</ItemGroup>\n", 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-26 00:41:57 +04:00
|
|
|
// 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);
|
2009-10-22 16:24:11 +04:00
|
|
|
(*this->BuildFileStream ) << *i << "|" << this->Platform << "\">\n";
|
2009-06-26 00:41:57 +04:00
|
|
|
this->WriteString("<Configuration>", 3);
|
|
|
|
(*this->BuildFileStream ) << *i << "</Configuration>\n";
|
2009-10-22 16:24:11 +04:00
|
|
|
this->WriteString("<Platform>", 3);
|
|
|
|
(*this->BuildFileStream) << this->Platform << "</Platform>\n";
|
2009-06-26 00:41:57 +04:00
|
|
|
this->WriteString("</ProjectConfiguration>\n", 2);
|
|
|
|
}
|
|
|
|
this->WriteString("</ItemGroup>\n", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
|
|
|
|
{
|
2010-12-01 20:48:32 +03:00
|
|
|
cmGlobalVisualStudio10Generator* gg =
|
|
|
|
static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
|
2009-06-26 00:41:57 +04:00
|
|
|
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;
|
2012-03-12 18:55:07 +04:00
|
|
|
case cmTarget::OBJECT_LIBRARY:
|
2009-06-26 00:41:57 +04:00
|
|
|
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);
|
2011-11-04 21:29:41 +04:00
|
|
|
|
2009-06-26 00:41:57 +04:00
|
|
|
const char* mfcFlag =
|
|
|
|
this->Target->GetMakefile()->GetDefinition("CMAKE_MFC_FLAG");
|
2011-11-04 21:29:41 +04:00
|
|
|
std::string mfcFlagValue = mfcFlag ? mfcFlag : "0";
|
|
|
|
|
|
|
|
std::string useOfMfcValue = "false";
|
|
|
|
if(mfcFlagValue == "1")
|
2009-06-26 00:41:57 +04:00
|
|
|
{
|
2011-11-04 21:29:41 +04:00
|
|
|
useOfMfcValue = "Static";
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
2011-11-04 21:29:41 +04:00
|
|
|
else if(mfcFlagValue == "2")
|
2009-06-26 00:41:57 +04:00
|
|
|
{
|
2011-11-04 21:29:41 +04:00
|
|
|
useOfMfcValue = "Dynamic";
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
2011-11-04 21:29:41 +04:00
|
|
|
std::string mfcLine = "<UseOfMfc>";
|
|
|
|
mfcLine += useOfMfcValue + "</UseOfMfc>\n";
|
|
|
|
this->WriteString(mfcLine.c_str(), 2);
|
|
|
|
|
2012-03-12 18:55:07 +04:00
|
|
|
if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY &&
|
2012-02-03 18:07:12 +04:00
|
|
|
this->ClOptions[*i]->UsingUnicode() ||
|
|
|
|
this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
|
2009-10-23 19:34:37 +04:00
|
|
|
{
|
|
|
|
this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
|
|
|
|
}
|
2012-02-17 01:27:05 +04:00
|
|
|
else if (this->Target->GetType() <= cmTarget::MODULE_LIBRARY &&
|
|
|
|
this->ClOptions[*i]->UsingSBCS())
|
|
|
|
{
|
|
|
|
this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2);
|
|
|
|
}
|
2009-10-23 19:34:37 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
|
|
|
|
}
|
2010-12-01 20:48:32 +03:00
|
|
|
if(const char* toolset = gg->GetPlatformToolset())
|
|
|
|
{
|
|
|
|
std::string pts = "<PlatformToolset>";
|
|
|
|
pts += toolset;
|
|
|
|
pts += "</PlatformToolset>\n";
|
|
|
|
this->WriteString(pts.c_str(), 2);
|
|
|
|
}
|
2012-02-03 18:07:12 +04:00
|
|
|
if(this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
|
|
|
|
{
|
|
|
|
this->WriteString("<Immersive>true</Immersive>\n", 2);
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
this->WriteString("</PropertyGroup>\n", 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmVisualStudio10TargetGenerator::WriteCustomCommands()
|
2009-09-07 18:12:18 +04:00
|
|
|
{
|
|
|
|
this->SourcesVisited.clear();
|
2012-03-07 20:56:21 +04:00
|
|
|
for(std::vector<cmSourceFile*>::const_iterator
|
|
|
|
si = this->GeneratorTarget->CustomCommands.begin();
|
|
|
|
si != this->GeneratorTarget->CustomCommands.end(); ++si)
|
2009-06-26 00:41:57 +04:00
|
|
|
{
|
2012-03-07 20:56:21 +04:00
|
|
|
this->WriteCustomCommand(*si);
|
2009-09-07 18:12:18 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf)
|
|
|
|
{
|
|
|
|
if(this->SourcesVisited.insert(sf).second)
|
|
|
|
{
|
|
|
|
if(std::vector<cmSourceFile*> const* depends =
|
|
|
|
this->Target->GetSourceDepends(sf))
|
2009-06-26 00:41:57 +04:00
|
|
|
{
|
2009-09-07 18:12:18 +04:00
|
|
|
for(std::vector<cmSourceFile*>::const_iterator di = depends->begin();
|
|
|
|
di != depends->end(); ++di)
|
|
|
|
{
|
|
|
|
this->WriteCustomCommand(*di);
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
2009-09-07 18:12:18 +04:00
|
|
|
if(cmCustomCommand const* command = sf->GetCustomCommand())
|
|
|
|
{
|
|
|
|
this->WriteString("<ItemGroup>\n", 1);
|
|
|
|
this->WriteCustomRule(sf, *command);
|
|
|
|
this->WriteString("</ItemGroup>\n", 1);
|
|
|
|
}
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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()))
|
|
|
|
{
|
2011-06-07 16:59:03 +04:00
|
|
|
// Make sure the path exists for the file
|
|
|
|
std::string path = cmSystemTools::GetFilenamePath(sourcePath);
|
|
|
|
cmSystemTools::MakeDirectory(path.c_str());
|
2009-06-26 00:41:57 +04:00
|
|
|
std::ofstream fout(sourcePath.c_str());
|
|
|
|
if(fout)
|
|
|
|
{
|
|
|
|
fout << "# generated from CMake\n";
|
|
|
|
fout.flush();
|
|
|
|
fout.close();
|
|
|
|
}
|
2011-06-07 16:59:03 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string error = "Could not create file: [";
|
|
|
|
error += sourcePath;
|
|
|
|
error += "] ";
|
|
|
|
cmSystemTools::Error
|
|
|
|
(error.c_str(), cmSystemTools::GetLastSystemError().c_str());
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
|
|
|
|
std::string comment = lg->ConstructComment(command);
|
2010-10-02 00:12:00 +04:00
|
|
|
comment = cmVS10EscapeComment(comment);
|
2009-06-26 00:41:57 +04:00
|
|
|
std::vector<std::string> *configs =
|
|
|
|
static_cast<cmGlobalVisualStudio7Generator *>
|
|
|
|
(this->GlobalGenerator)->GetConfigurations();
|
|
|
|
this->WriteString("<CustomBuild Include=\"", 2);
|
2011-06-22 19:52:15 +04:00
|
|
|
// custom command have to use relative paths or they do not
|
|
|
|
// show up in the GUI
|
|
|
|
std::string path = cmSystemTools::RelativePath(
|
|
|
|
this->Makefile->GetCurrentOutputDirectory(),
|
|
|
|
sourcePath.c_str());
|
2009-07-10 20:26:39 +04:00
|
|
|
this->ConvertToWindowsSlash(path);
|
|
|
|
(*this->BuildFileStream ) << path << "\">\n";
|
2009-06-26 00:41:57 +04:00
|
|
|
for(std::vector<std::string>::iterator i = configs->begin();
|
|
|
|
i != configs->end(); ++i)
|
|
|
|
{
|
2009-09-07 18:11:20 +04:00
|
|
|
std::string script =
|
2010-12-07 21:44:54 +03:00
|
|
|
cmVS10EscapeXML(lg->ConstructScript(command, i->c_str()));
|
2009-06-26 00:41:57 +04:00
|
|
|
this->WritePlatformConfigTag("Message",i->c_str(), 3);
|
2010-10-02 00:12:00 +04:00
|
|
|
(*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
|
2009-06-26 00:41:57 +04:00
|
|
|
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)
|
|
|
|
{
|
2010-12-09 00:51:16 +03:00
|
|
|
std::string dep;
|
|
|
|
if(this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(), dep))
|
|
|
|
{
|
|
|
|
this->ConvertToWindowsSlash(dep);
|
|
|
|
(*this->BuildFileStream ) << ";" << dep;
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
(*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 = ";";
|
|
|
|
}
|
2011-08-19 00:51:52 +04:00
|
|
|
(*this->BuildFileStream ) << "</Outputs>\n";
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
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()
|
2009-07-11 08:05:20 +04:00
|
|
|
{
|
|
|
|
// collect up group information
|
|
|
|
std::vector<cmSourceGroup> sourceGroups =
|
|
|
|
this->Makefile->GetSourceGroups();
|
|
|
|
std::vector<cmSourceFile*> classes = this->Target->GetSourceFiles();
|
|
|
|
|
|
|
|
std::set<cmSourceGroup*> groupsUsed;
|
|
|
|
std::vector<cmSourceFile*> clCompile;
|
|
|
|
std::vector<cmSourceFile*> customBuild;
|
|
|
|
std::vector<cmSourceFile*> none;
|
2009-10-22 05:30:41 +04:00
|
|
|
std::vector<cmSourceFile*> headers;
|
2011-01-05 02:51:15 +03:00
|
|
|
std::vector<cmSourceFile*> idls;
|
2009-12-09 19:52:10 +03:00
|
|
|
std::vector<cmSourceFile*> resource;
|
2009-06-26 00:41:57 +04:00
|
|
|
|
2009-07-11 08:05:20 +04:00
|
|
|
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
|
|
|
|
s != classes.end(); s++)
|
|
|
|
{
|
|
|
|
cmSourceFile* sf = *s;
|
|
|
|
std::string const& source = sf->GetFullPath();
|
|
|
|
cmSourceGroup& sourceGroup =
|
|
|
|
this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
|
|
|
|
groupsUsed.insert(&sourceGroup);
|
2009-10-22 05:30:41 +04:00
|
|
|
const char* lang = sf->GetLanguage();
|
|
|
|
bool header = (*s)->GetPropertyAsBool("HEADER_FILE_ONLY")
|
|
|
|
|| this->GlobalGenerator->IgnoreFile
|
|
|
|
((*s)->GetExtension().c_str());
|
2011-04-02 00:28:41 +04:00
|
|
|
std::string ext =
|
|
|
|
cmSystemTools::LowerCase((*s)->GetExtension());
|
2009-07-11 08:05:20 +04:00
|
|
|
if(!lang)
|
|
|
|
{
|
|
|
|
lang = "None";
|
|
|
|
}
|
2011-05-24 01:30:23 +04:00
|
|
|
if(header)
|
|
|
|
{
|
|
|
|
headers.push_back(sf);
|
|
|
|
}
|
|
|
|
else if(lang[0] == 'C')
|
2009-07-11 08:05:20 +04:00
|
|
|
{
|
|
|
|
clCompile.push_back(sf);
|
|
|
|
}
|
2011-01-05 02:51:15 +03:00
|
|
|
else if(strcmp(lang, "RC") == 0)
|
2009-12-09 19:52:10 +03:00
|
|
|
{
|
|
|
|
resource.push_back(sf);
|
|
|
|
}
|
2009-07-11 08:05:20 +04:00
|
|
|
else if(sf->GetCustomCommand())
|
|
|
|
{
|
|
|
|
customBuild.push_back(sf);
|
|
|
|
}
|
2011-04-02 00:28:41 +04:00
|
|
|
else if(ext == "idl")
|
2011-01-05 02:51:15 +03:00
|
|
|
{
|
|
|
|
idls.push_back(sf);
|
|
|
|
}
|
2009-07-11 08:05:20 +04:00
|
|
|
else
|
|
|
|
{
|
|
|
|
none.push_back(sf);
|
|
|
|
}
|
|
|
|
}
|
2010-06-11 23:33:38 +04:00
|
|
|
|
|
|
|
this->AddMissingSourceGroups(groupsUsed, sourceGroups);
|
|
|
|
|
2009-07-11 08:05:20 +04:00
|
|
|
// Write out group file
|
|
|
|
std::string path = this->Makefile->GetStartOutputDirectory();
|
|
|
|
path += "/";
|
2009-07-14 00:58:24 +04:00
|
|
|
path += this->Name;
|
2009-07-11 08:05:20 +04:00
|
|
|
path += ".vcxproj.filters";
|
|
|
|
cmGeneratedFileStream fout(path.c_str());
|
2010-05-05 22:30:21 +04:00
|
|
|
fout.SetCopyIfDifferent(true);
|
2009-07-11 08:05:20 +04:00
|
|
|
char magic[] = {0xEF,0xBB, 0xBF};
|
|
|
|
fout.write(magic, 3);
|
|
|
|
cmGeneratedFileStream* save = this->BuildFileStream;
|
|
|
|
this->BuildFileStream = & fout;
|
|
|
|
this->WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
|
|
|
|
"<Project "
|
|
|
|
"ToolsVersion=\"4.0\" "
|
|
|
|
"xmlns=\"http://schemas.microsoft.com/"
|
|
|
|
"developer/msbuild/2003\">\n",
|
|
|
|
0);
|
|
|
|
this->WriteGroupSources("ClCompile", clCompile, sourceGroups);
|
2009-10-22 05:30:41 +04:00
|
|
|
this->WriteGroupSources("ClInclude", headers, sourceGroups);
|
2009-12-09 19:52:10 +03:00
|
|
|
this->WriteGroupSources("ResourceCompile", resource, sourceGroups);
|
2011-01-05 02:51:15 +03:00
|
|
|
this->WriteGroupSources("Midl", idls, sourceGroups);
|
2009-07-11 08:05:20 +04:00
|
|
|
this->WriteGroupSources("CustomBuild", customBuild, sourceGroups);
|
|
|
|
|
2012-03-12 22:40:58 +04:00
|
|
|
// Add object library contents as external objects.
|
|
|
|
std::vector<std::string> objs;
|
|
|
|
this->GeneratorTarget->UseObjectLibraries(objs);
|
|
|
|
if(!objs.empty())
|
|
|
|
{
|
|
|
|
this->WriteString("<ItemGroup>\n", 1);
|
|
|
|
for(std::vector<std::string>::const_iterator
|
|
|
|
oi = objs.begin(); oi != objs.end(); ++oi)
|
|
|
|
{
|
|
|
|
std::string obj = *oi;
|
|
|
|
this->WriteString("<Object Include=\"", 2);
|
|
|
|
this->ConvertToWindowsSlash(obj);
|
|
|
|
(*this->BuildFileStream ) << obj << "\">\n";
|
|
|
|
this->WriteString("<Filter>Object Libraries</Filter>\n", 3);
|
|
|
|
this->WriteString("</Object>\n", 2);
|
|
|
|
}
|
|
|
|
this->WriteString("</ItemGroup>\n", 1);
|
|
|
|
}
|
|
|
|
|
2009-07-11 08:05:20 +04:00
|
|
|
this->WriteString("<ItemGroup>\n", 1);
|
|
|
|
for(std::set<cmSourceGroup*>::iterator g = groupsUsed.begin();
|
|
|
|
g != groupsUsed.end(); ++g)
|
|
|
|
{
|
|
|
|
cmSourceGroup* sg = *g;
|
|
|
|
const char* name = sg->GetFullName();
|
|
|
|
if(strlen(name) != 0)
|
|
|
|
{
|
|
|
|
this->WriteString("<Filter Include=\"", 2);
|
|
|
|
(*this->BuildFileStream) << name << "\">\n";
|
|
|
|
std::string guidName = "SG_Filter_";
|
|
|
|
guidName += name;
|
|
|
|
this->GlobalGenerator->CreateGUID(guidName.c_str());
|
|
|
|
this->WriteString("<UniqueIdentifier>", 3);
|
|
|
|
std::string guid
|
|
|
|
= this->GlobalGenerator->GetGUID(guidName.c_str());
|
|
|
|
(*this->BuildFileStream)
|
|
|
|
<< "{"
|
|
|
|
<< guid << "}"
|
|
|
|
<< "</UniqueIdentifier>\n";
|
|
|
|
this->WriteString("</Filter>\n", 2);
|
|
|
|
}
|
|
|
|
}
|
2012-03-12 22:40:58 +04:00
|
|
|
if(!objs.empty())
|
|
|
|
{
|
|
|
|
this->WriteString("<Filter Include=\"Object Libraries\">\n", 2);
|
|
|
|
std::string guidName = "SG_Filter_Object Libraries";
|
|
|
|
this->GlobalGenerator->CreateGUID(guidName.c_str());
|
|
|
|
this->WriteString("<UniqueIdentifier>", 3);
|
|
|
|
std::string guid =
|
|
|
|
this->GlobalGenerator->GetGUID(guidName.c_str());
|
|
|
|
(*this->BuildFileStream) << "{" << guid << "}"
|
|
|
|
<< "</UniqueIdentifier>\n";
|
|
|
|
this->WriteString("</Filter>\n", 2);
|
|
|
|
}
|
2009-07-11 08:05:20 +04:00
|
|
|
this->WriteString("</ItemGroup>\n", 1);
|
|
|
|
this->WriteGroupSources("None", none, sourceGroups);
|
|
|
|
this->WriteString("</Project>\n", 0);
|
|
|
|
// restore stream pointer
|
|
|
|
this->BuildFileStream = save;
|
2010-05-05 22:30:21 +04:00
|
|
|
|
|
|
|
if (fout.Close())
|
|
|
|
{
|
|
|
|
this->GlobalGenerator->FileReplacedDuringGenerate(path);
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
|
2010-06-11 23:33:38 +04:00
|
|
|
// Add to groupsUsed empty source groups that have non-empty children.
|
|
|
|
void
|
|
|
|
cmVisualStudio10TargetGenerator::AddMissingSourceGroups(
|
|
|
|
std::set<cmSourceGroup*>& groupsUsed,
|
|
|
|
const std::vector<cmSourceGroup>& allGroups
|
|
|
|
)
|
|
|
|
{
|
|
|
|
for(std::vector<cmSourceGroup>::const_iterator current = allGroups.begin();
|
|
|
|
current != allGroups.end(); ++current)
|
|
|
|
{
|
|
|
|
std::vector<cmSourceGroup> const& children = current->GetGroupChildren();
|
|
|
|
if(children.empty())
|
|
|
|
{
|
|
|
|
continue; // the group is really empty
|
|
|
|
}
|
|
|
|
|
|
|
|
this->AddMissingSourceGroups(groupsUsed, children);
|
|
|
|
|
|
|
|
cmSourceGroup* current_ptr = const_cast<cmSourceGroup*>(&(*current));
|
|
|
|
if(groupsUsed.find(current_ptr) != groupsUsed.end())
|
|
|
|
{
|
|
|
|
continue; // group has already been added to set
|
|
|
|
}
|
|
|
|
|
|
|
|
// check if it least one of the group's descendants is not empty
|
|
|
|
// (at least one child must already have been added)
|
|
|
|
std::vector<cmSourceGroup>::const_iterator child_it = children.begin();
|
|
|
|
while(child_it != children.end())
|
|
|
|
{
|
|
|
|
cmSourceGroup* child_ptr = const_cast<cmSourceGroup*>(&(*child_it));
|
|
|
|
if(groupsUsed.find(child_ptr) != groupsUsed.end())
|
|
|
|
{
|
|
|
|
break; // found a child that was already added => add current group too
|
|
|
|
}
|
|
|
|
child_it++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(child_it == children.end())
|
|
|
|
{
|
|
|
|
continue; // no descendants have source files => ignore this group
|
|
|
|
}
|
|
|
|
|
|
|
|
groupsUsed.insert(current_ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-05 22:30:21 +04:00
|
|
|
void
|
2009-07-11 08:05:20 +04:00
|
|
|
cmVisualStudio10TargetGenerator::
|
|
|
|
WriteGroupSources(const char* name,
|
|
|
|
std::vector<cmSourceFile*> const& sources,
|
|
|
|
std::vector<cmSourceGroup>& sourceGroups)
|
|
|
|
{
|
|
|
|
this->WriteString("<ItemGroup>\n", 1);
|
|
|
|
for(std::vector<cmSourceFile*>::const_iterator s = sources.begin();
|
|
|
|
s != sources.end(); ++s)
|
|
|
|
{
|
2011-01-21 18:57:34 +03:00
|
|
|
cmSourceFile* sf = *s;
|
|
|
|
if(sf->GetExtension() == "obj")
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2009-07-11 08:05:20 +04:00
|
|
|
std::string const& source = sf->GetFullPath();
|
|
|
|
cmSourceGroup& sourceGroup =
|
|
|
|
this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
|
|
|
|
const char* filter = sourceGroup.GetFullName();
|
|
|
|
this->WriteString("<", 2);
|
|
|
|
std::string path = source;
|
2011-06-22 19:52:15 +04:00
|
|
|
// custom command sources must use relative paths or they will
|
|
|
|
// not show up in the GUI.
|
|
|
|
if(sf->GetCustomCommand())
|
|
|
|
{
|
|
|
|
path = cmSystemTools::RelativePath(
|
|
|
|
this->Makefile->GetCurrentOutputDirectory(),
|
|
|
|
source.c_str());
|
|
|
|
}
|
2009-07-11 08:05:20 +04:00
|
|
|
this->ConvertToWindowsSlash(path);
|
|
|
|
(*this->BuildFileStream) << name << " Include=\""
|
|
|
|
<< path;
|
|
|
|
if(strlen(filter))
|
|
|
|
{
|
|
|
|
(*this->BuildFileStream) << "\">\n";
|
|
|
|
this->WriteString("<Filter>", 3);
|
|
|
|
(*this->BuildFileStream) << filter << "</Filter>\n";
|
|
|
|
this->WriteString("</", 2);
|
|
|
|
(*this->BuildFileStream) << name << ">\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
(*this->BuildFileStream) << "\" />\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this->WriteString("</ItemGroup>\n", 1);
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
|
2009-06-26 06:53:02 +04:00
|
|
|
void cmVisualStudio10TargetGenerator::WriteObjSources()
|
|
|
|
{
|
|
|
|
if(this->Target->GetType() > cmTarget::MODULE_LIBRARY)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
bool first = true;
|
|
|
|
std::vector<cmSourceFile*>const & sources = this->Target->GetSourceFiles();
|
|
|
|
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
|
|
|
|
source != sources.end(); ++source)
|
|
|
|
{
|
2011-04-02 00:28:41 +04:00
|
|
|
std::string ext =
|
|
|
|
cmSystemTools::LowerCase((*source)->GetExtension());
|
|
|
|
if(ext == "obj" || ext == "o")
|
2009-06-26 06:53:02 +04:00
|
|
|
{
|
|
|
|
if(first)
|
|
|
|
{
|
|
|
|
this->WriteString("<ItemGroup>\n", 1);
|
|
|
|
first = false;
|
|
|
|
}
|
2011-04-02 00:28:41 +04:00
|
|
|
// If an object file is generated, then vs10
|
|
|
|
// will use it in the build, and we have to list
|
|
|
|
// it as None instead of Object
|
|
|
|
if((*source)->GetPropertyAsBool("GENERATED"))
|
|
|
|
{
|
|
|
|
this->WriteString("<None Include=\"", 2);
|
|
|
|
}
|
|
|
|
// If it is not a generated object then we have
|
|
|
|
// to use the Object type
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->WriteString("<Object Include=\"", 2);
|
|
|
|
}
|
2009-06-26 06:53:02 +04:00
|
|
|
(*this->BuildFileStream ) << (*source)->GetFullPath() << "\" />\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!first)
|
|
|
|
{
|
|
|
|
this->WriteString("</ItemGroup>\n", 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cmVisualStudio10TargetGenerator::WriteCLSources()
|
2009-06-26 00:41:57 +04:00
|
|
|
{
|
2011-01-07 00:48:46 +03:00
|
|
|
if(this->Target->GetType() > cmTarget::UTILITY)
|
2009-06-26 00:41:57 +04:00
|
|
|
{
|
2009-07-10 17:12:39 +04:00
|
|
|
return;
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
2009-07-10 17:12:39 +04:00
|
|
|
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)
|
2009-06-26 00:41:57 +04:00
|
|
|
{
|
2011-04-02 00:28:41 +04:00
|
|
|
std::string ext = cmSystemTools::LowerCase((*source)->GetExtension());
|
|
|
|
if((*source)->GetCustomCommand() || ext == "o" || ext == "obj")
|
2011-01-21 18:57:34 +03:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// If it is not a custom command and it is not a pre-built obj file,
|
|
|
|
// then add it as a source (c/c++/header/rc/idl) file
|
|
|
|
bool header = (*source)->GetPropertyAsBool("HEADER_FILE_ONLY")
|
|
|
|
|| this->GlobalGenerator->IgnoreFile(ext.c_str());
|
|
|
|
const char* lang = (*source)->GetLanguage();
|
|
|
|
bool cl = lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0);
|
|
|
|
bool rc = lang && (strcmp(lang, "RC") == 0);
|
|
|
|
bool idl = ext == "idl";
|
|
|
|
std::string sourceFile = (*source)->GetFullPath();
|
2011-06-22 19:52:15 +04:00
|
|
|
// do not use a relative path here because it means that you
|
|
|
|
// can not use as long a path to the file.
|
2011-01-21 18:57:34 +03:00
|
|
|
this->ConvertToWindowsSlash(sourceFile);
|
|
|
|
// output the source file
|
|
|
|
if(header)
|
|
|
|
{
|
|
|
|
this->WriteString("<ClInclude Include=\"", 2);
|
|
|
|
}
|
|
|
|
else if(cl)
|
|
|
|
{
|
|
|
|
this->WriteString("<ClCompile Include=\"", 2);
|
|
|
|
}
|
|
|
|
else if(rc)
|
|
|
|
{
|
|
|
|
this->WriteString("<ResourceCompile Include=\"", 2);
|
|
|
|
}
|
|
|
|
else if(idl)
|
|
|
|
{
|
|
|
|
this->WriteString("<Midl Include=\"", 2);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->WriteString("<None Include=\"", 2);
|
|
|
|
}
|
|
|
|
(*this->BuildFileStream ) << sourceFile << "\"";
|
|
|
|
// ouput any flags specific to this source file
|
|
|
|
if(!header && cl && this->OutputSourceSpecificFlags(*source))
|
|
|
|
{
|
|
|
|
// if the source file has specific flags the tag
|
|
|
|
// is ended on a new line
|
|
|
|
this->WriteString("</ClCompile>\n", 2);
|
|
|
|
}
|
2011-01-26 02:54:36 +03:00
|
|
|
else if(!header && rc && this->OutputSourceSpecificFlags(*source))
|
|
|
|
{
|
|
|
|
this->WriteString("</ResourceCompile>\n", 2);
|
|
|
|
}
|
2011-01-21 18:57:34 +03:00
|
|
|
else
|
|
|
|
{
|
|
|
|
(*this->BuildFileStream ) << " />\n";
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
}
|
2012-03-12 22:40:58 +04:00
|
|
|
|
|
|
|
// Add object library contents as external objects.
|
|
|
|
std::vector<std::string> objs;
|
|
|
|
this->GeneratorTarget->UseObjectLibraries(objs);
|
|
|
|
for(std::vector<std::string>::const_iterator
|
|
|
|
oi = objs.begin(); oi != objs.end(); ++oi)
|
|
|
|
{
|
|
|
|
std::string obj = *oi;
|
|
|
|
this->WriteString("<Object Include=\"", 2);
|
|
|
|
this->ConvertToWindowsSlash(obj);
|
|
|
|
(*this->BuildFileStream ) << obj << "\" />\n";
|
|
|
|
}
|
|
|
|
|
2009-06-26 00:41:57 +04:00
|
|
|
this->WriteString("</ItemGroup>\n", 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
|
|
|
|
cmSourceFile* source)
|
2009-07-10 17:12:39 +04:00
|
|
|
{
|
2009-06-26 00:41:57 +04:00
|
|
|
cmSourceFile& sf = *source;
|
2009-07-10 17:12:39 +04:00
|
|
|
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
|
|
|
|
|
|
|
|
std::string objectName;
|
2012-03-07 23:04:33 +04:00
|
|
|
if(this->GeneratorTarget->ExplicitObjectName.find(&sf)
|
|
|
|
!= this->GeneratorTarget->ExplicitObjectName.end())
|
2009-07-10 17:12:39 +04:00
|
|
|
{
|
2012-03-07 23:04:33 +04:00
|
|
|
objectName = this->GeneratorTarget->Objects[&sf];
|
2009-07-10 17:12:39 +04:00
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
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);
|
2009-07-07 15:44:12 +04:00
|
|
|
const char* linkLanguage = this->Target->GetLinkerLanguage();
|
2009-06-26 00:41:57 +04:00
|
|
|
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 ";
|
|
|
|
}
|
|
|
|
}
|
2009-07-10 17:12:39 +04:00
|
|
|
bool hasFlags = false;
|
2009-06-26 00:41:57 +04:00
|
|
|
// for the first time we need a new line if there is something
|
|
|
|
// produced here.
|
|
|
|
const char* firstString = ">\n";
|
2009-07-10 17:12:39 +04:00
|
|
|
if(objectName.size())
|
|
|
|
{
|
|
|
|
(*this->BuildFileStream ) << firstString;
|
|
|
|
firstString = "";
|
|
|
|
hasFlags = true;
|
|
|
|
this->WriteString("<ObjectFileName>", 3);
|
|
|
|
(*this->BuildFileStream )
|
2010-09-27 16:37:00 +04:00
|
|
|
<< "$(IntDir)/" << objectName << "</ObjectFileName>\n";
|
2009-07-10 17:12:39 +04:00
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
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 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())
|
|
|
|
{
|
2009-07-14 00:58:24 +04:00
|
|
|
configDefines += ";";
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
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,
|
2011-11-11 02:17:41 +04:00
|
|
|
cmVisualStudioGeneratorOptions::Compiler,
|
2009-06-26 00:41:57 +04:00
|
|
|
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, " ");
|
2009-06-28 16:59:56 +04:00
|
|
|
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream,
|
2011-01-26 02:54:36 +03:00
|
|
|
" ", "\n", lang);
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return hasFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
|
|
|
|
{
|
2010-09-13 21:29:10 +04:00
|
|
|
cmTarget::TargetType ttype = this->Target->GetType();
|
|
|
|
if(ttype > cmTarget::GLOBAL_TARGET)
|
2009-07-10 17:12:39 +04:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2010-09-13 21:29:10 +04:00
|
|
|
|
2009-06-26 00:41:57 +04:00
|
|
|
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)
|
|
|
|
{
|
2010-09-13 21:29:10 +04:00
|
|
|
if(ttype >= cmTarget::UTILITY)
|
|
|
|
{
|
|
|
|
this->WritePlatformConfigTag("IntDir", config->c_str(), 3);
|
|
|
|
*this->BuildFileStream
|
|
|
|
<< "$(Platform)\\$(Configuration)\\$(ProjectName)\\"
|
|
|
|
<< "</IntDir>\n";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::string intermediateDir = this->LocalGenerator->
|
|
|
|
GetTargetDirectory(*this->Target);
|
|
|
|
intermediateDir += "/";
|
|
|
|
intermediateDir += *config;
|
|
|
|
intermediateDir += "/";
|
2012-03-12 18:55:07 +04:00
|
|
|
std::string outDir;
|
|
|
|
std::string targetNameFull;
|
|
|
|
if(ttype == cmTarget::OBJECT_LIBRARY)
|
|
|
|
{
|
|
|
|
outDir = intermediateDir;
|
|
|
|
targetNameFull = this->Target->GetName();
|
|
|
|
targetNameFull += ".lib";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
outDir = this->Target->GetDirectory(config->c_str()) + "/";
|
|
|
|
targetNameFull = this->Target->GetFullName(config->c_str());
|
|
|
|
}
|
2010-09-13 21:29:10 +04:00
|
|
|
this->ConvertToWindowsSlash(intermediateDir);
|
|
|
|
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::GetFilenameWithoutLastExtension(
|
|
|
|
targetNameFull.c_str())
|
|
|
|
<< "</TargetName>\n";
|
|
|
|
|
|
|
|
this->WritePlatformConfigTag("TargetExt", config->c_str(), 3);
|
|
|
|
*this->BuildFileStream
|
|
|
|
<< cmSystemTools::GetFilenameLastExtension(targetNameFull.c_str())
|
|
|
|
<< "</TargetExt>\n";
|
|
|
|
|
|
|
|
this->OutputLinkIncremental(*config);
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
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";
|
2009-07-08 21:04:04 +04:00
|
|
|
const char* linkLanguage =
|
|
|
|
this->Target->GetLinkerLanguage(configName.c_str());
|
2009-06-26 00:41:57 +04:00
|
|
|
if(!linkLanguage)
|
|
|
|
{
|
|
|
|
cmSystemTools::Error
|
|
|
|
("CMake can not determine linker language for target:",
|
2009-07-14 00:58:24 +04:00
|
|
|
this->Name.c_str());
|
2009-06-26 00:41:57 +04:00
|
|
|
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());
|
2009-09-29 05:19:20 +04:00
|
|
|
}
|
|
|
|
const char* targetLinkFlags = this->Target->GetProperty("LINK_FLAGS");
|
|
|
|
if(targetLinkFlags)
|
|
|
|
{
|
|
|
|
flags += " ";
|
|
|
|
flags += targetLinkFlags;
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
2010-05-28 19:00:31 +04:00
|
|
|
std::string flagsProp = "LINK_FLAGS_";
|
|
|
|
flagsProp += CONFIG;
|
|
|
|
if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str()))
|
|
|
|
{
|
|
|
|
flags += " ";
|
|
|
|
flags += flagsConfig;
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
if(flags.find("INCREMENTAL:NO") != flags.npos)
|
|
|
|
{
|
|
|
|
incremental = "false";
|
|
|
|
}
|
|
|
|
this->WritePlatformConfigTag("LinkIncremental", configName.c_str(), 3);
|
|
|
|
*this->BuildFileStream << incremental
|
|
|
|
<< "</LinkIncremental>\n";
|
2011-02-09 20:59:09 +03:00
|
|
|
|
|
|
|
const char* manifest = "true";
|
|
|
|
if(flags.find("MANIFEST:NO") != flags.npos)
|
|
|
|
{
|
|
|
|
manifest = "false";
|
|
|
|
}
|
|
|
|
this->WritePlatformConfigTag("GenerateManifest", configName.c_str(), 3);
|
|
|
|
*this->BuildFileStream << manifest
|
|
|
|
<< "</GenerateManifest>\n";
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
|
2009-10-23 19:34:37 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2010-09-30 16:48:38 +04:00
|
|
|
bool cmVisualStudio10TargetGenerator::ComputeClOptions()
|
2009-10-23 19:34:37 +04:00
|
|
|
{
|
|
|
|
std::vector<std::string> const* configs =
|
|
|
|
this->GlobalGenerator->GetConfigurations();
|
|
|
|
for(std::vector<std::string>::const_iterator i = configs->begin();
|
|
|
|
i != configs->end(); ++i)
|
|
|
|
{
|
2010-09-30 16:48:38 +04:00
|
|
|
if(!this->ComputeClOptions(*i))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2009-10-23 19:34:37 +04:00
|
|
|
}
|
2010-09-30 16:48:38 +04:00
|
|
|
return true;
|
2009-10-23 19:34:37 +04:00
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
|
2009-10-23 19:34:37 +04:00
|
|
|
//----------------------------------------------------------------------------
|
2010-09-30 16:48:38 +04:00
|
|
|
bool cmVisualStudio10TargetGenerator::ComputeClOptions(
|
2009-10-23 19:34:37 +04:00
|
|
|
std::string const& configName)
|
2009-06-26 00:41:57 +04:00
|
|
|
{
|
|
|
|
// much of this was copied from here:
|
|
|
|
// copied from cmLocalVisualStudio7Generator.cxx 805
|
2009-10-23 19:34:37 +04:00
|
|
|
// TODO: Integrate code below with cmLocalVisualStudio7Generator.
|
|
|
|
|
|
|
|
cmsys::auto_ptr<Options> pOptions(
|
2011-11-11 02:17:41 +04:00
|
|
|
new Options(this->LocalGenerator, Options::Compiler,
|
2009-10-23 19:34:37 +04:00
|
|
|
cmVS10CLFlagTable));
|
|
|
|
Options& clOptions = *pOptions;
|
2009-06-26 00:41:57 +04:00
|
|
|
|
|
|
|
std::string flags;
|
|
|
|
// collect up flags for
|
|
|
|
if(this->Target->GetType() < cmTarget::UTILITY)
|
|
|
|
{
|
2009-07-08 21:04:04 +04:00
|
|
|
const char* linkLanguage =
|
|
|
|
this->Target->GetLinkerLanguage(configName.c_str());
|
2009-06-26 00:41:57 +04:00
|
|
|
if(!linkLanguage)
|
|
|
|
{
|
|
|
|
cmSystemTools::Error
|
|
|
|
("CMake can not determine linker language for target:",
|
2009-07-14 00:58:24 +04:00
|
|
|
this->Name.c_str());
|
2010-09-30 16:48:38 +04:00
|
|
|
return false;
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
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 ";
|
|
|
|
}
|
|
|
|
}
|
2009-07-10 17:12:39 +04:00
|
|
|
// Add the target-specific flags.
|
|
|
|
if(const char* targetFlags = this->Target->GetProperty("COMPILE_FLAGS"))
|
|
|
|
{
|
|
|
|
flags += " ";
|
|
|
|
flags += targetFlags;
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
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);
|
|
|
|
}
|
2009-10-23 19:34:37 +04:00
|
|
|
|
|
|
|
this->ClOptions[configName] = pOptions.release();
|
2010-09-30 16:48:38 +04:00
|
|
|
return true;
|
2009-10-23 19:34:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
void cmVisualStudio10TargetGenerator::WriteClOptions(
|
|
|
|
std::string const& configName,
|
|
|
|
std::vector<std::string> const& includes)
|
|
|
|
{
|
|
|
|
Options& clOptions = *(this->ClOptions[configName]);
|
|
|
|
this->WriteString("<ClCompile>\n", 2);
|
2009-06-26 00:41:57 +04:00
|
|
|
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
|
|
|
this->OutputIncludes(includes);
|
|
|
|
clOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
2010-08-19 17:21:54 +04:00
|
|
|
|
|
|
|
// If not in debug mode, write the DebugInformationFormat field
|
|
|
|
// without value so PDBs don't get generated uselessly.
|
|
|
|
if(!clOptions.IsDebug())
|
|
|
|
{
|
|
|
|
this->WriteString("<DebugInformationFormat>"
|
|
|
|
"</DebugInformationFormat>\n", 3);
|
|
|
|
}
|
|
|
|
|
2009-06-26 00:41:57 +04:00
|
|
|
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
|
2011-01-26 02:54:36 +03:00
|
|
|
"\n", "CXX");
|
2009-06-26 00:41:57 +04:00
|
|
|
this->WriteString("<AssemblerListingLocation>", 3);
|
|
|
|
*this->BuildFileStream << configName
|
|
|
|
<< "</AssemblerListingLocation>\n";
|
|
|
|
this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
|
2012-03-12 18:55:07 +04:00
|
|
|
if(this->Target->GetType() != cmTarget::OBJECT_LIBRARY)
|
|
|
|
{
|
|
|
|
// TODO: PDB for object library?
|
|
|
|
this->WriteString("<ProgramDataBaseFileName>", 3);
|
|
|
|
*this->BuildFileStream << this->Target->GetDirectory(configName.c_str())
|
|
|
|
<< "/"
|
|
|
|
<< this->Target->GetPDBName(configName.c_str())
|
|
|
|
<< "</ProgramDataBaseFileName>\n";
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
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::
|
2010-12-21 17:17:21 +03:00
|
|
|
WriteRCOptions(std::string const& configName,
|
2009-06-26 00:41:57 +04:00
|
|
|
std::vector<std::string> const & includes)
|
|
|
|
{
|
|
|
|
this->WriteString("<ResourceCompile>\n", 2);
|
2010-12-21 17:17:21 +03:00
|
|
|
Options& clOptions = *(this->ClOptions[configName]);
|
|
|
|
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
|
2011-01-26 02:54:36 +03:00
|
|
|
"\n", "RC");
|
2009-06-26 00:41:57 +04:00
|
|
|
this->OutputIncludes(includes);
|
|
|
|
this->WriteString("</ResourceCompile>\n", 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-28 18:45:54 +04:00
|
|
|
void
|
|
|
|
cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
|
2009-06-28 16:59:56 +04:00
|
|
|
{
|
|
|
|
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2010-05-28 18:45:54 +04:00
|
|
|
const char* libflags = this->Target->GetProperty("STATIC_LIBRARY_FLAGS");
|
|
|
|
std::string flagsConfigVar = "STATIC_LIBRARY_FLAGS_";
|
|
|
|
flagsConfigVar += cmSystemTools::UpperCase(config);
|
|
|
|
const char* libflagsConfig =
|
|
|
|
this->Target->GetProperty(flagsConfigVar.c_str());
|
|
|
|
if(libflags || libflagsConfig)
|
2009-06-28 16:59:56 +04:00
|
|
|
{
|
|
|
|
this->WriteString("<Lib>\n", 2);
|
2009-09-30 00:38:43 +04:00
|
|
|
cmVisualStudioGeneratorOptions
|
2011-11-11 02:17:41 +04:00
|
|
|
libOptions(this->LocalGenerator,
|
2009-09-30 00:38:43 +04:00
|
|
|
cmVisualStudioGeneratorOptions::Linker,
|
|
|
|
cmVS10LibFlagTable, 0, this);
|
2010-05-28 18:45:54 +04:00
|
|
|
libOptions.Parse(libflags?libflags:"");
|
|
|
|
libOptions.Parse(libflagsConfig?libflagsConfig:"");
|
2009-06-28 16:59:56 +04:00
|
|
|
libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
|
|
|
libOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
|
|
|
this->WriteString("</Lib>\n", 2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-26 00:41:57 +04:00
|
|
|
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;
|
|
|
|
}
|
2009-07-08 21:04:04 +04:00
|
|
|
const char* linkLanguage =
|
|
|
|
this->Target->GetLinkerLanguage(config.c_str());
|
2009-06-26 00:41:57 +04:00
|
|
|
if(!linkLanguage)
|
|
|
|
{
|
|
|
|
cmSystemTools::Error
|
|
|
|
("CMake can not determine linker language for target:",
|
2009-07-14 00:58:24 +04:00
|
|
|
this->Name.c_str());
|
2009-06-26 00:41:57 +04:00
|
|
|
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;
|
|
|
|
}
|
2010-05-28 19:00:31 +04:00
|
|
|
std::string flagsProp = "LINK_FLAGS_";
|
|
|
|
flagsProp += CONFIG;
|
|
|
|
if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str()))
|
|
|
|
{
|
|
|
|
flags += " ";
|
|
|
|
flags += flagsConfig;
|
|
|
|
}
|
2009-09-30 00:38:43 +04:00
|
|
|
cmVisualStudioGeneratorOptions
|
2011-11-11 02:17:41 +04:00
|
|
|
linkOptions(this->LocalGenerator,
|
2009-09-30 00:38:43 +04:00
|
|
|
cmVisualStudioGeneratorOptions::Linker,
|
|
|
|
cmVS10LinkFlagTable, 0, this);
|
2009-06-26 00:41:57 +04:00
|
|
|
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:",
|
2009-07-14 00:58:24 +04:00
|
|
|
this->Name.c_str());
|
2009-06-26 00:41:57 +04:00
|
|
|
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)
|
|
|
|
{
|
2009-07-10 17:12:39 +04:00
|
|
|
// first just full path
|
|
|
|
linkDirs += sep;
|
|
|
|
linkDirs += *d;
|
2009-10-22 05:30:41 +04:00
|
|
|
sep = ";";
|
2009-06-26 00:41:57 +04:00
|
|
|
linkDirs += sep;
|
2009-07-10 17:12:39 +04:00
|
|
|
// next path with configuration type Debug, Release, etc
|
2009-06-26 00:41:57 +04:00
|
|
|
linkDirs += *d;
|
2009-07-10 17:12:39 +04:00
|
|
|
linkDirs += "/$(Configuration)";
|
2009-10-22 05:30:41 +04:00
|
|
|
linkDirs += sep;
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
linkDirs += "%(AdditionalLibraryDirectories)";
|
|
|
|
linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs.c_str());
|
|
|
|
linkOptions.AddFlag("AdditionalDependencies", libs.c_str());
|
2011-02-09 20:59:09 +03:00
|
|
|
linkOptions.AddFlag("Version", "");
|
2009-06-26 00:41:57 +04:00
|
|
|
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());
|
|
|
|
}
|
2009-10-23 19:33:27 +04:00
|
|
|
|
|
|
|
std::string dir = this->Target->GetDirectory(config.c_str());
|
2009-06-26 00:41:57 +04:00
|
|
|
dir += "/";
|
|
|
|
std::string pdb = dir;
|
|
|
|
pdb += targetNamePDB;
|
2009-10-23 19:33:27 +04:00
|
|
|
std::string imLib = this->Target->GetDirectory(config.c_str(), true);
|
|
|
|
imLib += "/";
|
|
|
|
imLib += targetNameImport;
|
|
|
|
|
2009-06-26 00:41:57 +04:00
|
|
|
linkOptions.AddFlag("ImportLibrary", imLib.c_str());
|
2012-01-09 23:54:45 +04:00
|
|
|
linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
|
2009-06-26 00:41:57 +04:00
|
|
|
linkOptions.Parse(flags.c_str());
|
2012-03-07 20:56:21 +04:00
|
|
|
if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
|
2009-09-30 00:39:07 +04:00
|
|
|
{
|
|
|
|
linkOptions.AddFlag("ModuleDefinitionFile",
|
2012-03-07 20:56:21 +04:00
|
|
|
this->GeneratorTarget->ModuleDefinitionFile.c_str());
|
2009-09-30 00:39:07 +04:00
|
|
|
}
|
2011-02-09 20:59:09 +03:00
|
|
|
|
|
|
|
linkOptions.RemoveFlag("GenerateManifest");
|
2009-06-26 00:41:57 +04:00
|
|
|
linkOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
|
|
|
|
linkOptions.OutputFlagMap(*this->BuildFileStream, " ");
|
|
|
|
|
|
|
|
this->WriteString("</Link>\n", 2);
|
2009-10-21 00:38:37 +04:00
|
|
|
if(!this->GlobalGenerator->NeedLinkLibraryDependencies(*this->Target))
|
|
|
|
{
|
|
|
|
this->WriteString("<ProjectReference>\n", 2);
|
|
|
|
this->WriteString(
|
|
|
|
" <LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 2);
|
|
|
|
this->WriteString("</ProjectReference>\n", 2);
|
|
|
|
}
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2009-11-19 00:14:36 +03:00
|
|
|
this->ConvertToWindowsSlash(path);
|
2009-06-26 00:41:57 +04:00
|
|
|
libstring += sep;
|
|
|
|
libstring += path;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
libstring += sep;
|
|
|
|
libstring += l->Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cmVisualStudio10TargetGenerator::
|
2009-06-26 06:53:02 +04:00
|
|
|
WriteMidlOptions(std::string const& /*config*/,
|
2009-06-26 00:41:57 +04:00
|
|
|
std::vector<std::string> const & includes)
|
|
|
|
{
|
|
|
|
this->WriteString("<Midl>\n", 2);
|
|
|
|
this->OutputIncludes(includes);
|
2011-01-05 02:51:15 +03:00
|
|
|
this->WriteString("<OutputDirectory>$(IntDir)</OutputDirectory>\n", 3);
|
|
|
|
this->WriteString("<HeaderFileName>%(Filename).h</HeaderFileName>\n", 3);
|
|
|
|
this->WriteString(
|
|
|
|
"<TypeLibraryName>%(Filename).tlb</TypeLibraryName>\n", 3);
|
|
|
|
this->WriteString(
|
|
|
|
"<InterfaceIdentifierFileName>"
|
|
|
|
"%(Filename)_i.c</InterfaceIdentifierFileName>\n", 3);
|
|
|
|
this->WriteString("<ProxyFileName>%(Filename)_p.c</ProxyFileName>\n",3);
|
2009-06-26 00:41:57 +04:00
|
|
|
this->WriteString("</Midl>\n", 2);
|
|
|
|
}
|
2011-01-05 02:51:15 +03:00
|
|
|
|
|
|
|
|
2009-06-26 00:41:57 +04:00
|
|
|
void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
|
2011-01-05 02:51:15 +03:00
|
|
|
{
|
2009-06-26 00:41:57 +04:00
|
|
|
std::vector<std::string> *configs =
|
|
|
|
static_cast<cmGlobalVisualStudio7Generator *>
|
|
|
|
(this->GlobalGenerator)->GetConfigurations();
|
|
|
|
std::vector<std::string> includes;
|
2011-11-05 19:17:49 +04:00
|
|
|
this->LocalGenerator->GetIncludeDirectories(includes, this->Target);
|
2009-06-26 00:41:57 +04:00
|
|
|
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>
|
2012-03-12 18:55:07 +04:00
|
|
|
if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
|
2009-06-26 00:41:57 +04:00
|
|
|
{
|
|
|
|
this->WriteClOptions(*i, includes);
|
|
|
|
// output rc compile flags <ResourceCompile></ResourceCompile>
|
|
|
|
this->WriteRCOptions(*i, includes);
|
|
|
|
}
|
|
|
|
// output midl flags <Midl></Midl>
|
|
|
|
this->WriteMidlOptions(*i, includes);
|
2009-07-10 17:12:39 +04:00
|
|
|
// write events
|
|
|
|
this->WriteEvents(*i);
|
2009-06-28 16:59:56 +04:00
|
|
|
// output link flags <Link></Link>
|
2009-06-26 00:41:57 +04:00
|
|
|
this->WriteLinkOptions(*i);
|
2009-06-28 16:59:56 +04:00
|
|
|
// output lib flags <Lib></Lib>
|
|
|
|
this->WriteLibOptions(*i);
|
2009-06-26 00:41:57 +04:00
|
|
|
this->WriteString("</ItemDefinitionGroup>\n", 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-10 17:12:39 +04:00
|
|
|
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";
|
2009-09-07 18:11:20 +04:00
|
|
|
script +=
|
2010-12-07 21:44:54 +03:00
|
|
|
cmVS10EscapeXML(lg->ConstructScript(command, configName.c_str()));
|
2009-07-10 17:12:39 +04:00
|
|
|
}
|
2010-10-02 00:12:00 +04:00
|
|
|
comment = cmVS10EscapeComment(comment);
|
2009-07-10 17:12:39 +04:00
|
|
|
this->WriteString("<Message>",3);
|
2010-10-02 00:12:00 +04:00
|
|
|
(*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
|
2009-07-10 17:12:39 +04:00
|
|
|
this->WriteString("<Command>", 3);
|
|
|
|
(*this->BuildFileStream ) << script;
|
|
|
|
(*this->BuildFileStream ) << "</Command>" << "\n";
|
|
|
|
this->WriteString("</", 2);
|
|
|
|
(*this->BuildFileStream ) << name << ">\n";
|
|
|
|
}
|
|
|
|
|
2009-06-26 00:41:57 +04:00
|
|
|
|
|
|
|
void cmVisualStudio10TargetGenerator::WriteProjectReferences()
|
|
|
|
{
|
2010-10-07 17:54:24 +04:00
|
|
|
cmGlobalGenerator::TargetDependSet const& unordered
|
2009-07-10 17:12:39 +04:00
|
|
|
= this->GlobalGenerator->GetTargetDirectDepends(*this->Target);
|
2010-10-07 17:54:24 +04:00
|
|
|
typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet
|
|
|
|
OrderedTargetDependSet;
|
|
|
|
OrderedTargetDependSet depends(unordered);
|
2009-07-10 17:12:39 +04:00
|
|
|
this->WriteString("<ItemGroup>\n", 1);
|
2010-10-07 17:54:24 +04:00
|
|
|
for( OrderedTargetDependSet::const_iterator i = depends.begin();
|
2009-07-10 17:12:39 +04:00
|
|
|
i != depends.end(); ++i)
|
|
|
|
{
|
|
|
|
cmTarget* dt = *i;
|
2011-08-04 01:24:43 +04:00
|
|
|
// skip fortran targets as they can not be processed by MSBuild
|
|
|
|
// the only reference will be in the .sln file
|
|
|
|
if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
|
|
|
|
->TargetIsFortranOnly(*dt))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2009-07-10 17:12:39 +04:00
|
|
|
this->WriteString("<ProjectReference Include=\"", 2);
|
|
|
|
cmMakefile* mf = dt->GetMakefile();
|
2009-07-14 00:58:24 +04:00
|
|
|
std::string name = dt->GetName();
|
|
|
|
std::string path;
|
2009-07-14 22:16:46 +04:00
|
|
|
const char* p = dt->GetProperty("EXTERNAL_MSPROJECT");
|
|
|
|
if(p)
|
2009-07-14 00:58:24 +04:00
|
|
|
{
|
2009-07-14 22:16:46 +04:00
|
|
|
path = p;
|
2009-07-14 00:58:24 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
path = mf->GetStartOutputDirectory();
|
|
|
|
path += "/";
|
|
|
|
path += dt->GetName();
|
|
|
|
path += ".vcxproj";
|
|
|
|
}
|
2009-07-10 17:12:39 +04:00
|
|
|
(*this->BuildFileStream) << path << "\">\n";
|
|
|
|
this->WriteString("<Project>", 3);
|
|
|
|
(*this->BuildFileStream)
|
2009-07-14 00:58:24 +04:00
|
|
|
<< this->GlobalGenerator->GetGUID(name.c_str())
|
2009-07-10 17:12:39 +04:00
|
|
|
<< "</Project>\n";
|
|
|
|
this->WriteString("</ProjectReference>\n", 2);
|
|
|
|
}
|
|
|
|
this->WriteString("</ItemGroup>\n", 1);
|
2009-06-26 00:41:57 +04:00
|
|
|
}
|