diff --git a/SystemTools.cxx b/SystemTools.cxx
index 2de0ba21dc58fe8643dcecb82d8030538c64c88c..f9c2b354ee4e13f6caefb18b17dd5a7136f24fb5 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -2044,7 +2044,11 @@ kwsys_stl::string SystemTools
 bool SystemTools::FileIsDirectory(const char* name)
 {  
   struct stat fs;
+#if _WIN32
   if(stat(name, &fs) == 0)
+#else
+  if(lstat(name, &fs) == 0)
+#endif
     {
 #if _WIN32
     return ((fs.st_mode & _S_IFDIR) != 0);