BUG: Alternative fix to bug #8423
The patch used to fix this bug used SystemTools::GetRealPath which works only for existing files. It broke the case of using the command get_filename_component for a non-existing file. Also, it changed long-standing behavior in a possibly incompatible way even for existing files. This reverts the original fix and instead updates the documentation to be consistent with the behavior.
This commit is contained in:
parent
0499ca66aa
commit
16fe328dfc
|
@ -91,8 +91,7 @@ bool cmGetFilenameComponentCommand
|
|||
}
|
||||
|
||||
// Collapse the path to its simplest form.
|
||||
filename = cmSystemTools::CollapseFullPath(filename.c_str());
|
||||
result = cmSystemTools::GetRealPath(filename.c_str());
|
||||
result = cmSystemTools::CollapseFullPath(filename.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
" [CACHE])\n"
|
||||
"Set VarName to be the path (PATH), file name (NAME), file "
|
||||
"extension (EXT), file name without extension (NAME_WE) of FileName, "
|
||||
"or the full absolute (ABSOLUTE) file name without symlinks. "
|
||||
"or the full path (ABSOLUTE). "
|
||||
"Note that the path is converted to Unix slashes format and has no "
|
||||
"trailing slashes. The longest file extension is always considered. "
|
||||
"If the optional CACHE argument is specified, the result variable is "
|
||||
|
|
|
@ -14,7 +14,6 @@ AddCMakeTest(VariableWatch "")
|
|||
AddCMakeTest(Include "")
|
||||
AddCMakeTest(FindBase "")
|
||||
AddCMakeTest(Toolchain "")
|
||||
AddCMakeTest(GetFilenameComponentSymlinks "")
|
||||
|
||||
SET(GetPrerequisites_PreArgs
|
||||
"-DCTEST_CONFIGURATION_TYPE:STRING=\\\${CTEST_CONFIGURATION_TYPE}"
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
if(UNIX)
|
||||
# file1 => file2 => file3 (real)
|
||||
|
||||
set(bindir ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
file(WRITE ${bindir}/file3 "test file")
|
||||
find_program(LN NAMES "ln")
|
||||
|
||||
if(LN)
|
||||
# Create symlinks using "ln -s"
|
||||
if(NOT EXISTS ${bindir}/file2)
|
||||
execute_process(COMMAND ${LN} "-s" "${bindir}/file3" "${bindir}/file2")
|
||||
endif()
|
||||
if(NOT EXISTS ${bindir}/file1)
|
||||
execute_process(COMMAND ${LN} "-s" "${bindir}/file2" "${bindir}/file1")
|
||||
endif()
|
||||
|
||||
get_filename_component(file1 ${bindir}/file1 ABSOLUTE)
|
||||
get_filename_component(file2 ${bindir}/file2 ABSOLUTE)
|
||||
get_filename_component(file3 ${bindir}/file3 ABSOLUTE)
|
||||
|
||||
if(NOT file3 STREQUAL "${bindir}/file3")
|
||||
message(FATAL_ERROR "CMake fails resolving absolute file file3")
|
||||
endif()
|
||||
|
||||
if(NOT file2 STREQUAL "${bindir}/file3")
|
||||
message(FATAL_ERROR "CMake fails resolving simple symlink")
|
||||
endif()
|
||||
|
||||
if(NOT file1 STREQUAL "${bindir}/file3")
|
||||
message(FATAL_ERROR "CMake fails resolving double symlink")
|
||||
endif()
|
||||
|
||||
# cleanup
|
||||
file(REMOVE ${bindir}/file1)
|
||||
file(REMOVE ${bindir}/file2)
|
||||
file(REMOVE ${bindir}/file3)
|
||||
if(EXISTS file1 OR EXISTS file2 OR EXISTS file3)
|
||||
message(FATAL_ERROR "removal of file1, file2, or file3 failed")
|
||||
endif()
|
||||
|
||||
endif(LN)
|
||||
endif()
|
Loading…
Reference in New Issue