diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2570e5be312b2b3da57602d79804d0b28140cda1..c0154c8c202480f38fda2d6c2ef0b9b8b5cf4cb3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -496,6 +496,16 @@ IF(KWSYS_USE_SystemTools)
     KWSYS_CXX_STAT_HAS_ST_MTIM=${KWSYS_CXX_STAT_HAS_ST_MTIM}
     KWSYS_CXX_STAT_HAS_ST_MTIMESPEC=${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC}
     )
+  IF(NOT WIN32)
+    IF(KWSYS_STANDALONE)
+      OPTION(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES "If true, Windows paths will be supported on Unix as well" ON)
+    ENDIF()
+    IF(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES)
+      SET_PROPERTY(SOURCE SystemTools.cxx testSystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
+        KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES
+        )
+    ENDIF()
+  ENDIF()
 
   # Disable getpwnam for static linux builds since it depends on shared glibc
   GET_PROPERTY(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
diff --git a/SystemTools.cxx b/SystemTools.cxx
index 91745d975443b4cffee47cb70c264c28fa6b0768..1768eabfbc02351d1f757b21d9a81d161d7e1c07 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -3719,7 +3719,12 @@ std::string SystemTools::GetFilenamePath(const std::string& filename)
  */
 std::string SystemTools::GetFilenameName(const std::string& filename)
 {
-  std::string::size_type slash_pos = filename.find_last_of("/\\");
+#if defined(_WIN32) || defined(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES)
+  const char* separators = "/\\";
+#else
+  char separators = '/';
+#endif
+  std::string::size_type slash_pos = filename.find_last_of(separators);
   if (slash_pos != std::string::npos) {
     return filename.substr(slash_pos + 1);
   } else {
diff --git a/testSystemTools.cxx b/testSystemTools.cxx
index f1321e5da26b69831c1b11eec3ab2037c6d9e104..487c7f3297c0cbbba3946f3979e0d9e421868207 100644
--- a/testSystemTools.cxx
+++ b/testSystemTools.cxx
@@ -764,20 +764,26 @@ static bool CheckGetFilenameName()
   const char* windowsFilepath = "C:\\somewhere\\something";
   const char* unixFilepath = "/somewhere/something";
 
-  std::string expectedFilename = "something";
+#if defined(_WIN32) || defined(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES)
+  std::string expectedWindowsFilename = "something";
+#else
+  std::string expectedWindowsFilename = "C:\\somewhere\\something";
+#endif
+  std::string expectedUnixFilename = "something";
 
   bool res = true;
   std::string filename = kwsys::SystemTools::GetFilenameName(windowsFilepath);
-  if (filename != expectedFilename) {
+  if (filename != expectedWindowsFilename) {
     std::cerr << "GetFilenameName(" << windowsFilepath << ") yielded "
-              << filename << " instead of " << expectedFilename << std::endl;
+              << filename << " instead of " << expectedWindowsFilename
+              << std::endl;
     res = false;
   }
 
   filename = kwsys::SystemTools::GetFilenameName(unixFilepath);
-  if (filename != expectedFilename) {
+  if (filename != expectedUnixFilename) {
     std::cerr << "GetFilenameName(" << unixFilepath << ") yielded " << filename
-              << " instead of " << expectedFilename << std::endl;
+              << " instead of " << expectedUnixFilename << std::endl;
     res = false;
   }
   return res;