From b894942d3e01d4af2a371c37dd3a6764ae285b25 Mon Sep 17 00:00:00 2001 From: Tyler Yankee Date: Sun, 12 Apr 2026 18:43:48 -0400 Subject: [PATCH] file(CREATE_LINK): Revise CMP0205 warning Ensure we only warn when COPY_ON_ERROR is specified. While we're at it, tweak the spelling and apply consistent policy & logic ordering in compound conditions. --- Source/cmFileCommand.cxx | 12 ++++++------ .../CMP0205-HardLink-WARN-stderr.txt | 5 ++--- .../file-CREATE_LINK/CMP0205-SymLink-WARN-stderr.txt | 3 +-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 16cd19bf8b..b504e761a7 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -3295,12 +3295,12 @@ bool HandleCreateLinkCommand(std::vector const& args, if (sourceIsDirectory) { if (cmp0205 == cmPolicies::NEW) { needToTry = false; - } else if (cmp0205 == cmPolicies::WARN) { + } else if (cmp0205 == cmPolicies::WARN && arguments.CopyOnError) { status.GetMakefile().IssueMessage( MessageType::AUTHOR_WARNING, cmStrCat("Path\n ", fileName, - "\nis directory. Hardlinks creation is not supported for " - "directories.\n", + "\nis a directory. Hard link creation is not supported " + "for directories.\n", cmPolicies::GetPolicyWarning(cmPolicies::CMP0205))); } } @@ -3320,13 +3320,13 @@ bool HandleCreateLinkCommand(std::vector const& args, } } - if (arguments.CopyOnError && cmp0205 == cmPolicies::WARN && + if (cmp0205 == cmPolicies::WARN && arguments.CopyOnError && sourceIsDirectory) { status.GetMakefile().IssueMessage( MessageType::AUTHOR_WARNING, cmStrCat("Path\n ", fileName, - "\nis directory. It will be copied recursively when NEW policy " - "behavior applies for CMP0205.\n", + "\nis a directory. It will be copied " + "recursively when CMP0205 is set to NEW.\n", cmPolicies::GetPolicyWarning(cmPolicies::CMP0205))); } diff --git a/Tests/RunCMake/file-CREATE_LINK/CMP0205-HardLink-WARN-stderr.txt b/Tests/RunCMake/file-CREATE_LINK/CMP0205-HardLink-WARN-stderr.txt index 52873f3e5e..3cd83deb30 100644 --- a/Tests/RunCMake/file-CREATE_LINK/CMP0205-HardLink-WARN-stderr.txt +++ b/Tests/RunCMake/file-CREATE_LINK/CMP0205-HardLink-WARN-stderr.txt @@ -5,7 +5,7 @@ [^ ]*[\\|/]file-CREATE_LINK[\\|/]CMP0205 - is directory. Hardlinks creation is not supported for directories. + is a directory. Hard link creation is not supported for directories. Policy CMP0205 is not set: file\(CREATE_LINK\) with COPY_ON_ERROR copies directory content\. Run "cmake --help-policy CMP0205" for policy details\. @@ -24,8 +24,7 @@ CMake Warning \(dev\) at [^ [^ ]*[\\|/]file-CREATE_LINK[\\|/]CMP0205 - is directory. It will be copied recursively when NEW policy behavior - applies for CMP0205\. + is a directory. It will be copied recursively when CMP0205 is set to NEW\. Policy CMP0205 is not set: file\(CREATE_LINK\) with COPY_ON_ERROR copies directory content\. Run "cmake --help-policy CMP0205" for policy details\. diff --git a/Tests/RunCMake/file-CREATE_LINK/CMP0205-SymLink-WARN-stderr.txt b/Tests/RunCMake/file-CREATE_LINK/CMP0205-SymLink-WARN-stderr.txt index 0399f1fd8e..baa9f8d60a 100644 --- a/Tests/RunCMake/file-CREATE_LINK/CMP0205-SymLink-WARN-stderr.txt +++ b/Tests/RunCMake/file-CREATE_LINK/CMP0205-SymLink-WARN-stderr.txt @@ -5,8 +5,7 @@ [^ ]*[\\|/]file-CREATE_LINK[\\|/]CMP0205 - is directory. It will be copied recursively when NEW policy behavior - applies for CMP0205\. + is a directory. It will be copied recursively when CMP0205 is set to NEW\. Policy CMP0205 is not set: file\(CREATE_LINK\) with COPY_ON_ERROR copies directory content\. Run "cmake --help-policy CMP0205" for policy details\.