summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kuemmel <syntheticpp@gmx.net>2012-02-18 07:07:11 (GMT)
committerPeter Kuemmel <syntheticpp@gmx.net>2012-02-18 07:15:23 (GMT)
commit7fb2bb3e8b0dc7bc718aadc4ab9a74cb7fdb656e (patch)
treed96a23ef8d6a46a7e291a596875d5d9452a78ab5
parent5d19e8aa6aac75fb08897aece8aa5545360aeeb2 (diff)
downloadCMake-7fb2bb3e8b0dc7bc718aadc4ab9a74cb7fdb656e.zip
CMake-7fb2bb3e8b0dc7bc718aadc4ab9a74cb7fdb656e.tar.gz
CMake-7fb2bb3e8b0dc7bc718aadc4ab9a74cb7fdb656e.tar.bz2
Ninja: win fixes: escape back slash/colon, use cd. as cmd.exe nop
-rw-r--r--Source/CMakeLists.txt9
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx11
-rw-r--r--Source/cmLocalNinjaGenerator.cxx4
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx4
4 files changed, 21 insertions, 7 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 7ddabbd..7cc56d7 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -353,9 +353,8 @@ IF (WIN32)
ENDIF(NOT UNIX)
ENDIF (WIN32)
-# Ninja only works on UNIX.
-IF(UNIX)
- SET(SRCS ${SRCS}
+
+SET(SRCS ${SRCS}
cmGlobalNinjaGenerator.cxx
cmGlobalNinjaGenerator.h
cmNinjaTypes.h
@@ -368,8 +367,8 @@ IF(UNIX)
cmNinjaUtilityTargetGenerator.cxx
cmNinjaUtilityTargetGenerator.h
)
- ADD_DEFINITIONS(-DCMAKE_USE_NINJA)
-ENDIF(UNIX)
+ADD_DEFINITIONS(-DCMAKE_USE_NINJA)
+
# create a library used by the command line and the GUI
ADD_LIBRARY(CMakeLib ${SRCS})
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 7ff33ba..879a973 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -59,6 +59,7 @@ static bool IsIdentChar(char c)
(c == '_') || (c == '$') || (c == '\\');
}
+
std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string &ident,
std::ostream &vars) {
if (std::find_if(ident.begin(), ident.end(),
@@ -69,14 +70,19 @@ std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string &ident,
vars << names.str() << " = " << ident << "\n";
return "$" + names.str();
} else {
- return ident;
+ return EncodeLiteral(ident);
}
}
+
std::string cmGlobalNinjaGenerator::EncodeLiteral(const std::string &lit)
{
std::string result = lit;
cmSystemTools::ReplaceString(result, "$", "$$");
+ cmSystemTools::ReplaceString(result, ":", "$:");
+#ifdef _WIN32
+ cmSystemTools::ReplaceString(result, "/", "\\");
+#endif
return result;
}
@@ -200,7 +206,8 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
this->AddCustomCommandRule();
cmNinjaVars vars;
- vars["COMMAND"] = command;
+
+ vars["COMMAND"] = EncodeLiteral(command);
vars["DESC"] = EncodeLiteral(description);
cmGlobalNinjaGenerator::WriteBuild(*this->BuildFileStream,
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index a4e66e4..cf0e36a 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -294,7 +294,11 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(
// This happens when building a POST_BUILD value for link targets that
// don't use POST_BUILD.
if (cmdLines.empty())
+#ifdef _WIN32
+ return "cd.";
+#else
return ":";
+#endif
// TODO: This will work only on Unix platforms. I don't
// want to use a link.txt file because I will lose the benefit of the
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 4dd6a9b..7cce45b 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -172,6 +172,10 @@ cmNinjaNormalTargetGenerator
i != linkCmds.end();
++i)
{
+#ifdef _WIN32
+ // HACK: no TARGET_IMPLIB here???
+ cmSystemTools::ReplaceString(*i, "/implib:", "");
+#endif
this->GetLocalGenerator()->ExpandRuleVariables(*i, vars);
}
linkCmds.insert(linkCmds.begin(), "$PRE_LINK");