STYLE: fix line length

This commit is contained in:
Ken Martin 2006-05-12 11:56:09 -04:00
parent 4b176d7f45
commit 7dc8a92246
10 changed files with 376 additions and 226 deletions

View File

@ -17,7 +17,8 @@
#include "cmLinkDirectoriesCommand.h" #include "cmLinkDirectoriesCommand.h"
// cmLinkDirectoriesCommand // cmLinkDirectoriesCommand
bool cmLinkDirectoriesCommand::InitialPass(std::vector<std::string> const& args) bool cmLinkDirectoriesCommand
::InitialPass(std::vector<std::string> const& args)
{ {
if(args.size() < 1 ) if(args.size() < 1 )
{ {

View File

@ -33,7 +33,8 @@ bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args)
++i; ++i;
if(i == args.end()) if(i == args.end())
{ {
this->SetError("The \"debug\" argument must be followed by a library"); this->SetError("The \"debug\" argument must be followed by "
"a library");
return false; return false;
} }
this->Makefile->AddLinkLibrary(i->c_str(), this->Makefile->AddLinkLibrary(i->c_str(),
@ -44,7 +45,8 @@ bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args)
++i; ++i;
if(i == args.end()) if(i == args.end())
{ {
this->SetError("The \"optimized\" argument must be followed by a library"); this->SetError("The \"optimized\" argument must be followed by "
"a library");
return false; return false;
} }
this->Makefile->AddLinkLibrary(i->c_str(), this->Makefile->AddLinkLibrary(i->c_str(),

View File

@ -153,7 +153,9 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
if ( item < 0 || nitem <= (size_t)item ) if ( item < 0 || nitem <= (size_t)item )
{ {
cmOStringStream str; cmOStringStream str;
str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << varArgsExpanded.size()-1 << ")"; str << "index: " << item << " out of range (-"
<< varArgsExpanded.size() << ", "
<< varArgsExpanded.size()-1 << ")";
this->SetError(str.str().c_str()); this->SetError(str.str().c_str());
return false; return false;
} }
@ -221,7 +223,9 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
if ( item < 0 || nitem <= (size_t)item ) if ( item < 0 || nitem <= (size_t)item )
{ {
cmOStringStream str; cmOStringStream str;
str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << varArgsExpanded.size()-1 << ")"; str << "index: " << item << " out of range (-"
<< varArgsExpanded.size() << ", "
<< varArgsExpanded.size()-1 << ")";
this->SetError(str.str().c_str()); this->SetError(str.str().c_str());
return false; return false;
} }
@ -293,11 +297,13 @@ bool cmListCommand::HandleRemoveCommand(std::vector<std::string> const& args)
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
bool cmListCommand::HandleRemoveItemCommand(std::vector<std::string> const& args) bool cmListCommand
::HandleRemoveItemCommand(std::vector<std::string> const& args)
{ {
if(args.size() < 3) if(args.size() < 3)
{ {
this->SetError("sub-command REMOVE_ITEM requires at least two arguments."); this->SetError("sub-command REMOVE_ITEM requires at least "
"two arguments.");
return false; return false;
} }
@ -322,7 +328,9 @@ bool cmListCommand::HandleRemoveItemCommand(std::vector<std::string> const& args
if ( item < 0 || nitem <= (size_t)item ) if ( item < 0 || nitem <= (size_t)item )
{ {
cmOStringStream str; cmOStringStream str;
str << "index: " << item << " out of range (-" << varArgsExpanded.size() << ", " << varArgsExpanded.size()-1 << ")"; str << "index: " << item << " out of range (-"
<< varArgsExpanded.size() << ", "
<< varArgsExpanded.size()-1 << ")";
this->SetError(str.str().c_str()); this->SetError(str.str().c_str());
return false; return false;
} }

View File

@ -44,7 +44,8 @@ bool cmListFile::ParseFile(const char* filename, bool requireProjectCommand)
if(!cmListFileLexer_SetFileName(lexer, filename)) if(!cmListFileLexer_SetFileName(lexer, filename))
{ {
cmListFileLexer_Delete(lexer); cmListFileLexer_Delete(lexer);
cmSystemTools::Error("cmListFileCache: error can not open file ", filename); cmSystemTools::Error("cmListFileCache: error can not open file ",
filename);
return false; return false;
} }
@ -190,7 +191,8 @@ bool cmListFileCacheParseFunction(cmListFileLexer* lexer,
// Error. // Error.
cmOStringStream error; cmOStringStream error;
error << "Error in cmake code at\n" error << "Error in cmake code at\n"
<< filename << ":" << cmListFileLexer_GetCurrentLine(lexer) << ":\n" << filename << ":" << cmListFileLexer_GetCurrentLine(lexer)
<< ":\n"
<< "Parse error. Function missing ending \")\". " << "Parse error. Function missing ending \")\". "
<< "Instead found " << "Instead found "
<< cmListFileLexer_GetTypeAsString(lexer, token->type) << cmListFileLexer_GetTypeAsString(lexer, token->type)

View File

@ -205,7 +205,8 @@ bool cmLoadCacheCommand::ParseEntry(const char* entry, std::string& var,
// input line is: key:type=value // input line is: key:type=value
cmsys::RegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$"); cmsys::RegularExpression reg("^([^:]*):([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
// input line is: "key":type=value // input line is: "key":type=value
cmsys::RegularExpression regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$"); cmsys::RegularExpression
regQuoted("^\"([^\"]*)\":([^=]*)=(.*[^\t ]|[\t ]*)[\t ]*$");
bool flag = false; bool flag = false;
if(regQuoted.find(entry)) if(regQuoted.find(entry))
{ {

View File

@ -63,9 +63,9 @@ public:
" LOAD_COMMAND(COMMAND_NAME <loc1> [loc2 ...])\n" " LOAD_COMMAND(COMMAND_NAME <loc1> [loc2 ...])\n"
"The given locations are searched for a library whose name is " "The given locations are searched for a library whose name is "
"cmCOMMAND_NAME. If found, it is loaded as a module and the command " "cmCOMMAND_NAME. If found, it is loaded as a module and the command "
"is added to the set of available CMake commands. Usually, TRY_COMPILE " "is added to the set of available CMake commands. Usually, "
"is used before this command to compile the module. If the command " "TRY_COMPILE is used before this command to compile the module. "
"is successfully loaded a variable named\n" "If the command is successfully loaded a variable named\n"
" CMAKE_LOADED_COMMAND_<COMMAND_NAME>\n" " CMAKE_LOADED_COMMAND_<COMMAND_NAME>\n"
"will be set to the full path of the module that was loaded. " "will be set to the full path of the module that was loaded. "
"Otherwise the variable will not be set."; "Otherwise the variable will not be set.";

View File

@ -94,12 +94,16 @@ void cmLocalGenerator::SetupPathConversions()
outdir = outdir =
cmSystemTools::CollapseFullPath(this->Makefile->GetStartDirectory()); cmSystemTools::CollapseFullPath(this->Makefile->GetStartDirectory());
cmSystemTools::SplitPath(outdir.c_str(), this->StartDirectoryComponents); cmSystemTools::SplitPath(outdir.c_str(), this->StartDirectoryComponents);
outdir =
cmSystemTools::CollapseFullPath(this->Makefile->GetHomeOutputDirectory()); outdir = cmSystemTools::CollapseFullPath
cmSystemTools::SplitPath(outdir.c_str(), this->HomeOutputDirectoryComponents); (this->Makefile->GetHomeOutputDirectory());
outdir = cmSystemTools::SplitPath(outdir.c_str(),
cmSystemTools::CollapseFullPath(this->Makefile->GetStartOutputDirectory()); this->HomeOutputDirectoryComponents);
cmSystemTools::SplitPath(outdir.c_str(), this->StartOutputDirectoryComponents);
outdir = cmSystemTools::CollapseFullPath
(this->Makefile->GetStartOutputDirectory());
cmSystemTools::SplitPath(outdir.c_str(),
this->StartOutputDirectoryComponents);
} }
@ -139,22 +143,28 @@ void cmLocalGenerator::GenerateTestFiles()
fout.SetCopyIfDifferent(true); fout.SetCopyIfDifferent(true);
fout << "# CMake generated Testfile for " << std::endl fout << "# CMake generated Testfile for " << std::endl
<< "# Source directory: " << this->Makefile->GetStartDirectory() << std::endl << "# Source directory: "
<< "# Build directory: " << this->Makefile->GetStartOutputDirectory() << std::endl << this->Makefile->GetStartDirectory() << std::endl
<< "# " << std::endl << "# Build directory: "
<< "# This file replicates the SUBDIRS() and ADD_TEST() commands from the source" << std::endl << this->Makefile->GetStartOutputDirectory() << std::endl
<< "# tree CMakeLists.txt file, skipping any SUBDIRS() or ADD_TEST() commands" << std::endl << "# " << std::endl
<< "# that are excluded by CMake control structures, i.e. IF() commands." << std::endl << "# This file replicates the SUBDIRS() and ADD_TEST() commands "
<< "#" << std::endl << "from the source" << std::endl
<< "# The next line is critical for Dart to work" << std::endl << "# tree CMakeLists.txt file, skipping any SUBDIRS() or "
<< "# Duh :-)" << std::endl << std::endl; << "ADD_TEST() commands" << std::endl
<< "# that are excluded by CMake control structures, i.e. IF() "
const char* testIncludeFile = this->Makefile->GetProperty("TEST_INCLUDE_FILE"); << "commands." << std::endl
<< "#" << std::endl
<< "# The next line is critical for Dart to work" << std::endl
<< "# Duh :-)" << std::endl << std::endl;
const char* testIncludeFile =
this->Makefile->GetProperty("TEST_INCLUDE_FILE");
if ( testIncludeFile ) if ( testIncludeFile )
{ {
fout << "INCLUDE(\"" << testIncludeFile << "\")" << std::endl; fout << "INCLUDE(\"" << testIncludeFile << "\")" << std::endl;
} }
const std::vector<cmTest*> *tests = this->Makefile->GetTests(); const std::vector<cmTest*> *tests = this->Makefile->GetTests();
std::vector<cmTest*>::const_iterator it; std::vector<cmTest*>::const_iterator it;
for ( it = tests->begin(); it != tests->end(); ++ it ) for ( it = tests->begin(); it != tests->end(); ++ it )
@ -162,15 +172,16 @@ void cmLocalGenerator::GenerateTestFiles()
cmTest* test = *it; cmTest* test = *it;
fout << "ADD_TEST("; fout << "ADD_TEST(";
fout << test->GetName() << " \"" << test->GetCommand() << "\""; fout << test->GetName() << " \"" << test->GetCommand() << "\"";
std::vector<cmStdString>::const_iterator argit; std::vector<cmStdString>::const_iterator argit;
for (argit = test->GetArguments().begin(); for (argit = test->GetArguments().begin();
argit != test->GetArguments().end(); ++argit) argit != test->GetArguments().end(); ++argit)
{ {
// Just double-quote all arguments so they are re-parsed // Just double-quote all arguments so they are re-parsed
// correctly by the test system. // correctly by the test system.
fout << " \""; fout << " \"";
for(std::string::const_iterator c = argit->begin(); c != argit->end(); ++c) for(std::string::const_iterator c = argit->begin();
c != argit->end(); ++c)
{ {
// Escape quotes within arguments. We should escape // Escape quotes within arguments. We should escape
// backslashes too but we cannot because it makes the result // backslashes too but we cannot because it makes the result
@ -233,7 +244,8 @@ void cmLocalGenerator::GenerateTestFiles()
outDir += "/"; outDir += "/";
for(i = 0; i < this->Children.size(); ++i) for(i = 0; i < this->Children.size(); ++i)
{ {
std::string binP = this->Children[i]->GetMakefile()->GetStartOutputDirectory(); std::string binP =
this->Children[i]->GetMakefile()->GetStartOutputDirectory();
cmSystemTools::ReplaceString(binP, outDir.c_str(), ""); cmSystemTools::ReplaceString(binP, outDir.c_str(), "");
if ( i > 0 ) if ( i > 0 )
{ {
@ -279,7 +291,8 @@ void cmLocalGenerator::GenerateInstallRules()
// Compute the set of configurations. // Compute the set of configurations.
std::vector<std::string> configurationTypes; std::vector<std::string> configurationTypes;
if(const char* types = this->Makefile->GetDefinition("CMAKE_CONFIGURATION_TYPES")) if(const char* types =
this->Makefile->GetDefinition("CMAKE_CONFIGURATION_TYPES"))
{ {
cmSystemTools::ExpandListArgument(types, configurationTypes); cmSystemTools::ExpandListArgument(types, configurationTypes);
} }
@ -333,11 +346,12 @@ void cmLocalGenerator::GenerateInstallRules()
fout << "# Install script for directory: " fout << "# Install script for directory: "
<< this->Makefile->GetCurrentDirectory() << std::endl << std::endl; << this->Makefile->GetCurrentDirectory() << std::endl << std::endl;
fout << "# Set the install prefix" << std::endl fout << "# Set the install prefix" << std::endl
<< "IF(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl << "IF(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl
<< " SET(CMAKE_INSTALL_PREFIX \"" << prefix << "\")" << std::endl << " SET(CMAKE_INSTALL_PREFIX \"" << prefix << "\")" << std::endl
<< "ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl << "ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)" << std::endl
<< "STRING(REGEX REPLACE \"/$\" \"\" CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")" << std::endl << "STRING(REGEX REPLACE \"/$\" \"\" CMAKE_INSTALL_PREFIX "
<< std::endl; << "\"${CMAKE_INSTALL_PREFIX}\")" << std::endl
<< std::endl;
// Write support code for generating per-configuration install rules. // Write support code for generating per-configuration install rules.
fout << fout <<
@ -349,7 +363,8 @@ void cmLocalGenerator::GenerateInstallRules()
" ELSE(BUILD_TYPE)\n" " ELSE(BUILD_TYPE)\n"
" SET(CMAKE_INSTALL_CONFIG_NAME \"" << default_config << "\")\n" " SET(CMAKE_INSTALL_CONFIG_NAME \"" << default_config << "\")\n"
" ENDIF(BUILD_TYPE)\n" " ENDIF(BUILD_TYPE)\n"
" MESSAGE(STATUS \"Install configuration: \\\"${CMAKE_INSTALL_CONFIG_NAME}\\\"\")\n" " MESSAGE(STATUS \"Install configuration: "
"\\\"${CMAKE_INSTALL_CONFIG_NAME}\\\"\")\n"
"ENDIF(NOT CMAKE_INSTALL_CONFIG_NAME)\n" "ENDIF(NOT CMAKE_INSTALL_CONFIG_NAME)\n"
"\n"; "\n";
@ -369,7 +384,8 @@ void cmLocalGenerator::GenerateInstallRules()
// Ask each install generator to write its code. // Ask each install generator to write its code.
std::vector<cmInstallGenerator*> const& installers = std::vector<cmInstallGenerator*> const& installers =
this->Makefile->GetInstallGenerators(); this->Makefile->GetInstallGenerators();
for(std::vector<cmInstallGenerator*>::const_iterator gi = installers.begin(); for(std::vector<cmInstallGenerator*>::const_iterator
gi = installers.begin();
gi != installers.end(); ++gi) gi != installers.end(); ++gi)
{ {
(*gi)->Generate(fout, config, configurationTypes); (*gi)->Generate(fout, config, configurationTypes);
@ -574,7 +590,8 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
ofname += "/"; ofname += "/";
ofname += (*i)->GetSourceName() + outExt; ofname += (*i)->GetSourceName() + outExt;
objVector.push_back(ofname); objVector.push_back(ofname);
this->AddCustomCommandToCreateObject(ofname.c_str(), llang, *(*i), target); this->AddCustomCommandToCreateObject(ofname.c_str(),
llang, *(*i), target);
objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE); objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE);
objs += " "; objs += " ";
} }
@ -637,11 +654,13 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang, cmTarget& target)
comment.c_str(), comment.c_str(),
this->Makefile->GetStartOutputDirectory() this->Makefile->GetStartOutputDirectory()
); );
target.GetSourceFiles().push_back(this->Makefile->GetSource(targetFullPath.c_str())); target.GetSourceFiles().push_back
(this->Makefile->GetSource(targetFullPath.c_str()));
} }
void cmLocalGenerator::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang) void cmLocalGenerator
::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang)
{ {
cmTargets &tgts = this->Makefile->GetTargets(); cmTargets &tgts = this->Makefile->GetTargets();
for(cmTargets::iterator l = tgts.begin(); for(cmTargets::iterator l = tgts.begin();
@ -655,11 +674,13 @@ void cmLocalGenerator::CreateCustomTargetsAndCommands(std::set<cmStdString> cons
case cmTarget::MODULE_LIBRARY: case cmTarget::MODULE_LIBRARY:
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
{ {
const char* llang = target.GetLinkerLanguage(this->GetGlobalGenerator()); const char* llang =
target.GetLinkerLanguage(this->GetGlobalGenerator());
if(!llang) if(!llang)
{ {
cmSystemTools::Error("CMake can not determine linker language for target:", cmSystemTools::Error
target.GetName()); ("CMake can not determine linker language for target:",
target.GetName());
return; return;
} }
// if the language is not in the set lang then create custom // if the language is not in the set lang then create custom
@ -680,8 +701,6 @@ void cmLocalGenerator::CreateCustomTargetsAndCommands(std::set<cmStdString> cons
} }
} }
// List of variables that are replaced when // List of variables that are replaced when
// rules are expanced. These variables are // rules are expanced. These variables are
// replaced in the form <var> with GetSafeDefinition(var). // replaced in the form <var> with GetSafeDefinition(var).
@ -863,12 +882,14 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
} }
if(actualReplace == variable) if(actualReplace == variable)
{ {
std::string replace = this->Makefile->GetSafeDefinition(variable.c_str()); std::string replace =
this->Makefile->GetSafeDefinition(variable.c_str());
// if the variable is not a FLAG then treat it like a path // if the variable is not a FLAG then treat it like a path
if(variable.find("_FLAG") == variable.npos) if(variable.find("_FLAG") == variable.npos)
{ {
std::string ret = this->ConvertToOutputForExisting(replace.c_str()); std::string ret = this->ConvertToOutputForExisting(replace.c_str());
// if there is a required first argument to the compiler add it to the compiler string // if there is a required first argument to the compiler add it
// to the compiler string
if(compilerArg1) if(compilerArg1)
{ {
ret += " "; ret += " ";
@ -978,15 +999,16 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang)
{ {
quotePaths = true; quotePaths = true;
} }
bool repeatFlag = true; // should the include flag be repeated like ie. -IA -IB bool repeatFlag = true;
// should the include flag be repeated like ie. -IA -IB
if(!sep) if(!sep)
{ {
sep = " "; sep = " ";
} }
else else
{ {
// if there is a separator then the flag is not repeated but is only given once // if there is a separator then the flag is not repeated but is only
// i.e. -classpath a:b:c // given once i.e. -classpath a:b:c
repeatFlag = false; repeatFlag = false;
} }
bool flagUsed = false; bool flagUsed = false;
@ -1001,7 +1023,9 @@ const char* cmLocalGenerator::GetIncludeFlags(const char* lang)
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str()); frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
if(emitted.insert(frameworkDir).second) if(emitted.insert(frameworkDir).second)
{ {
includeFlags << "-F" << this->ConvertToOutputForExisting(frameworkDir.c_str()) << " "; includeFlags
<< "-F"
<< this->ConvertToOutputForExisting(frameworkDir.c_str()) << " ";
} }
continue; continue;
} }
@ -1081,14 +1105,16 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs)
this->Makefile->GetDefinition("VTK_SOURCE_DIR"); this->Makefile->GetDefinition("VTK_SOURCE_DIR");
if(vtkSourceDir) if(vtkSourceDir)
{ {
const char* vtk_major = this->Makefile->GetDefinition("VTK_MAJOR_VERSION"); const char* vtk_major =
const char* vtk_minor = this->Makefile->GetDefinition("VTK_MINOR_VERSION"); this->Makefile->GetDefinition("VTK_MAJOR_VERSION");
const char* vtk_minor =
this->Makefile->GetDefinition("VTK_MINOR_VERSION");
vtk_major = vtk_major? vtk_major : "4"; vtk_major = vtk_major? vtk_major : "4";
vtk_minor = vtk_minor? vtk_minor : "4"; vtk_minor = vtk_minor? vtk_minor : "4";
int vmajor = 0; int vmajor = 0;
int vminor = 0; int vminor = 0;
if(sscanf(vtk_major, "%d", &vmajor) && sscanf(vtk_minor, "%d", &vminor) && if(sscanf(vtk_major, "%d", &vmajor) &&
vmajor == 4 && vminor <= 4) sscanf(vtk_minor, "%d", &vminor) && vmajor == 4 && vminor <= 4)
{ {
includeSourceDir = true; includeSourceDir = true;
} }
@ -1116,8 +1142,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs)
// This can cause problems with certain standard library // This can cause problems with certain standard library
// implementations because the wrong headers may be found first. // implementations because the wrong headers may be found first.
emitted.insert("/usr/include"); emitted.insert("/usr/include");
if(const char* implicitIncludes = if(const char* implicitIncludes = this->Makefile->GetDefinition
this->Makefile->GetDefinition("CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES")) ("CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES"))
{ {
std::vector<std::string> implicitIncludeVec; std::vector<std::string> implicitIncludeVec;
cmSystemTools::ExpandListArgument(implicitIncludes, implicitIncludeVec); cmSystemTools::ExpandListArgument(implicitIncludes, implicitIncludeVec);
@ -1128,7 +1154,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs)
} }
// Get the project-specified include directories. // Get the project-specified include directories.
std::vector<std::string>& includes = this->Makefile->GetIncludeDirectories(); std::vector<std::string>& includes =
this->Makefile->GetIncludeDirectories();
// Support putting all the in-project include directories first if // Support putting all the in-project include directories first if
// it is requested by the project. // it is requested by the project.
@ -1170,15 +1197,18 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
std::string& linkFlags, std::string& linkFlags,
cmTarget& target) cmTarget& target)
{ {
std::string buildType = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); std::string buildType =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
buildType = cmSystemTools::UpperCase(buildType); buildType = cmSystemTools::UpperCase(buildType);
const char* libraryLinkVariable = "CMAKE_SHARED_LINKER_FLAGS"; // default to shared library const char* libraryLinkVariable =
"CMAKE_SHARED_LINKER_FLAGS"; // default to shared library
switch(target.GetType()) switch(target.GetType())
{ {
case cmTarget::STATIC_LIBRARY: case cmTarget::STATIC_LIBRARY:
{ {
const char* targetLinkFlags = target.GetProperty("STATIC_LIBRARY_FLAGS"); const char* targetLinkFlags =
target.GetProperty("STATIC_LIBRARY_FLAGS");
if(targetLinkFlags) if(targetLinkFlags)
{ {
linkFlags += targetLinkFlags; linkFlags += targetLinkFlags;
@ -1200,7 +1230,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
linkFlags += " "; linkFlags += " ";
} }
if(this->Makefile->IsOn("WIN32") && !(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW"))) if(this->Makefile->IsOn("WIN32") &&
!(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
{ {
const std::vector<cmSourceFile*>& sources = target.GetSourceFiles(); const std::vector<cmSourceFile*>& sources = target.GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin(); for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
@ -1208,8 +1239,10 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
{ {
if((*i)->GetSourceExtension() == "def") if((*i)->GetSourceExtension() == "def")
{ {
linkFlags += this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG"); linkFlags +=
linkFlags += this->Convert((*i)->GetFullPath().c_str(),START_OUTPUT,MAKEFILE); this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
linkFlags += this->Convert((*i)->GetFullPath().c_str(),
START_OUTPUT,MAKEFILE);
linkFlags += " "; linkFlags += " ";
} }
} }
@ -1235,7 +1268,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
break; break;
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
{ {
linkFlags += this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); linkFlags +=
this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
linkFlags += " "; linkFlags += " ";
if(buildType.size()) if(buildType.size())
{ {
@ -1244,11 +1278,13 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
linkFlags += this->Makefile->GetSafeDefinition(build.c_str()); linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
linkFlags += " "; linkFlags += " ";
} }
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); const char* linkLanguage =
target.GetLinkerLanguage(this->GetGlobalGenerator());
if(!linkLanguage) if(!linkLanguage)
{ {
cmSystemTools::Error("CMake can not determine linker language for target:", cmSystemTools::Error
target.GetName()); ("CMake can not determine linker language for target:",
target.GetName());
return; return;
} }
std::string langVar = "CMAKE_"; std::string langVar = "CMAKE_";
@ -1264,21 +1300,24 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
cmOStringStream linklibs; cmOStringStream linklibs;
this->OutputLinkLibraries(linklibs, target, false); this->OutputLinkLibraries(linklibs, target, false);
linkLibs = linklibs.str(); linkLibs = linklibs.str();
if(cmSystemTools::IsOn(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) if(cmSystemTools::IsOn
(this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
{ {
std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + linkLanguage std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_")
+ std::string("_FLAGS"); + linkLanguage + std::string("_FLAGS");
linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str()); linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str());
linkFlags += " "; linkFlags += " ";
} }
if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") ) if ( target.GetPropertyAsBool("WIN32_EXECUTABLE") )
{ {
linkFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE"); linkFlags +=
this->Makefile->GetSafeDefinition("CMAKE_CREATE_WIN32_EXE");
linkFlags += " "; linkFlags += " ";
} }
else else
{ {
linkFlags += this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE"); linkFlags +=
this->Makefile->GetSafeDefinition("CMAKE_CREATE_CONSOLE_EXE");
linkFlags += " "; linkFlags += " ";
} }
const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
@ -1323,7 +1362,8 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
std::string runtimeSep; std::string runtimeSep;
const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE"); const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
const char* linkLanguage = tgt.GetLinkerLanguage(this->GetGlobalGenerator()); const char* linkLanguage =
tgt.GetLinkerLanguage(this->GetGlobalGenerator());
if(!linkLanguage) if(!linkLanguage)
{ {
cmSystemTools:: cmSystemTools::
@ -1348,8 +1388,10 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
// Some search paths should never be emitted // Some search paths should never be emitted
emitted.insert(""); emitted.insert("");
emitted.insert("/usr/lib"); emitted.insert("/usr/lib");
std::string libPathFlag = this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG"); std::string libPathFlag =
std::string libLinkFlag = this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG"); this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG");
std::string libLinkFlag =
this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG");
// collect all the flags needed for linking libraries // collect all the flags needed for linking libraries
std::string linkLibs; std::string linkLibs;
@ -1466,12 +1508,12 @@ void cmLocalGenerator::OutputLinkLibraries(std::ostream& fout,
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
void void cmLocalGenerator
cmLocalGenerator::ComputeLinkInformation(cmTarget& target, ::ComputeLinkInformation(cmTarget& target,
const char* config, const char* config,
std::vector<cmStdString>& outLibs, std::vector<cmStdString>& outLibs,
std::vector<cmStdString>& outDirs, std::vector<cmStdString>& outDirs,
std::vector<cmStdString>* fullPathLibs) std::vector<cmStdString>* fullPathLibs)
{ {
// Compute which library configuration to link. // Compute which library configuration to link.
cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED; cmTarget::LinkLibraryType linkType = cmTarget::OPTIMIZED;
@ -1779,7 +1821,8 @@ cmLocalGenerator::ConstructScript(const cmCustomCommandLines& commandLines,
// if CMAKE_MSVCIDE_RUN_PATH is set. // if CMAKE_MSVCIDE_RUN_PATH is set.
if(this->Makefile->GetDefinition("MSVC_IDE")) if(this->Makefile->GetDefinition("MSVC_IDE"))
{ {
const char* extraPath = this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH"); const char* extraPath =
this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH");
if(extraPath) if(extraPath)
{ {
script += "set PATH="; script += "set PATH=";
@ -1863,22 +1906,26 @@ std::string cmLocalGenerator::Convert(const char* source,
case HOME: case HOME:
//result = cmSystemTools::CollapseFullPath(result.c_str()); //result = cmSystemTools::CollapseFullPath(result.c_str());
result = this->GlobalGenerator-> result = this->GlobalGenerator->
ConvertToRelativePath(this->HomeDirectoryComponents, result.c_str()); ConvertToRelativePath(this->HomeDirectoryComponents,
result.c_str());
break; break;
case START: case START:
//result = cmSystemTools::CollapseFullPath(result.c_str()); //result = cmSystemTools::CollapseFullPath(result.c_str());
result = this->GlobalGenerator-> result = this->GlobalGenerator->
ConvertToRelativePath(this->StartDirectoryComponents, result.c_str()); ConvertToRelativePath(this->StartDirectoryComponents,
result.c_str());
break; break;
case HOME_OUTPUT: case HOME_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str()); //result = cmSystemTools::CollapseFullPath(result.c_str());
result = this->GlobalGenerator-> result = this->GlobalGenerator->
ConvertToRelativePath(this->HomeOutputDirectoryComponents, result.c_str()); ConvertToRelativePath(this->HomeOutputDirectoryComponents,
result.c_str());
break; break;
case START_OUTPUT: case START_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str()); //result = cmSystemTools::CollapseFullPath(result.c_str());
result = this->GlobalGenerator-> result = this->GlobalGenerator->
ConvertToRelativePath(this->StartOutputDirectoryComponents, result.c_str()); ConvertToRelativePath(this->StartOutputDirectoryComponents,
result.c_str());
break; break;
case FULL: case FULL:
result = cmSystemTools::CollapseFullPath(result.c_str()); result = cmSystemTools::CollapseFullPath(result.c_str());

View File

@ -48,7 +48,8 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
if(strcmp(this->Makefile->GetStartOutputDirectory(), if(strcmp(this->Makefile->GetStartOutputDirectory(),
this->Makefile->GetHomeDirectory()) != 0) this->Makefile->GetHomeDirectory()) != 0)
{ {
if(!cmSystemTools::MakeDirectory(this->Makefile->GetStartOutputDirectory())) if(!cmSystemTools::MakeDirectory
(this->Makefile->GetStartOutputDirectory()))
{ {
cmSystemTools::Error("Error creating directory ", cmSystemTools::Error("Error creating directory ",
this->Makefile->GetStartOutputDirectory()); this->Makefile->GetStartOutputDirectory());
@ -178,7 +179,8 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
} }
} }
void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname, cmTarget &target) void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname,
cmTarget &target)
{ {
// add to the list of projects // add to the list of projects
std::string pname = lname; std::string pname = lname;
@ -209,7 +211,8 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
{ {
std::string dspname = tgt.GetName(); std::string dspname = tgt.GetName();
dspname += ".dsp.cmake"; dspname += ".dsp.cmake";
const char* dsprule = this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"); const char* dsprule =
this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
cmCustomCommandLine commandLine; cmCustomCommandLine commandLine;
commandLine.push_back(dsprule); commandLine.push_back(dsprule);
std::string makefileIn = this->Makefile->GetStartDirectory(); std::string makefileIn = this->Makefile->GetStartDirectory();
@ -219,8 +222,8 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
comment += makefileIn; comment += makefileIn;
std::string args; std::string args;
args = "-H"; args = "-H";
args += args += this->Convert(this->Makefile->GetHomeDirectory(),
this->Convert(this->Makefile->GetHomeDirectory(),START_OUTPUT, SHELL, true); START_OUTPUT, SHELL, true);
commandLine.push_back(args); commandLine.push_back(args);
args = "-B"; args = "-B";
args += args +=
@ -329,8 +332,8 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
{ {
// Add the file to the list of sources. // Add the file to the list of sources.
std::string source = (*i)->GetFullPath(); std::string source = (*i)->GetFullPath();
cmSourceGroup& sourceGroup = this->Makefile->FindSourceGroup(source.c_str(), cmSourceGroup& sourceGroup =
sourceGroups); this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
sourceGroup.AssignSource(*i); sourceGroup.AssignSource(*i);
// while we are at it, if it is a .rule file then for visual studio 6 we // while we are at it, if it is a .rule file then for visual studio 6 we
// must generate it // must generate it
@ -341,7 +344,8 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
cmSystemTools::ReplaceString(source, "$(IntDir)/", ""); cmSystemTools::ReplaceString(source, "$(IntDir)/", "");
#if defined(_WIN32) || defined(__CYGWIN__) #if defined(_WIN32) || defined(__CYGWIN__)
std::ofstream fout(source.c_str(), std::ofstream fout(source.c_str(),
std::ios::binary | std::ios::out | std::ios::trunc); std::ios::binary | std::ios::out
| std::ios::trunc);
#else #else
std::ofstream fout(source.c_str(), std::ofstream fout(source.c_str(),
std::ios::out | std::ios::trunc); std::ios::out | std::ios::trunc);
@ -371,7 +375,9 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
this->WriteDSPFooter(fout); this->WriteDSPFooter(fout);
} }
void cmLocalVisualStudio6Generator::WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, const char *libName) void cmLocalVisualStudio6Generator
::WriteGroup(const cmSourceGroup *sg, cmTarget target,
std::ostream &fout, const char *libName)
{ {
const std::vector<const cmSourceFile *> &sourceFiles = const std::vector<const cmSourceFile *> &sourceFiles =
sg->GetSourceFiles(); sg->GetSourceFiles();
@ -405,8 +411,8 @@ void cmLocalVisualStudio6Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
compileFlags += cflags; compileFlags += cflags;
} }
const char* lang = const char* lang = this->GlobalGenerator->
this->GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str()); GetLanguageFromExtension((*sf)->GetSourceExtension().c_str());
if(lang && strcmp(lang, "CXX") == 0) if(lang && strcmp(lang, "CXX") == 0)
{ {
// force a C++ file type // force a C++ file type
@ -461,7 +467,8 @@ void cmLocalVisualStudio6Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
else if(compileFlags.size()) else if(compileFlags.size())
{ {
for(std::vector<std::string>::iterator i for(std::vector<std::string>::iterator i
= this->Configurations.begin(); i != this->Configurations.end(); ++i) = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{ {
if (i == this->Configurations.begin()) if (i == this->Configurations.begin())
{ {
@ -580,7 +587,8 @@ cmLocalVisualStudio6Generator
fout << "\n\n"; fout << "\n\n";
if(outputs.empty()) if(outputs.empty())
{ {
fout << source << "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t"; fout << source
<< "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
fout << command << "\n\n"; fout << command << "\n\n";
} }
else else
@ -623,7 +631,8 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
cmTarget& target) cmTarget& target)
{ {
std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT"); std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT");
const char *def= this->Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY"); const char *def=
this->Makefile->GetDefinition( "MSPROJECT_TEMPLATE_DIRECTORY");
if( def) if( def)
{ {
@ -683,7 +692,8 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
} }
// reset this->Configurations // reset this->Configurations
this->Configurations.erase(this->Configurations.begin(), this->Configurations.end()); this->Configurations.erase(this->Configurations.begin(),
this->Configurations.end());
// now add all the configurations possible // now add all the configurations possible
std::string line; std::string line;
while(cmSystemTools::GetLineFromStream(fin, line)) while(cmSystemTools::GetLineFromStream(fin, line))
@ -761,7 +771,8 @@ cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target,
// Write the post-build rules. Make sure no continuation character // Write the post-build rules. Make sure no continuation character
// is put on the last line. // is put on the last line.
int postbuild_total = static_cast<int>(target.GetPostBuildCommands().size()); int postbuild_total =
static_cast<int>(target.GetPostBuildCommands().size());
int postbuild_count = 0; int postbuild_count = 0;
const char* postbuild_newline = "\\\n\t"; const char* postbuild_newline = "\\\n\t";
if(postbuild_total > 0) if(postbuild_total > 0)
@ -859,7 +870,8 @@ void cmLocalVisualStudio6Generator
lpath = "."; lpath = ".";
} }
std::string lpathIntDir = libPath + "$(INTDIR)"; std::string lpathIntDir = libPath + "$(INTDIR)";
lpathIntDir = this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str()); lpathIntDir =
this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
if(pathEmitted.insert(lpath).second) if(pathEmitted.insert(lpath).second)
{ {
libOptions += " /LIBPATH:"; libOptions += " /LIBPATH:";
@ -891,7 +903,8 @@ void cmLocalVisualStudio6Generator
lpath = "."; lpath = ".";
} }
std::string lpathIntDir = exePath + "$(INTDIR)"; std::string lpathIntDir = exePath + "$(INTDIR)";
lpathIntDir = this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str()); lpathIntDir =
this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
if(pathEmitted.insert(lpath).second) if(pathEmitted.insert(lpath).second)
{ {
@ -931,7 +944,8 @@ void cmLocalVisualStudio6Generator
lpath = "."; lpath = ".";
} }
std::string lpathIntDir = path + "$(INTDIR)"; std::string lpathIntDir = path + "$(INTDIR)";
lpathIntDir = this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str()); lpathIntDir =
this->ConvertToOptionallyRelativeOutputPath(lpathIntDir.c_str());
if(pathEmitted.insert(lpath).second) if(pathEmitted.insert(lpath).second)
{ {
libOptions += " /LIBPATH:"; libOptions += " /LIBPATH:";
@ -975,8 +989,10 @@ void cmLocalVisualStudio6Generator
cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str()); cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str());
if(tgt) if(tgt)
{ {
lib = cmSystemTools::GetFilenameWithoutExtension(tgt->GetFullName().c_str()); lib = cmSystemTools::GetFilenameWithoutExtension
libDebug = cmSystemTools::GetFilenameWithoutExtension(tgt->GetFullName("Debug").c_str()); (tgt->GetFullName().c_str());
libDebug = cmSystemTools::GetFilenameWithoutExtension
(tgt->GetFullName("Debug").c_str());
lib += ".lib"; lib += ".lib";
libDebug += ".lib"; libDebug += ".lib";
} }
@ -991,7 +1007,8 @@ void cmLocalVisualStudio6Generator
} }
} }
lib = this->ConvertToOptionallyRelativeOutputPath(lib.c_str()); lib = this->ConvertToOptionallyRelativeOutputPath(lib.c_str());
libDebug = this->ConvertToOptionallyRelativeOutputPath(libDebug.c_str()); libDebug =
this->ConvertToOptionallyRelativeOutputPath(libDebug.c_str());
if (j->second == cmTarget::GENERAL) if (j->second == cmTarget::GENERAL)
{ {
@ -1030,15 +1047,18 @@ void cmLocalVisualStudio6Generator
std::string extraLinkOptions; std::string extraLinkOptions;
if(target.GetType() == cmTarget::EXECUTABLE) if(target.GetType() == cmTarget::EXECUTABLE)
{ {
extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS"); extraLinkOptions =
this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS");
} }
if(target.GetType() == cmTarget::SHARED_LIBRARY) if(target.GetType() == cmTarget::SHARED_LIBRARY)
{ {
extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS"); extraLinkOptions =
this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS");
} }
if(target.GetType() == cmTarget::MODULE_LIBRARY) if(target.GetType() == cmTarget::MODULE_LIBRARY)
{ {
extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS"); extraLinkOptions =
this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS");
} }
// Get extra linker options for this target. // Get extra linker options for this target.
@ -1053,11 +1073,13 @@ void cmLocalVisualStudio6Generator
target.GetType() <= cmTarget::MODULE_LIBRARY) target.GetType() <= cmTarget::MODULE_LIBRARY)
{ {
// Get the language to use for linking. // Get the language to use for linking.
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); const char* linkLanguage =
target.GetLinkerLanguage(this->GetGlobalGenerator());
if(!linkLanguage) if(!linkLanguage)
{ {
cmSystemTools::Error("CMake can not determine linker language for target:", cmSystemTools::Error
target.GetName()); ("CMake can not determine linker language for target:",
target.GetName());
return; return;
} }
@ -1077,7 +1099,8 @@ void cmLocalVisualStudio6Generator
} }
// Compute the real name of the target. // Compute the real name of the target.
std::string outputName = "(OUTPUT_NAME is for libraries and executables only)"; std::string outputName =
"(OUTPUT_NAME is for libraries and executables only)";
std::string outputNameDebug = outputName; std::string outputNameDebug = outputName;
std::string outputNameRelease = outputName; std::string outputNameRelease = outputName;
std::string outputNameMinSizeRel = outputName; std::string outputNameMinSizeRel = outputName;
@ -1201,17 +1224,25 @@ void cmLocalVisualStudio6Generator
#endif #endif
// Substitute the real output name into the template. // Substitute the real output name into the template.
cmSystemTools::ReplaceString(line, "OUTPUT_NAME_DEBUG", outputNameDebug.c_str()); cmSystemTools::ReplaceString(line, "OUTPUT_NAME_DEBUG",
cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELEASE", outputNameRelease.c_str()); outputNameDebug.c_str());
cmSystemTools::ReplaceString(line, "OUTPUT_NAME_MINSIZEREL", outputNameMinSizeRel.c_str()); cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELEASE",
cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELWITHDEBINFO", outputNameRelWithDebInfo.c_str()); outputNameRelease.c_str());
cmSystemTools::ReplaceString(line, "OUTPUT_NAME_MINSIZEREL",
outputNameMinSizeRel.c_str());
cmSystemTools::ReplaceString(line, "OUTPUT_NAME_RELWITHDEBINFO",
outputNameRelWithDebInfo.c_str());
cmSystemTools::ReplaceString(line, "OUTPUT_NAME", outputName.c_str()); cmSystemTools::ReplaceString(line, "OUTPUT_NAME", outputName.c_str());
// Substitute the proper link information into the template. // Substitute the proper link information into the template.
cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_DEBUG", optionsDebug.c_str()); cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_DEBUG",
cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELEASE", optionsRelease.c_str()); optionsDebug.c_str());
cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_MINSIZEREL", optionsMinSizeRel.c_str()); cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELEASE",
cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELWITHDEBINFO", optionsRelWithDebInfo.c_str()); optionsRelease.c_str());
cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_MINSIZEREL",
optionsMinSizeRel.c_str());
cmSystemTools::ReplaceString(line, "CM_MULTILINE_OPTIONS_RELWITHDEBINFO",
optionsRelWithDebInfo.c_str());
cmSystemTools::ReplaceString(line, "BUILD_INCLUDES", cmSystemTools::ReplaceString(line, "BUILD_INCLUDES",
this->IncludeOptions.c_str()); this->IncludeOptions.c_str());
@ -1220,13 +1251,14 @@ void cmLocalVisualStudio6Generator
// are already quoted in the template file, // are already quoted in the template file,
// we need to remove the quotes here, we still need // we need to remove the quotes here, we still need
// to convert to output path for unix to win32 conversion // to convert to output path for unix to win32 conversion
cmSystemTools::ReplaceString(line, "LIBRARY_OUTPUT_PATH", cmSystemTools::ReplaceString
removeQuotes( (line, "LIBRARY_OUTPUT_PATH",
this->ConvertToOptionallyRelativeOutputPath(libPath.c_str())).c_str()); removeQuotes(this->ConvertToOptionallyRelativeOutputPath
cmSystemTools::ReplaceString(line, "EXECUTABLE_OUTPUT_PATH", (libPath.c_str())).c_str());
removeQuotes( cmSystemTools::ReplaceString
this->ConvertToOptionallyRelativeOutputPath(exePath.c_str())).c_str()); (line, "EXECUTABLE_OUTPUT_PATH",
removeQuotes(this->ConvertToOptionallyRelativeOutputPath
(exePath.c_str())).c_str());
cmSystemTools::ReplaceString(line, cmSystemTools::ReplaceString(line,
"EXTRA_DEFINES", "EXTRA_DEFINES",
@ -1244,11 +1276,13 @@ void cmLocalVisualStudio6Generator
if(target.GetType() >= cmTarget::EXECUTABLE && if(target.GetType() >= cmTarget::EXECUTABLE &&
target.GetType() <= cmTarget::MODULE_LIBRARY) target.GetType() <= cmTarget::MODULE_LIBRARY)
{ {
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); const char* linkLanguage =
target.GetLinkerLanguage(this->GetGlobalGenerator());
if(!linkLanguage) if(!linkLanguage)
{ {
cmSystemTools::Error("CMake can not determine linker language for target:", cmSystemTools::Error
target.GetName()); ("CMake can not determine linker language for target:",
target.GetName());
return; return;
} }
// if CXX is on and the target contains cxx code then add the cxx flags // if CXX is on and the target contains cxx code then add the cxx flags
@ -1260,7 +1294,8 @@ void cmLocalVisualStudio6Generator
std::string flagVar = baseFlagVar + "_RELEASE"; std::string flagVar = baseFlagVar + "_RELEASE";
flagsRelease = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagsRelease = this->Makefile->GetSafeDefinition(flagVar.c_str());
flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" "; flagsRelease += " -DCMAKE_INTDIR=\\\"Release\\\" ";
if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_RELEASE")) if(const char* targetLinkFlags =
target.GetProperty("LINK_FLAGS_RELEASE"))
{ {
flagsRelease += targetLinkFlags; flagsRelease += targetLinkFlags;
flagsRelease += " "; flagsRelease += " ";
@ -1268,7 +1303,8 @@ void cmLocalVisualStudio6Generator
flagVar = baseFlagVar + "_MINSIZEREL"; flagVar = baseFlagVar + "_MINSIZEREL";
flagsMinSize = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagsMinSize = this->Makefile->GetSafeDefinition(flagVar.c_str());
flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" "; flagsMinSize += " -DCMAKE_INTDIR=\\\"MinSizeRel\\\" ";
if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_MINSIZEREL")) if(const char* targetLinkFlags =
target.GetProperty("LINK_FLAGS_MINSIZEREL"))
{ {
flagsMinSize += targetLinkFlags; flagsMinSize += targetLinkFlags;
flagsMinSize += " "; flagsMinSize += " ";
@ -1286,7 +1322,8 @@ void cmLocalVisualStudio6Generator
flagVar = baseFlagVar + "_RELWITHDEBINFO"; flagVar = baseFlagVar + "_RELWITHDEBINFO";
flagsDebugRel = this->Makefile->GetSafeDefinition(flagVar.c_str()); flagsDebugRel = this->Makefile->GetSafeDefinition(flagVar.c_str());
flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" "; flagsDebugRel += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
if(const char* targetLinkFlags = target.GetProperty("LINK_FLAGS_RELWITHDEBINFO")) if(const char* targetLinkFlags =
target.GetProperty("LINK_FLAGS_RELWITHDEBINFO"))
{ {
flagsDebugRel += targetLinkFlags; flagsDebugRel += targetLinkFlags;
flagsDebugRel += " "; flagsDebugRel += " ";
@ -1313,10 +1350,14 @@ void cmLocalVisualStudio6Generator
// There are not separate CXX and C template files, so we use the same // There are not separate CXX and C template files, so we use the same
// variable names. The previous code sets up flags* variables to contain // variable names. The previous code sets up flags* variables to contain
// the correct C or CXX flags // the correct C or CXX flags
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL", flagsMinSize.c_str()); cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_MINSIZEREL",
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG", flagsDebug.c_str()); flagsMinSize.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELWITHDEBINFO", flagsDebugRel.c_str()); cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_DEBUG",
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE", flagsRelease.c_str()); flagsDebug.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELWITHDEBINFO",
flagsDebugRel.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS_RELEASE",
flagsRelease.c_str());
cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str()); cmSystemTools::ReplaceString(line, "CMAKE_CXX_FLAGS", flags.c_str());
fout << line.c_str() << std::endl; fout << line.c_str() << std::endl;
} }
@ -1337,11 +1378,12 @@ void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout)
} }
} }
//----------------------------------------------------------------------------- //----------------------------------------------------------------------------
void cmLocalVisualStudio6Generator::ComputeLinkOptions(cmTarget& target, void cmLocalVisualStudio6Generator
const char* configName, ::ComputeLinkOptions(cmTarget& target,
const std::string extraOptions, const char* configName,
std::string& options) const std::string extraOptions,
std::string& options)
{ {
// Compute the link information for this configuration. // Compute the link information for this configuration.
std::vector<cmStdString> linkLibs; std::vector<cmStdString> linkLibs;

View File

@ -54,7 +54,8 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
if(strcmp(this->Makefile->GetStartOutputDirectory(), if(strcmp(this->Makefile->GetStartOutputDirectory(),
this->Makefile->GetHomeDirectory()) != 0) this->Makefile->GetHomeDirectory()) != 0)
{ {
if(!cmSystemTools::MakeDirectory(this->Makefile->GetStartOutputDirectory())) if(!cmSystemTools::MakeDirectory
(this->Makefile->GetStartOutputDirectory()))
{ {
cmSystemTools::Error("Error creating directory ", cmSystemTools::Error("Error creating directory ",
this->Makefile->GetStartOutputDirectory()); this->Makefile->GetStartOutputDirectory());
@ -78,7 +79,8 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
this->ExecutableOutputPath = ""; this->ExecutableOutputPath = "";
if (this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH")) if (this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
{ {
this->ExecutableOutputPath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"); this->ExecutableOutputPath =
this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
} }
if(this->ExecutableOutputPath.size()) if(this->ExecutableOutputPath.size())
{ {
@ -134,7 +136,8 @@ void cmLocalVisualStudio7Generator::OutputVCProjFile()
} }
} }
void cmLocalVisualStudio7Generator::CreateSingleVCProj(const char *lname, cmTarget &target) void cmLocalVisualStudio7Generator
::CreateSingleVCProj(const char *lname, cmTarget &target)
{ {
// add to the list of projects // add to the list of projects
std::string pname = lname; std::string pname = lname;
@ -164,7 +167,8 @@ void cmLocalVisualStudio7Generator::AddVCProjBuildRule(cmTarget& tgt)
{ {
std::string dspname = tgt.GetName(); std::string dspname = tgt.GetName();
dspname += ".vcproj.cmake"; dspname += ".vcproj.cmake";
const char* dsprule = this->Makefile->GetRequiredDefinition("CMAKE_COMMAND"); const char* dsprule =
this->Makefile->GetRequiredDefinition("CMAKE_COMMAND");
cmCustomCommandLine commandLine; cmCustomCommandLine commandLine;
commandLine.push_back(dsprule); commandLine.push_back(dsprule);
std::string makefileIn = this->Makefile->GetStartDirectory(); std::string makefileIn = this->Makefile->GetStartDirectory();
@ -174,8 +178,8 @@ void cmLocalVisualStudio7Generator::AddVCProjBuildRule(cmTarget& tgt)
comment += makefileIn; comment += makefileIn;
std::string args; std::string args;
args = "-H"; args = "-H";
args += args += this->Convert(this->Makefile->GetHomeDirectory(),
this->Convert(this->Makefile->GetHomeDirectory(), START_OUTPUT, SHELL, true); START_OUTPUT, SHELL, true);
commandLine.push_back(args); commandLine.push_back(args);
args = "-B"; args = "-B";
args += args +=
@ -224,7 +228,9 @@ void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout,
cmTarget &target) cmTarget &target)
{ {
std::vector<std::string> *configs = std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator)->GetConfigurations(); static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
fout << "\t<Configurations>\n"; fout << "\t<Configurations>\n";
for( std::vector<std::string>::iterator i = configs->begin(); for( std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i) i != configs->end(); ++i)
@ -243,17 +249,17 @@ struct cmVS7FlagTable
const char* value; // string value const char* value; // string value
}; };
// fill the table here // fill the table here currently the comment field is not used for
// currently the comment field is not used for anything other than documentation // anything other than documentation NOTE: Make sure the longer
// NOTE: Make sure the longer commandFlag comes FIRST! // commandFlag comes FIRST!
cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] = cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] =
{ {
// option flags (some flags map to the same option) // option flags (some flags map to the same option)
{"BasicRuntimeChecks", "GZ", "Stack frame checks", "1"}, {"BasicRuntimeChecks", "GZ", "Stack frame checks", "1"},
{"BasicRuntimeChecks", "RTCsu", "Both stack and uninitialized checks ", "3"}, {"BasicRuntimeChecks", "RTCsu", "Both stack and uninitialized checks", "3"},
{"BasicRuntimeChecks", "RTCs", "Stack frame checks", "1"}, {"BasicRuntimeChecks", "RTCs", "Stack frame checks", "1"},
{"BasicRuntimeChecks", "RTCu", "Uninitialized Variables ", "2"}, {"BasicRuntimeChecks", "RTCu", "Uninitialized Variables ", "2"},
{"BasicRuntimeChecks", "RTC1", "Both stack and uninitialized checks ", "3"}, {"BasicRuntimeChecks", "RTC1", "Both stack and uninitialized checks ", "3"},
{"DebugInformationFormat", "Z7", "debug format", "1"}, {"DebugInformationFormat", "Z7", "debug format", "1"},
{"DebugInformationFormat", "Zd", "debug format", "2"}, {"DebugInformationFormat", "Zd", "debug format", "2"},
{"DebugInformationFormat", "Zi", "debug format", "3"}, {"DebugInformationFormat", "Zi", "debug format", "3"},
@ -299,11 +305,13 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorFlagTable[] =
{"ExceptionHandling", "EHsc", "enable c++ exceptions", "TRUE"}, {"ExceptionHandling", "EHsc", "enable c++ exceptions", "TRUE"},
{"ExceptionHandling", "GX", "enable c++ exceptions", "TRUE"}, {"ExceptionHandling", "GX", "enable c++ exceptions", "TRUE"},
{"GlobalOptimizations", "Og", "Global Optimize", "TRUE"}, {"GlobalOptimizations", "Og", "Global Optimize", "TRUE"},
{"ImproveFloatingPointConsistency", "Op", "ImproveFloatingPointConsistency", "TRUE"}, {"ImproveFloatingPointConsistency", "Op",
"ImproveFloatingPointConsistency", "TRUE"},
{"MinimalRebuild", "Gm", "minimal rebuild", "TRUE"}, {"MinimalRebuild", "Gm", "minimal rebuild", "TRUE"},
{"OmitFramePointers", "Oy", "OmitFramePointers", "TRUE"}, {"OmitFramePointers", "Oy", "OmitFramePointers", "TRUE"},
{"OptimizeForWindowsApplication", "GA", "Optimize for windows", "TRUE"}, {"OptimizeForWindowsApplication", "GA", "Optimize for windows", "TRUE"},
{"RuntimeTypeInfo", "GR", "Turn on Run time type information for c++", "TRUE"}, {"RuntimeTypeInfo", "GR",
"Turn on Run time type information for c++", "TRUE"},
{"SmallerTypeCheck", "RTCc", "smaller type check", "TRUE"}, {"SmallerTypeCheck", "RTCc", "smaller type check", "TRUE"},
{"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "TRUE"}, {"SuppressStartupBanner", "nologo", "SuppressStartupBanner", "TRUE"},
{"WarnAsError", "WX", "Treat warnings as errors", "TRUE"}, {"WarnAsError", "WX", "Treat warnings as errors", "TRUE"},
@ -379,11 +387,13 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
std::string flags; std::string flags;
if(strcmp(configType, "10") != 0) if(strcmp(configType, "10") != 0)
{ {
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); const char* linkLanguage =
target.GetLinkerLanguage(this->GetGlobalGenerator());
if(!linkLanguage) if(!linkLanguage)
{ {
cmSystemTools::Error("CMake can not determine linker language for target:", cmSystemTools::Error
target.GetName()); ("CMake can not determine linker language for target:",
target.GetName());
return; return;
} }
if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0) if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0)
@ -446,16 +456,16 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
// now fill the flagMap from the command line flags, and // now fill the flagMap from the command line flags, and
// if a flag is used, it will be removed from the flags string by // if a flag is used, it will be removed from the flags string by
// this function call // this function call
this->FillFlagMapFromCommandFlags(flagMap, this->FillFlagMapFromCommandFlags
&cmLocalVisualStudio7GeneratorFlagTable[0], (flagMap, &cmLocalVisualStudio7GeneratorFlagTable[0], flags);
flags);
std::string defineFlags = this->Makefile->GetDefineFlags(); std::string defineFlags = this->Makefile->GetDefineFlags();
// now check the define flags for flags other than -D and // now check the define flags for flags other than -D and
// put them in the map, the -D flags will be left in the defineFlags // put them in the map, the -D flags will be left in the defineFlags
// variable as -D is not in the flagMap // variable as -D is not in the flagMap
this->FillFlagMapFromCommandFlags(flagMap, this->FillFlagMapFromCommandFlags
&cmLocalVisualStudio7GeneratorFlagTable[0], (flagMap, &cmLocalVisualStudio7GeneratorFlagTable[0], defineFlags);
defineFlags);
// output remaining flags that were not mapped to anything // output remaining flags that were not mapped to anything
fout << this->EscapeForXML(flags.c_str()).c_str(); fout << this->EscapeForXML(flags.c_str()).c_str();
fout << " -DCMAKE_INTDIR=\\&quot;" << configName << "\\&quot;" fout << " -DCMAKE_INTDIR=\\&quot;" << configName << "\\&quot;"
@ -477,7 +487,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
} }
if ( this->Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL") ) if ( this->Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL") )
{ {
flagMap["WarningLevel"] = this->Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL"); flagMap["WarningLevel"] =
this->Makefile->GetDefinition("CMAKE_CXX_WARNING_LEVEL");
} }
// Now copy the flag map into the xml for the file // Now copy the flag map into the xml for the file
@ -508,7 +519,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
fout << "\"\n"; fout << "\"\n";
fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n"; fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n"; fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
std::map<cmStdString, cmStdString>::iterator mi = flagMap.find("DebugInformationFormat"); std::map<cmStdString, cmStdString>::iterator mi =
flagMap.find("DebugInformationFormat");
if(mi != flagMap.end() && mi->second != "1") if(mi != flagMap.end() && mi->second != "1")
{ {
fout << "\t\t\t\tProgramDatabaseFileName=\"" fout << "\t\t\t\tProgramDatabaseFileName=\""
@ -602,10 +614,12 @@ cmLocalVisualStudio7Generator
::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const char* configName) ::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const char* configName)
{ {
std::string configTypeUpper = cmSystemTools::UpperCase(configName); std::string configTypeUpper = cmSystemTools::UpperCase(configName);
std::string extraLinkOptionsBuildTypeDef = rootLinkerFlags + "_" + configTypeUpper; std::string extraLinkOptionsBuildTypeDef =
rootLinkerFlags + "_" + configTypeUpper;
std::string extraLinkOptionsBuildType = std::string extraLinkOptionsBuildType =
this->Makefile->GetRequiredDefinition(extraLinkOptionsBuildTypeDef.c_str()); this->Makefile->GetRequiredDefinition
(extraLinkOptionsBuildTypeDef.c_str());
return extraLinkOptionsBuildType; return extraLinkOptionsBuildType;
} }
@ -620,18 +634,24 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
std::string extraLinkOptions; std::string extraLinkOptions;
if(target.GetType() == cmTarget::EXECUTABLE) if(target.GetType() == cmTarget::EXECUTABLE)
{ {
extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS") + extraLinkOptions =
std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName); this->Makefile->GetRequiredDefinition("CMAKE_EXE_LINKER_FLAGS")
+ std::string(" ")
+ GetBuildTypeLinkerFlags("CMAKE_EXE_LINKER_FLAGS", configName);
} }
if(target.GetType() == cmTarget::SHARED_LIBRARY) if(target.GetType() == cmTarget::SHARED_LIBRARY)
{ {
extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS") + extraLinkOptions =
std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName); this->Makefile->GetRequiredDefinition("CMAKE_SHARED_LINKER_FLAGS")
+ std::string(" ")
+ GetBuildTypeLinkerFlags("CMAKE_SHARED_LINKER_FLAGS", configName);
} }
if(target.GetType() == cmTarget::MODULE_LIBRARY) if(target.GetType() == cmTarget::MODULE_LIBRARY)
{ {
extraLinkOptions = this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS") + extraLinkOptions =
std::string(" ") + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName); this->Makefile->GetRequiredDefinition("CMAKE_MODULE_LINKER_FLAGS")
+ std::string(" ")
+ GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
} }
const char* targetLinkFlags = target.GetProperty("LINK_FLAGS"); const char* targetLinkFlags = target.GetProperty("LINK_FLAGS");
@ -650,10 +670,10 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
extraLinkOptions += targetLinkFlags; extraLinkOptions += targetLinkFlags;
} }
std::map<cmStdString, cmStdString> flagMap; std::map<cmStdString, cmStdString> flagMap;
this-> this->FillFlagMapFromCommandFlags
FillFlagMapFromCommandFlags(flagMap, (flagMap, &cmLocalVisualStudio7GeneratorLinkFlagTable[0],
&cmLocalVisualStudio7GeneratorLinkFlagTable[0], extraLinkOptions);
extraLinkOptions);
switch(target.GetType()) switch(target.GetType())
{ {
case cmTarget::STATIC_LIBRARY: case cmTarget::STATIC_LIBRARY:
@ -679,11 +699,13 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
this->ComputeLinkInformation(target, configName, linkLibs, linkDirs); this->ComputeLinkInformation(target, configName, linkLibs, linkDirs);
// Get the language to use for linking. // Get the language to use for linking.
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); const char* linkLanguage =
target.GetLinkerLanguage(this->GetGlobalGenerator());
if(!linkLanguage) if(!linkLanguage)
{ {
cmSystemTools::Error("CMake can not determine linker language for target:", cmSystemTools::Error
target.GetName()); ("CMake can not determine linker language for target:",
target.GetName());
return; return;
} }
@ -746,9 +768,11 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
temp = this->LibraryOutputPath; temp = this->LibraryOutputPath;
temp += configName; temp += configName;
temp += "/"; temp += "/";
temp += cmSystemTools::GetFilenameWithoutLastExtension(targetFullName.c_str()); temp +=
cmSystemTools::GetFilenameWithoutLastExtension(targetFullName.c_str());
temp += ".lib"; temp += ".lib";
fout << "\t\t\t\tImportLibrary=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n"; fout << "\t\t\t\tImportLibrary=\""
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
} }
break; break;
case cmTarget::EXECUTABLE: case cmTarget::EXECUTABLE:
@ -759,11 +783,13 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
this->ComputeLinkInformation(target, configName, linkLibs, linkDirs); this->ComputeLinkInformation(target, configName, linkLibs, linkDirs);
// Get the language to use for linking. // Get the language to use for linking.
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); const char* linkLanguage =
target.GetLinkerLanguage(this->GetGlobalGenerator());
if(!linkLanguage) if(!linkLanguage)
{ {
cmSystemTools::Error("CMake can not determine linker language for target:", cmSystemTools::Error
target.GetName()); ("CMake can not determine linker language for target:",
target.GetName());
return; return;
} }
@ -793,7 +819,8 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
temp += configName; temp += configName;
temp += "/"; temp += "/";
temp += targetFullName; temp += targetFullName;
fout << "\t\t\t\tOutputFile=\"" << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n"; fout << "\t\t\t\tOutputFile=\""
<< this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"\n";
for(std::map<cmStdString, cmStdString>::iterator i = flagMap.begin(); for(std::map<cmStdString, cmStdString>::iterator i = flagMap.begin();
i != flagMap.end(); ++i) i != flagMap.end(); ++i)
{ {
@ -834,8 +861,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
} }
} }
void cmLocalVisualStudio7Generator::OutputModuleDefinitionFile(std::ostream& fout, void cmLocalVisualStudio7Generator
cmTarget &target) ::OutputModuleDefinitionFile(std::ostream& fout,
cmTarget &target)
{ {
std::vector<cmSourceFile*> const& classes = target.GetSourceFiles(); std::vector<cmSourceFile*> const& classes = target.GetSourceFiles();
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin(); for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
@ -998,8 +1026,10 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
this->WriteVCProjFooter(fout); this->WriteVCProjFooter(fout);
} }
void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget target, void cmLocalVisualStudio7Generator
std::ostream &fout, const char *libName, std::vector<std::string> *configs) ::WriteGroup(const cmSourceGroup *sg, cmTarget target,
std::ostream &fout, const char *libName,
std::vector<std::string> *configs)
{ {
const std::vector<const cmSourceFile *> &sourceFiles = const std::vector<const cmSourceFile *> &sourceFiles =
sg->GetSourceFiles(); sg->GetSourceFiles();
@ -1044,9 +1074,11 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
compileFlags += " "; compileFlags += " ";
compileFlags += cflags; compileFlags += cflags;
} }
const char* lang = const char* lang = this->GlobalGenerator->GetLanguageFromExtension
this->GlobalGenerator->GetLanguageFromExtension((*sf)->GetSourceExtension().c_str()); ((*sf)->GetSourceExtension().c_str());
const char* linkLanguage = target.GetLinkerLanguage(this->GetGlobalGenerator()); const char* linkLanguage = target.GetLinkerLanguage
(this->GetGlobalGenerator());
// if the source file does not match the linker language // if the source file does not match the linker language
// then force c or c++ // then force c or c++
if(linkLanguage && lang && strcmp(lang, linkLanguage) != 0) if(linkLanguage && lang && strcmp(lang, linkLanguage) != 0)
@ -1090,15 +1122,17 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
if (command) if (command)
{ {
// Construct the entire set of commands in one string. // Construct the entire set of commands in one string.
std::string script = this->ConstructScript(command->GetCommandLines(), std::string script =
command->GetWorkingDirectory()); this->ConstructScript(command->GetCommandLines(),
command->GetWorkingDirectory());
std::string comment = this->ConstructComment(*command); std::string comment = this->ConstructComment(*command);
const char* flags = compileFlags.size() ? compileFlags.c_str(): 0; const char* flags = compileFlags.size() ? compileFlags.c_str(): 0;
this->WriteCustomRule(fout, source.c_str(), script.c_str(), this->WriteCustomRule(fout, source.c_str(), script.c_str(),
comment.c_str(), command->GetDepends(), comment.c_str(), command->GetDepends(),
command->GetOutputs(), flags); command->GetOutputs(), flags);
} }
else if(compileFlags.size() || additionalDeps.length() || objectName.size()) else if(compileFlags.size() || additionalDeps.length()
|| objectName.size())
{ {
const char* aCompilerTool = "VCCLCompilerTool"; const char* aCompilerTool = "VCCLCompilerTool";
std::string ext = (*sf)->GetSourceExtension(); std::string ext = (*sf)->GetSourceExtension();
@ -1119,7 +1153,8 @@ void cmLocalVisualStudio7Generator::WriteGroup(const cmSourceGroup *sg, cmTarget
i != configs->end(); ++i) i != configs->end(); ++i)
{ {
fout << "\t\t\t\t<FileConfiguration\n" fout << "\t\t\t\t<FileConfiguration\n"
<< "\t\t\t\t\tName=\"" << *i << "|" << this->PlatformName << "\">\n" << "\t\t\t\t\tName=\"" << *i
<< "|" << this->PlatformName << "\">\n"
<< "\t\t\t\t\t<Tool\n" << "\t\t\t\t\t<Tool\n"
<< "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n"; << "\t\t\t\t\tName=\"" << aCompilerTool << "\"\n";
if(compileFlags.size()) if(compileFlags.size())
@ -1171,7 +1206,9 @@ WriteCustomRule(std::ostream& fout,
// Write the rule for each configuration. // Write the rule for each configuration.
std::vector<std::string>::iterator i; std::vector<std::string>::iterator i;
std::vector<std::string> *configs = std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator)->GetConfigurations(); static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
for(i = configs->begin(); i != configs->end(); ++i) for(i = configs->begin(); i != configs->end(); ++i)
{ {
fout << "\t\t\t\t<FileConfiguration\n"; fout << "\t\t\t\t<FileConfiguration\n";
@ -1185,8 +1222,10 @@ WriteCustomRule(std::ostream& fout,
} }
fout << "\t\t\t\t\t<Tool\n" fout << "\t\t\t\t\t<Tool\n"
<< "\t\t\t\t\tName=\"VCCustomBuildTool\"\n" << "\t\t\t\t\tName=\"VCCustomBuildTool\"\n"
<< "\t\t\t\t\tDescription=\"" << this->EscapeForXML(comment) << "\"\n" << "\t\t\t\t\tDescription=\""
<< "\t\t\t\t\tCommandLine=\"" << this->EscapeForXML(command) << "\"\n" << this->EscapeForXML(comment) << "\"\n"
<< "\t\t\t\t\tCommandLine=\""
<< this->EscapeForXML(command) << "\"\n"
<< "\t\t\t\t\tAdditionalDependencies=\""; << "\t\t\t\t\tAdditionalDependencies=\"";
// Write out the dependencies for the rule. // Write out the dependencies for the rule.
std::string temp; std::string temp;
@ -1238,9 +1277,10 @@ void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout)
// look for custom rules on a target and collect them together // look for custom rules on a target and collect them together
void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout, void cmLocalVisualStudio7Generator
cmTarget &target, ::OutputTargetRules(std::ostream& fout,
const char * /*libName*/) cmTarget &target,
const char * /*libName*/)
{ {
if (target.GetType() > cmTarget::GLOBAL_TARGET) if (target.GetType() > cmTarget::GLOBAL_TARGET)
{ {
@ -1259,7 +1299,8 @@ void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
fout << "\nCommandLine=\""; fout << "\nCommandLine=\"";
init = true; init = true;
} }
std::string script = this->ConstructScript(cr->GetCommandLines(), cr->GetWorkingDirectory()); std::string script =
this->ConstructScript(cr->GetCommandLines(), cr->GetWorkingDirectory());
fout << this->EscapeForXML(script.c_str()).c_str(); fout << this->EscapeForXML(script.c_str()).c_str();
} }
if (init) if (init)
@ -1302,7 +1343,8 @@ void cmLocalVisualStudio7Generator::OutputTargetRules(std::ostream& fout,
fout << "\nCommandLine=\""; fout << "\nCommandLine=\"";
init = true; init = true;
} }
std::string script = this->ConstructScript(cr->GetCommandLines(), cr->GetWorkingDirectory()); std::string script =
this->ConstructScript(cr->GetCommandLines(), cr->GetWorkingDirectory());
fout << this->EscapeForXML(script.c_str()).c_str(); fout << this->EscapeForXML(script.c_str()).c_str();
} }
if (init) if (init)
@ -1381,7 +1423,8 @@ std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s)
return ret; return ret;
} }
std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPath(const char* path) std::string cmLocalVisualStudio7Generator
::ConvertToXMLOutputPath(const char* path)
{ {
std::string ret = this->ConvertToOptionallyRelativeOutputPath(path); std::string ret = this->ConvertToOptionallyRelativeOutputPath(path);
cmSystemTools::ReplaceString(ret, "&", "&amp;"); cmSystemTools::ReplaceString(ret, "&", "&amp;");
@ -1391,7 +1434,8 @@ std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPath(const char* pa
return ret; return ret;
} }
std::string cmLocalVisualStudio7Generator::ConvertToXMLOutputPathSingle(const char* path) std::string cmLocalVisualStudio7Generator
::ConvertToXMLOutputPathSingle(const char* path)
{ {
std::string ret = this->ConvertToOptionallyRelativeOutputPath(path); std::string ret = this->ConvertToOptionallyRelativeOutputPath(path);
cmSystemTools::ReplaceString(ret, "\"", ""); cmSystemTools::ReplaceString(ret, "\"", "");
@ -1426,7 +1470,8 @@ void cmLocalVisualStudio7Generator::ConfigureFinalPass()
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
std::string cmLocalVisualStudio7Generator::GetTargetDirectory(cmTarget& target) std::string cmLocalVisualStudio7Generator
::GetTargetDirectory(cmTarget& target)
{ {
std::string dir; std::string dir;
dir += target.GetName(); dir += target.GetName();

View File

@ -65,7 +65,8 @@ public:
void SetPlatformName(const char* n) { this->PlatformName = n;} void SetPlatformName(const char* n) { this->PlatformName = n;}
virtual void ConfigureFinalPass(); virtual void ConfigureFinalPass();
private: private:
void FillFlagMapFromCommandFlags(std::map<cmStdString, cmStdString>& flagMap, void FillFlagMapFromCommandFlags(std::map<cmStdString,
cmStdString>& flagMap,
cmVS7FlagTable* flagTable, cmVS7FlagTable* flagTable,
std::string& flags); std::string& flags);
std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags, std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
@ -111,7 +112,8 @@ private:
const std::vector<std::string>& outputs, const std::vector<std::string>& outputs,
const char* extraFlags); const char* extraFlags);
void WriteGroup(const cmSourceGroup *sg, cmTarget target, std::ostream &fout, void WriteGroup(const cmSourceGroup *sg,
cmTarget target, std::ostream &fout,
const char *libName, std::vector<std::string> *configs); const char *libName, std::vector<std::string> *configs);
virtual std::string GetTargetDirectory(cmTarget&); virtual std::string GetTargetDirectory(cmTarget&);