summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalVisualStudioGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmLocalVisualStudioGenerator.cxx')
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx99
1 files changed, 89 insertions, 10 deletions
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index b4ab9e2..5a6df53 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -23,6 +23,8 @@
//----------------------------------------------------------------------------
cmLocalVisualStudioGenerator::cmLocalVisualStudioGenerator()
{
+ this->WindowsShell = true;
+ this->WindowsVSIDE = true;
}
//----------------------------------------------------------------------------
@@ -31,13 +33,32 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator()
}
//----------------------------------------------------------------------------
+bool cmLocalVisualStudioGenerator::SourceFileCompiles(const cmSourceFile* sf)
+{
+ // Identify the language of the source file.
+ if(const char* lang = this->GetSourceFileLanguage(*sf))
+ {
+ // Check whether this source will actually be compiled.
+ return (!sf->GetCustomCommand() &&
+ !sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
+ !sf->GetPropertyAsBool("EXTERNAL_OBJECT"));
+ }
+ else
+ {
+ // Unknown source file language. Assume it will not be compiled.
+ return false;
+ }
+}
+
+//----------------------------------------------------------------------------
void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
(std::vector<cmSourceGroup> const& sourceGroups)
{
// Clear the current set of requirements.
this->NeedObjectName.clear();
- // Count the number of object files with each name.
+ // Count the number of object files with each name. Note that
+ // windows file names are not case sensitive.
std::map<cmStdString, int> objectNameCounts;
for(unsigned int i = 0; i < sourceGroups.size(); ++i)
{
@@ -46,14 +67,13 @@ void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
for(std::vector<const cmSourceFile*>::const_iterator s = srcs.begin();
s != srcs.end(); ++s)
{
- const cmSourceFile& sf = *(*s);
- if(!sf.GetCustomCommand() &&
- !sf.GetPropertyAsBool("HEADER_FILE_ONLY") &&
- !sf.GetPropertyAsBool("EXTERNAL_OBJECT"))
+ const cmSourceFile* sf = *s;
+ if(this->SourceFileCompiles(sf))
{
std::string objectName =
+ cmSystemTools::LowerCase(
cmSystemTools::GetFilenameWithoutLastExtension(
- sf.GetFullPath().c_str());
+ sf->GetFullPath().c_str()));
objectName += ".obj";
objectNameCounts[objectName] += 1;
}
@@ -70,13 +90,12 @@ void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
s != srcs.end(); ++s)
{
const cmSourceFile* sf = *s;
- if(!sf->GetCustomCommand() &&
- !sf->GetPropertyAsBool("HEADER_FILE_ONLY") &&
- !sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
+ if(this->SourceFileCompiles(sf))
{
std::string objectName =
+ cmSystemTools::LowerCase(
cmSystemTools::GetFilenameWithoutLastExtension(
- sf->GetFullPath().c_str());
+ sf->GetFullPath().c_str()));
objectName += ".obj";
if(objectNameCounts[objectName] > 1)
{
@@ -86,3 +105,63 @@ void cmLocalVisualStudioGenerator::ComputeObjectNameRequirements
}
}
}
+
+//----------------------------------------------------------------------------
+std::string
+cmLocalVisualStudioGenerator
+::ConstructScript(const cmCustomCommandLines& commandLines,
+ const char* workingDirectory,
+ bool escapeOldStyle,
+ bool escapeAllowMakeVars,
+ const char* newline)
+{
+ // Store the script in a string.
+ std::string script;
+ if(workingDirectory)
+ {
+ script += "cd ";
+ script += this->Convert(workingDirectory, START_OUTPUT, SHELL);
+ script += newline;
+ }
+ // for visual studio IDE add extra stuff to the PATH
+ // if CMAKE_MSVCIDE_RUN_PATH is set.
+ if(this->Makefile->GetDefinition("MSVC_IDE"))
+ {
+ const char* extraPath =
+ this->Makefile->GetDefinition("CMAKE_MSVCIDE_RUN_PATH");
+ if(extraPath)
+ {
+ script += "set PATH=";
+ script += extraPath;
+ script += ";%PATH%";
+ script += newline;
+ }
+ }
+ // Write each command on a single line.
+ for(cmCustomCommandLines::const_iterator cl = commandLines.begin();
+ cl != commandLines.end(); ++cl)
+ {
+ // Start with the command name.
+ const cmCustomCommandLine& commandLine = *cl;
+ script += this->Convert(commandLine[0].c_str(),START_OUTPUT,SHELL);
+
+ // Add the arguments.
+ for(unsigned int j=1;j < commandLine.size(); ++j)
+ {
+ script += " ";
+ if(escapeOldStyle)
+ {
+ script += this->EscapeForShellOldStyle(commandLine[j].c_str());
+ }
+ else
+ {
+ script += this->EscapeForShell(commandLine[j].c_str(),
+ escapeAllowMakeVars);
+ }
+ }
+
+ // End the line.
+ script += newline;
+ }
+ return script;
+}