mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-15 12:16:40 +08:00
file(REAL_PATH): Warn on non-existing paths
The command is documented to work only for cases that the referenced path exists. Fixes: #26260
This commit is contained in:

committed by
Brad King

parent
613a883470
commit
00c1161b01
@@ -1439,6 +1439,13 @@ bool HandleRealPathCommand(std::vector<std::string> const& args,
|
||||
realPath = oldPolicyPath;
|
||||
}
|
||||
|
||||
if (!cmSystemTools::FileExists(realPath)) {
|
||||
status.GetMakefile().IssueMessage(
|
||||
MessageType::AUTHOR_WARNING,
|
||||
cmStrCat("Given path:\n ", input,
|
||||
"\ndoes not refer to an existing path on disk."));
|
||||
}
|
||||
|
||||
status.GetMakefile().AddDefinition(args[2], realPath);
|
||||
|
||||
return true;
|
||||
|
2
Tests/RunCMake/file/REAL_PATH-existing.cmake
Normal file
2
Tests/RunCMake/file/REAL_PATH-existing.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
file(REAL_PATH "dir" real_path_dir)
|
||||
file(REAL_PATH "dir/empty.txt" real_path_file)
|
9
Tests/RunCMake/file/REAL_PATH-non-existing-stderr.txt
Normal file
9
Tests/RunCMake/file/REAL_PATH-non-existing-stderr.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
^CMake Warning \(dev\) at REAL_PATH-non-existing.cmake:[0-9]+ \(file\):
|
||||
Given path:
|
||||
|
||||
dir/bad-magic-file\.txt
|
||||
|
||||
does not refer to an existing path on disk.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:[0-9]+ \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.$
|
2
Tests/RunCMake/file/REAL_PATH-non-existing.cmake
Normal file
2
Tests/RunCMake/file/REAL_PATH-non-existing.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
file(REAL_PATH "dir/bad-magic-file.txt" real_path)
|
@@ -99,6 +99,8 @@ if(NOT WIN32
|
||||
endif()
|
||||
endif()
|
||||
|
||||
run_cmake(REAL_PATH-non-existing)
|
||||
run_cmake(REAL_PATH-existing)
|
||||
run_cmake(REAL_PATH-unexpected-arg)
|
||||
run_cmake(REAL_PATH-no-base-dir)
|
||||
run_cmake(REAL_PATH)
|
||||
|
Reference in New Issue
Block a user