[cmake-commits] hoffman committed CMakeLists.txt 1.337 1.338
cmLocalGenerator.cxx 1.175 1.176
cmLocalUnixMakefileGenerator3.cxx 1.188 1.189 cmSystemTools.cxx
1.334 1.335 cmSystemTools.h 1.135 1.136
cmake-commits at cmake.org
cmake-commits at cmake.org
Wed Feb 21 21:24:19 EST 2007
Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv8802/Source
Modified Files:
CMakeLists.txt cmLocalGenerator.cxx
cmLocalUnixMakefileGenerator3.cxx cmSystemTools.cxx
cmSystemTools.h
Log Message:
ENH: fix parens in the path with spaces in the path
Index: cmSystemTools.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.h,v
retrieving revision 1.135
retrieving revision 1.136
diff -u -d -r1.135 -r1.136
--- cmSystemTools.h 1 Feb 2007 16:45:37 -0000 1.135
+++ cmSystemTools.h 22 Feb 2007 02:24:17 -0000 1.136
@@ -293,10 +293,12 @@
// be used when RunCommand is called from cmake, because the
// running cmake needs paths to be in its format
static std::string ConvertToRunCommandPath(const char* path);
-
+ // convert to a shell path
+ static std::string ConvertToShellPath(const char* path);
//! Check if the first string ends with the second one.
static bool StringEndsWith(const char* str1, const char* str2);
-
+ // escape for unix shells
+ static std::string EscapeForUnixShell(std::string& result);
static bool CreateSymlink(const char* origName, const char* newName);
/** compute the relative path from local to remote. local must
Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CMakeLists.txt,v
retrieving revision 1.337
retrieving revision 1.338
diff -u -d -r1.337 -r1.338
--- CMakeLists.txt 21 Feb 2007 19:58:33 -0000 1.337
+++ CMakeLists.txt 22 Feb 2007 02:24:17 -0000 1.338
@@ -1011,12 +1011,24 @@
--test-command testIOS
)
ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR)
-
+ SET(MAKE_IS_GNU )
+ IF(${CMAKE_TEST_MAKEPROGRAM} MATCHES make)
+ EXECUTE_PROCESS(COMMAND ${CMAKE_TEST_MAKEPROGRAM} --version
+ RESULT_VARIABLE res OUTPUT_VARIABLE out
+ ERROR_QUIET
+ OUTPUT_QUIET)
+ IF("${res}" EQUAL 0)
+ IF("${out}" MATCHES "GNU")
+ SET(MAKE_IS_GNU 1)
+ ENDIF("${out}" MATCHES "GNU")
+ ENDIF("${res}" EQUAL 0)
+ ENDIF(${CMAKE_TEST_MAKEPROGRAM} MATCHES make)
# only add this test on platforms that support it
# some old versions of make simply cannot handle spaces in paths
- IF ("${CMAKE_TEST_MAKEPROGRAM}" MATCHES "nmake|gmake|wmake" OR
- "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio|Xcode")
+ IF (MAKE_IS_GNU OR
+ "${CMAKE_TEST_MAKEPROGRAM}" MATCHES "nmake|gmake|wmake" OR
+ "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio|XCode")
ADD_TEST(SubDirSpaces ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/SubDirSpaces"
@@ -1030,8 +1042,9 @@
"${CMake_BINARY_DIR}/Tests/SubDirSpaces/ShouldBeHere"
"${CMake_BINARY_DIR}/Tests/SubDirSpaces/testfromsubdir.obj"
)
- ENDIF ("${CMAKE_TEST_MAKEPROGRAM}" MATCHES "nmake|gmake|wmake" OR
- "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio|Xcode")
+ ENDIF (MAKE_IS_GNU OR
+ "${CMAKE_TEST_MAKEPROGRAM}" MATCHES "nmake|gmake|wmake" OR
+ "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio|XCode")
IF (WIN32)
ADD_TEST(SubDir ${CMAKE_CTEST_COMMAND}
Index: cmSystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.cxx,v
retrieving revision 1.334
retrieving revision 1.335
diff -u -d -r1.334 -r1.335
--- cmSystemTools.cxx 1 Feb 2007 16:45:37 -0000 1.334
+++ cmSystemTools.cxx 22 Feb 2007 02:24:17 -0000 1.335
@@ -1341,6 +1341,64 @@
#endif
}
+std::string cmSystemTools::EscapeForUnixShell(std::string& result)
+{
+ // For UNIX Shell paths we need to escape () in the path
+ if(result.find_first_of("()") != result.npos)
+ {
+ std::string newResult = "";
+ char lastch = 1;
+ bool inDollarVariable = false;
+ for(const char* ch = result.c_str(); *ch != '\0'; ++ch)
+ {
+ // if it is already escaped then don't try to escape it again
+ if((*ch == ' ' || *ch == '(' || *ch == ')') && lastch != '\\')
+ {
+ if(*ch == '(' && lastch == '$')
+ {
+ inDollarVariable = true;
+ }
+ // if we are in a $(..... and we get a ) then do not escape
+ // the ) and but set inDollarVariable to false
+ else if(*ch == ')' && inDollarVariable)
+ {
+ inDollarVariable = false;
+ }
+ else
+ {
+ newResult += '\\';
+ }
+ }
+ newResult += *ch;
+ lastch = *ch;
+ }
+ return newResult;
+ }
+ return result;
+}
+
+std::string cmSystemTools::ConvertToShellPath(const char* path)
+{
+ bool useUnix = false; // assume windows
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ // if windows and force paths but not cygwin useUnix is on
+ if(s_ForceUnixPaths)
+ {
+ useUnix = true;
+ }
+#else
+ // if not win32 and maybe cygwin then unix is true
+ useUnix = true;
+#endif
+ // if unix we need to call EscapeForUnixShell as well
+ if(useUnix)
+ {
+ std::string result = cmSystemTools::ConvertToUnixOutputPath(path);
+ return cmSystemTools::EscapeForUnixShell(result);
+ }
+ return cmSystemTools::ConvertToWindowsOutputPath(path);
+}
+
std::string cmSystemTools::ConvertToRunCommandPath(const char* path)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.188
retrieving revision 1.189
diff -u -d -r1.188 -r1.189
--- cmLocalUnixMakefileGenerator3.cxx 19 Feb 2007 19:25:45 -0000 1.188
+++ cmLocalUnixMakefileGenerator3.cxx 22 Feb 2007 02:24:17 -0000 1.189
@@ -1743,7 +1743,7 @@
// Call make on the given file.
std::string cmd;
cmd += "$(MAKE) -f ";
- cmd += this->Convert(makefile,NONE,MAKEFILE);
+ cmd += this->Convert(makefile,NONE,SHELL);
cmd += " ";
// Passg down verbosity level.
@@ -1765,7 +1765,7 @@
// Add the target.
if (tgt && tgt[0] != '\0')
{
- std::string tgt2 = this->Convert(tgt,HOME_OUTPUT,MAKEFILE);
+ std::string tgt2 = this->Convert(tgt,HOME_OUTPUT,SHELL);
tgt2 = this->ConvertToMakeTarget(tgt2.c_str());
cmd += tgt2;
}
Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -d -r1.175 -r1.176
--- cmLocalGenerator.cxx 17 Feb 2007 13:46:22 -0000 1.175
+++ cmLocalGenerator.cxx 22 Feb 2007 02:24:17 -0000 1.176
@@ -1023,7 +1023,7 @@
{
if(!cmSystemTools::GetShortPath(ret.c_str(), ret))
{
- ret = this->Convert(p,START_OUTPUT,MAKEFILE,true);
+ ret = this->Convert(p,START_OUTPUT,SHELL,true);
}
}
}
@@ -2088,6 +2088,14 @@
result[0] = '/';
}
}
+ // if this is unix then we need to escape () in the shell
+#if !defined(WIN32) || defined(CYGWIN)
+ forceOn = true;
+#endif
+ if(forceOn )
+ {
+ result = cmSystemTools::EscapeForUnixShell(result);
+ }
}
return result;
}
More information about the Cmake-commits
mailing list