Browse Source

Merge topic 'file-REAL_PATH'

1d12853ed3 file(REAL_PATH): Ensure same behavior as get_filename_component(REALPATH)

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Acked-by: scivision <[email protected]>
Merge-request: !8348
Brad King 2 years ago
parent
commit
926501c42a
2 changed files with 19 additions and 4 deletions
  1. 3 4
      Source/cmFileCommand.cxx
  2. 16 0
      Tests/RunCMake/file/REAL_PATH.cmake

+ 3 - 4
Source/cmFileCommand.cxx

@@ -30,7 +30,6 @@
 
 #include "cmArgumentParser.h"
 #include "cmArgumentParserTypes.h"
-#include "cmCMakePath.h"
 #include "cmCryptoHash.h"
 #include "cmELF.h"
 #include "cmExecutionStatus.h"
@@ -1278,9 +1277,9 @@ bool HandleRealPathCommand(std::vector<std::string> const& args,
     }
   }
 
-  cmCMakePath path(input, cmCMakePath::auto_format);
-  path = path.Absolute(*arguments.BaseDirectory).Normal();
-  auto realPath = cmSystemTools::GetRealPath(path.GenericString());
+  auto realPath =
+    cmSystemTools::CollapseFullPath(input, *arguments.BaseDirectory);
+  realPath = cmSystemTools::GetRealPath(realPath);
 
   status.GetMakefile().AddDefinition(args[2], realPath);
 

+ 16 - 0
Tests/RunCMake/file/REAL_PATH.cmake

@@ -34,3 +34,19 @@ file(REAL_PATH "~/test.txt" real_path EXPAND_TILDE)
 if (NOT real_path STREQUAL "${HOME_DIR}/test.txt")
   message(SEND_ERROR "real path is \"${real_path}\", should be \"${HOME_DIR}/test.txt\"")
 endif()
+
+if (WIN32)
+  cmake_policy(SET CMP0139 NEW)
+
+  set(in "${CMAKE_CURRENT_BINARY_DIR}/AbC.TxT")
+
+  file(REMOVE "${in}")
+  file(TOUCH "${in}")
+
+  string(TOLOWER "${in}" low)
+  file(REAL_PATH "${low}" out)
+
+  if(NOT "${out}" PATH_EQUAL "${in}")
+    message(SEND_ERROR "real path is \"${out}\", should be \"${in}\"")
+  endif()
+endif()