Fix get_filename_component(... REALPATH) work dir

The commit "Fix get_filename_component ABSOLUTE mode" broke REALPATH
treatment of relative paths because it stopped storing the absolute path
in local variable 'filename'.  This commit fixes the call to GetRealPath
to use the proper local variable and adds a test.
This commit is contained in:
Brad King 2009-11-18 10:56:40 -05:00
parent 77fddc1f65
commit 5fbefd66dc
2 changed files with 16 additions and 1 deletions

View File

@ -101,7 +101,7 @@ bool cmGetFilenameComponentCommand
if(args[2] == "REALPATH") if(args[2] == "REALPATH")
{ {
// Resolve symlinks if possible // Resolve symlinks if possible
result = cmSystemTools::GetRealPath(filename.c_str()); result = cmSystemTools::GetRealPath(result.c_str());
} }
} }
else else

View File

@ -12,6 +12,21 @@ if(NOT nonexistent2 STREQUAL "${bindir}/THIS_IS_A_NONEXISTENT_FILE")
message(FATAL_ERROR "ABSOLUTE is not preserving nonexistent files") message(FATAL_ERROR "ABSOLUTE is not preserving nonexistent files")
endif() endif()
#
# Test treatment of relative paths
#
foreach(c REALPATH ABSOLUTE)
get_filename_component(dir "subdir/THIS_IS_A_NONEXISTENT_FILE" ${c})
if(NOT "${dir}" STREQUAL "${bindir}/subdir/THIS_IS_A_NONEXISTENT_FILE")
message(FATAL_ERROR
"${c} does not handle relative paths. Expected:\n"
" ${bindir}/subdir/THIS_IS_A_NONEXISTENT_FILE\n"
"but got:\n"
" ${nonexistent1}\n"
)
endif()
endforeach()
# #
# Test symbolic link resolution # Test symbolic link resolution
# #