summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2008-01-13 16:36:20 -0500
committerBrad King <brad.king@kitware.com>2008-01-13 16:36:20 -0500
commit857e2e15dd8871b67ee00a939e903916320457e4 (patch)
treedde741acf9e16d62f19d78b2be632a4562918a75 /Source
parent4e96f4d503aff294343f9c3e27e85c54aa15998f (diff)
downloadcmake-857e2e15dd8871b67ee00a939e903916320457e4.tar.gz
ENH: Improved escaping in kwsys/System. Added escape of % for NMake. Added escape of ; for the VS IDE.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.cxx1
-rw-r--r--Source/cmLocalGenerator.cxx5
-rw-r--r--Source/cmLocalGenerator.h1
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h5
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx3
-rw-r--r--Source/kwsys/System.c40
-rw-r--r--Source/kwsys/System.h.in5
7 files changed, 54 insertions, 6 deletions
diff --git a/Source/cmGlobalNMakeMakefileGenerator.cxx b/Source/cmGlobalNMakeMakefileGenerator.cxx
index 88dd81d5b6..446881bf20 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.cxx
+++ b/Source/cmGlobalNMakeMakefileGenerator.cxx
@@ -47,6 +47,7 @@ cmLocalGenerator *cmGlobalNMakeMakefileGenerator::CreateLocalGenerator()
lg->SetGlobalGenerator(this);
lg->SetIgnoreLibPrefix(true);
lg->SetPassMakeflags(true);
+ lg->SetNMake(true);
lg->SetUnixCD(false);
return lg;
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index e7d78cd237..4253848fff 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -48,6 +48,7 @@ cmLocalGenerator::cmLocalGenerator()
this->WindowsVSIDE = false;
this->WatcomWMake = false;
this->MinGWMake = false;
+ this->NMake = false;
this->MSYSShell = false;
this->IgnoreLibPrefix = false;
this->UseRelativePaths = false;
@@ -2884,6 +2885,10 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars,
{
flags |= cmsysSystem_Shell_Flag_MinGWMake;
}
+ if(this->NMake)
+ {
+ flags |= cmsysSystem_Shell_Flag_NMake;
+ }
// Compute the buffer size needed.
int size = (this->WindowsShell ?
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 587a6f2b28..12e7451622 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -341,6 +341,7 @@ protected:
bool WindowsVSIDE;
bool WatcomWMake;
bool MinGWMake;
+ bool NMake;
bool ForceUnixPath;
bool MSYSShell;
bool UseRelativePaths;
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index c6fcb99fa2..d3216439b0 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -102,6 +102,11 @@ public:
void SetMinGWMake(bool v) {this->MinGWMake = v;}
/**
+ * Set to true if the make tool being used is NMake.
+ */
+ void SetNMake(bool v) {this->NMake = v;}
+
+ /**
* Set to true if the shell being used is the MSYS shell.
* This controls if statements in the makefile and the SHELL variable.
* The default is false.
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 1c144e279a..51ebcbc177 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -76,7 +76,8 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
{
std::vector<std::string> no_depends;
cmCustomCommandLine force_command;
- force_command.push_back(";");
+ force_command.push_back("cd");
+ force_command.push_back(".");
cmCustomCommandLines force_commands;
force_commands.push_back(force_command);
const char* no_main_dependency = 0;
diff --git a/Source/kwsys/System.c b/Source/kwsys/System.c
index ec328f8025..de85c3a5d2 100644
--- a/Source/kwsys/System.c
+++ b/Source/kwsys/System.c
@@ -315,13 +315,23 @@ static int kwsysSystem_Shell__GetArgumentSize(const char* in,
{
if((flags & kwsysSystem_Shell_Flag_VSIDE) ||
((flags & kwsysSystem_Shell_Flag_Make) &&
- (flags & kwsysSystem_Shell_Flag_MinGWMake)))
+ ((flags & kwsysSystem_Shell_Flag_MinGWMake) ||
+ (flags & kwsysSystem_Shell_Flag_NMake))))
{
- /* In the VS IDE or MinGW make a percent is written %% so we
- need one extra characters. */
+ /* In the VS IDE, NMake, or MinGW make a percent is written %%
+ so we need one extra characters. */
size += 1;
}
}
+ else if(*c == ';')
+ {
+ if(flags & kwsysSystem_Shell_Flag_VSIDE)
+ {
+ /* In a VS IDE a semicolon is written ";" so we need two extra
+ characters. */
+ size += 2;
+ }
+ }
}
/* Check whether the argument needs surrounding quotes. */
@@ -471,9 +481,10 @@ static char* kwsysSystem_Shell__GetArgument(const char* in, char* out,
{
if((flags & kwsysSystem_Shell_Flag_VSIDE) ||
((flags & kwsysSystem_Shell_Flag_Make) &&
- (flags & kwsysSystem_Shell_Flag_MinGWMake)))
+ ((flags & kwsysSystem_Shell_Flag_MinGWMake) ||
+ (flags & kwsysSystem_Shell_Flag_NMake))))
{
- /* In the VS IDE or MinGW make a percent is written %%. */
+ /* In the VS IDE, NMake, or MinGW make a percent is written %%. */
*out++ = '%';
*out++ = '%';
}
@@ -483,6 +494,25 @@ static char* kwsysSystem_Shell__GetArgument(const char* in, char* out,
*out++ = '%';
}
}
+ else if(*c == ';')
+ {
+ if(flags & kwsysSystem_Shell_Flag_VSIDE)
+ {
+ /* In a VS IDE a semicolon is written ";". If this is written
+ in an un-quoted argument it starts a quoted segment,
+ inserts the ; and ends the segment. If it is written in a
+ quoted argument it ends quoting, inserts the ; and restarts
+ quoting. Either way the ; is isolated. */
+ *out++ = '"';
+ *out++ = ';';
+ *out++ = '"';
+ }
+ else
+ {
+ /* Otherwise a semicolon is written just ;. */
+ *out++ = ';';
+ }
+ }
else
{
/* Store this character. */
diff --git a/Source/kwsys/System.h.in b/Source/kwsys/System.h.in
index b190262116..e76c499e48 100644
--- a/Source/kwsys/System.h.in
+++ b/Source/kwsys/System.h.in
@@ -34,6 +34,7 @@
#define kwsysSystem_Shell_Flag_EchoWindows kwsys_ns(System_Shell_Flag_EchoWindows)
#define kwsysSystem_Shell_Flag_WatcomWMake kwsys_ns(System_Shell_Flag_WatcomWMake)
#define kwsysSystem_Shell_Flag_MinGWMake kwsys_ns(System_Shell_Flag_MinGWMake)
+#define kwsysSystem_Shell_Flag_NMake kwsys_ns(System_Shell_Flag_NMake)
#define kwsysSystem_Shell_Flag_AllowMakeVariables kwsys_ns(System_Shell_Flag_AllowMakeVariables)
#if defined(__cplusplus)
@@ -90,6 +91,9 @@ enum kwsysSystem_Shell_Flag_e
/** The target shell is in a MinGW Make makefile. */
kwsysSystem_Shell_Flag_MinGWMake = (1<<4),
+ /** The target shell is in a NMake makefile. */
+ kwsysSystem_Shell_Flag_NMake = (1<<6),
+
/** Make variable reference syntax $(MAKEVAR) should not be escaped
to allow a build tool to replace it. Replacement values
containing spaces, quotes, backslashes, or other
@@ -117,6 +121,7 @@ enum kwsysSystem_Shell_Flag_e
# undef kwsysSystem_Shell_Flag_EchoWindows
# undef kwsysSystem_Shell_Flag_WatcomWMake
# undef kwsysSystem_Shell_Flag_MinGWMake
+# undef kwsysSystem_Shell_Flag_NMake
# undef kwsysSystem_Shell_Flag_AllowMakeVariables
#endif