summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-01-24 13:38:50 (GMT)
committerKitware Robot <kwrobot@kitware.com>2024-01-24 13:39:09 (GMT)
commit73b76563fb40d88ac3b6dd7ad14e1658f3910a5e (patch)
tree5cc62631b2e5b732a062b004cdd1e80b6bacc35f
parent31cdde5ce8ec30e4ad34cb53e3d92f45539ea554 (diff)
parent0cfd8fe8ad01f05ba95f51c4d6ce2f8774de3f5c (diff)
downloadCMake-73b76563fb40d88ac3b6dd7ad14e1658f3910a5e.zip
CMake-73b76563fb40d88ac3b6dd7ad14e1658f3910a5e.tar.gz
CMake-73b76563fb40d88ac3b6dd7ad14e1658f3910a5e.tar.bz2
Merge topic 'validate_read-only_target_properties'
0cfd8fe8ad cmTarget: Don't allow setting read-only properties Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !9133
-rw-r--r--Help/manual/cmake-policies.7.rst1
-rw-r--r--Help/policy/CMP0160.rst39
-rw-r--r--Source/cmPolicies.h9
-rw-r--r--Source/cmTarget.cxx194
-rw-r--r--Tests/RunCMake/CMP0160/CMP0160-NEW-result.txt1
-rw-r--r--Tests/RunCMake/CMP0160/CMP0160-NEW-stderr.txt233
-rw-r--r--Tests/RunCMake/CMP0160/CMP0160-NEW.cmake4
-rw-r--r--Tests/RunCMake/CMP0160/CMP0160-OLD-result.txt1
-rw-r--r--Tests/RunCMake/CMP0160/CMP0160-OLD-stderr.txt104
-rw-r--r--Tests/RunCMake/CMP0160/CMP0160-OLD.cmake4
-rw-r--r--Tests/RunCMake/CMP0160/CMP0160-WARN-result.txt1
-rw-r--r--Tests/RunCMake/CMP0160/CMP0160-WARN-stderr.txt297
-rw-r--r--Tests/RunCMake/CMP0160/CMP0160-WARN.cmake3
-rw-r--r--Tests/RunCMake/CMP0160/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMP0160/READONLY_PROPERTIES.cmake52
-rw-r--r--Tests/RunCMake/CMP0160/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt1
-rw-r--r--Tests/RunCMake/set_property/IMPORTED_GLOBAL-stderr.txt4
-rw-r--r--Tests/RunCMake/target_sources/FileSetReadOnlyInterface-stderr.txt2
-rw-r--r--Tests/RunCMake/target_sources/FileSetReadOnlyPrivate-stderr.txt2
21 files changed, 881 insertions, 80 deletions
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 2bb4f2f..d37c855 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -57,6 +57,7 @@ Policies Introduced by CMake 3.29
.. toctree::
:maxdepth: 1
+ CMP0160: More read-only target properties now error when trying to set them. </policy/CMP0160>
CMP0159: file(STRINGS) with REGEX updates CMAKE_MATCH_<n>. </policy/CMP0159>
CMP0158: add_test() honors CMAKE_CROSSCOMPILING_EMULATOR only when cross-compiling. </policy/CMP0158>
CMP0157: Swift compilation mode is selected by an abstraction. </policy/CMP0157>
diff --git a/Help/policy/CMP0160.rst b/Help/policy/CMP0160.rst
new file mode 100644
index 0000000..46318ab
--- /dev/null
+++ b/Help/policy/CMP0160.rst
@@ -0,0 +1,39 @@
+CMP0160
+-------
+
+.. versionadded:: 3.29
+
+More read-only target properties now error when trying to set them.
+
+The :command:`set_target_properties` and :command:`set_property` commands
+are intended to error out on all read-only properties. However, CMake 3.28 and
+below only did this for the following properties:
+
+* :prop_tgt:`HEADER_SETS`
+* :prop_tgt:`INTERFACE_HEADER_SETS`
+* :prop_tgt:`IMPORTED_GLOBAL`
+* :prop_tgt:`MANUALLY_ADDED_DEPENDENCIES`
+* :prop_tgt:`NAME`
+* :prop_tgt:`TYPE`
+
+This policy enforces the read-only nature of the following target properties:
+
+* :prop_tgt:`ALIAS_GLOBAL`
+* :prop_tgt:`BINARY_DIR`
+* :prop_tgt:`CXX_MODULE_SETS`
+* :prop_tgt:`IMPORTED`
+* :prop_tgt:`INTERFACE_CXX_MODULE_SETS`
+* :prop_tgt:`LOCATION`
+* :prop_tgt:`LOCATION_<CONFIG>`
+* :prop_tgt:`SOURCE_DIR`
+
+The ``OLD`` behavior for this policy is to only error out for the properties
+:prop_tgt:`MANUALLY_ADDED_DEPENDENCIES`, :prop_tgt:`NAME`, and :prop_tgt:`TYPE`.
+The ``NEW`` behavior for this policy is to error out on all target properties
+that are documented as read-only.
+
+.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.29
+.. |WARNS_OR_DOES_NOT_WARN| replace:: warns
+.. include:: STANDARD_ADVICE.txt
+
+.. include:: DEPRECATED.txt
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 65870dc..e23e687 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -487,7 +487,11 @@ class cmMakefile;
3, 29, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0159, \
"file(STRINGS) with REGEX updates CMAKE_MATCH_<n>.", 3, 29, 0, \
- cmPolicies::WARN)
+ cmPolicies::WARN) \
+ SELECT( \
+ POLICY, CMP0160, \
+ "More read-only target properties now error when trying to set them.", 3, \
+ 29, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
@@ -529,7 +533,8 @@ class cmMakefile;
F(CMP0154) \
F(CMP0155) \
F(CMP0156) \
- F(CMP0157)
+ F(CMP0157) \
+ F(CMP0160)
#define CM_FOR_EACH_CUSTOM_COMMAND_POLICY(F) \
F(CMP0116) \
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 4cb9a54..e6e1ac4 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -8,6 +8,7 @@
#include <map>
#include <set>
#include <sstream>
+#include <unordered_map>
#include <unordered_set>
#include <cm/memory>
@@ -802,18 +803,6 @@ bool FileSetType::WriteProperties(cmTarget* tgt, cmTargetInternals* impl,
}
return true;
}
- if (prop == this->SelfEntries.PropertyName) {
- impl->Makefile->IssueMessage(
- MessageType::FATAL_ERROR,
- cmStrCat(this->SelfEntries.PropertyName, " property is read-only\n"));
- return true;
- }
- if (prop == this->InterfaceEntries.PropertyName) {
- impl->Makefile->IssueMessage(MessageType::FATAL_ERROR,
- cmStrCat(this->InterfaceEntries.PropertyName,
- " property is read-only\n"));
- return true;
- }
return false;
}
@@ -1981,7 +1970,6 @@ MAKE_PROP(CUDA_CUBIN_COMPILATION);
MAKE_PROP(CUDA_FATBIN_COMPILATION);
MAKE_PROP(CUDA_OPTIX_COMPILATION);
MAKE_PROP(CUDA_PTX_COMPILATION);
-MAKE_PROP(EXPORT_NAME);
MAKE_PROP(IMPORTED);
MAKE_PROP(IMPORTED_GLOBAL);
MAKE_PROP(INCLUDE_DIRECTORIES);
@@ -2007,43 +1995,118 @@ MAKE_PROP(INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE);
#undef MAKE_PROP
}
-void cmTarget::SetProperty(const std::string& prop, cmValue value)
+namespace {
+
+enum class ReadOnlyCondition
{
- if (prop == propMANUALLY_ADDED_DEPENDENCIES) {
- this->impl->Makefile->IssueMessage(
- MessageType::FATAL_ERROR,
- "MANUALLY_ADDED_DEPENDENCIES property is read-only\n");
- return;
- }
- if (prop == propNAME) {
- this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR,
- "NAME property is read-only\n");
- return;
- }
- if (prop == propTYPE) {
- this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR,
- "TYPE property is read-only\n");
- return;
+ All,
+ Imported,
+ NonImported,
+};
+
+struct ReadOnlyProperty
+{
+ ReadOnlyProperty(ReadOnlyCondition cond)
+ : Condition{ cond }
+ , Policy{} {};
+ ReadOnlyProperty(ReadOnlyCondition cond, cmPolicies::PolicyID id)
+ : Condition{ cond }
+ , Policy{ id } {};
+
+ ReadOnlyCondition Condition;
+ cm::optional<cmPolicies::PolicyID> Policy;
+
+ std::string message(const std::string& prop, cmTarget* target) const
+ {
+ std::string msg;
+ if (this->Condition == ReadOnlyCondition::All) {
+ msg = " property is read-only for target(\"";
+ } else if (this->Condition == ReadOnlyCondition::Imported) {
+ msg = " property can't be set on imported targets(\"";
+ } else if (this->Condition == ReadOnlyCondition::NonImported) {
+ msg = " property can't be set on non-imported targets(\"";
+ }
+ return cmStrCat(prop, msg, target->GetName(), "\")\n");
}
- if (prop == propEXPORT_NAME && this->IsImported()) {
- std::ostringstream e;
- e << "EXPORT_NAME property can't be set on imported targets (\""
- << this->impl->Name << "\")\n";
- this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
- return;
+
+ bool isReadOnly(const std::string& prop, cmMakefile* context,
+ cmTarget* target) const
+ {
+ auto importedTarget = target->IsImported();
+ bool matchingCondition = true;
+ if ((!importedTarget && this->Condition == ReadOnlyCondition::Imported) ||
+ (importedTarget &&
+ this->Condition == ReadOnlyCondition::NonImported)) {
+ matchingCondition = false;
+ }
+ if (!matchingCondition) {
+ // Not read-only in this scenario
+ return false;
+ }
+
+ bool readOnly = true;
+ if (!this->Policy) {
+ // No policy associated, so is always read-only
+ context->IssueMessage(MessageType::FATAL_ERROR,
+ this->message(prop, target));
+ } else {
+ switch (target->GetPolicyStatus(*this->Policy)) {
+ case cmPolicies::WARN:
+ context->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0160) + "\n" +
+ this->message(prop, target));
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ readOnly = false;
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ context->IssueMessage(MessageType::FATAL_ERROR,
+ this->message(prop, target));
+ break;
+ }
+ }
+ return readOnly;
}
- if (prop == propSOURCES && this->IsImported()) {
- std::ostringstream e;
- e << "SOURCES property can't be set on imported targets (\""
- << this->impl->Name << "\")\n";
- this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
- return;
+};
+
+bool IsSetableProperty(cmMakefile* context, cmTarget* target,
+ const std::string& prop)
+{
+ using ROC = ReadOnlyCondition;
+ static std::unordered_map<std::string, ReadOnlyProperty> const readOnlyProps{
+ { "EXPORT_NAME", { ROC::Imported } },
+ { "HEADER_SETS", { ROC::All } },
+ { "IMPORTED_GLOBAL", { ROC::NonImported } },
+ { "INTERFACE_HEADER_SETS", { ROC::All } },
+ { "MANUALLY_ADDED_DEPENDENCIES", { ROC::All } },
+ { "NAME", { ROC::All } },
+ { "SOURCES", { ROC::Imported } },
+ { "TYPE", { ROC::All } },
+ { "ALIAS_GLOBAL", { ROC::All, cmPolicies::CMP0160 } },
+ { "BINARY_DIR", { ROC::All, cmPolicies::CMP0160 } },
+ { "CXX_MODULE_SETS", { ROC::All, cmPolicies::CMP0160 } },
+ { "IMPORTED", { ROC::All, cmPolicies::CMP0160 } },
+ { "INTERFACE_CXX_MODULE_SETS", { ROC::All, cmPolicies::CMP0160 } },
+ { "LOCATION", { ROC::All, cmPolicies::CMP0160 } },
+ { "LOCATION_CONFIG", { ROC::All, cmPolicies::CMP0160 } },
+ { "SOURCE_DIR", { ROC::All, cmPolicies::CMP0160 } }
+ };
+
+ auto it = readOnlyProps.find(prop);
+
+ if (it != readOnlyProps.end()) {
+ return !(it->second.isReadOnly(prop, context, target));
}
- if (prop == propIMPORTED_GLOBAL && !this->IsImported()) {
- std::ostringstream e;
- e << "IMPORTED_GLOBAL property can't be set on non-imported targets (\""
- << this->impl->Name << "\")\n";
- this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return true;
+}
+}
+
+void cmTarget::SetProperty(const std::string& prop, cmValue value)
+{
+ if (!IsSetableProperty(this->impl->Makefile, this, prop)) {
return;
}
@@ -2188,40 +2251,23 @@ void cmTarget::AppendProperty(const std::string& prop,
cm::optional<cmListFileBacktrace> const& bt,
bool asString)
{
- if (prop == "NAME") {
- this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR,
- "NAME property is read-only\n");
- return;
- }
- if (prop == "EXPORT_NAME" && this->IsImported()) {
- std::ostringstream e;
- e << "EXPORT_NAME property can't be set on imported targets (\""
- << this->impl->Name << "\")\n";
- this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
- return;
- }
- if (prop == "SOURCES" && this->IsImported()) {
- std::ostringstream e;
- e << "SOURCES property can't be set on imported targets (\""
- << this->impl->Name << "\")\n";
- this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ if (!IsSetableProperty(this->impl->Makefile, this, prop)) {
return;
}
if (prop == "IMPORTED_GLOBAL") {
- std::ostringstream e;
- e << "IMPORTED_GLOBAL property can't be appended, only set on imported "
- "targets (\""
- << this->impl->Name << "\")\n";
- this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
- return;
+ this->impl->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("IMPORTED_GLOBAL property can't be appended, only set on "
+ "imported targets (\"",
+ this->impl->Name, "\")\n"));
}
if (prop == propPRECOMPILE_HEADERS &&
this->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) {
- std::ostringstream e;
- e << "PRECOMPILE_HEADERS_REUSE_FROM property is already set on target "
- "(\""
- << this->impl->Name << "\")\n";
- this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->impl->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ "PRECOMPILE_HEADERS_REUSE_FROM property is already set on target (\"",
+ this->impl->Name, "\")\n"));
return;
}
diff --git a/Tests/RunCMake/CMP0160/CMP0160-NEW-result.txt b/Tests/RunCMake/CMP0160/CMP0160-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/CMP0160-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMP0160/CMP0160-NEW-stderr.txt b/Tests/RunCMake/CMP0160/CMP0160-NEW-stderr.txt
new file mode 100644
index 0000000..b52b633
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/CMP0160-NEW-stderr.txt
@@ -0,0 +1,233 @@
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ HEADER_SETS property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ INTERFACE_HEADER_SETS property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ MANUALLY_ADDED_DEPENDENCIES property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ NAME property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ TYPE property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ ALIAS_GLOBAL property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ BINARY_DIR property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ CXX_MODULE_SETS property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ IMPORTED property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ INTERFACE_CXX_MODULE_SETS property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ LOCATION property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ LOCATION_CONFIG property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ SOURCE_DIR property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ IMPORTED_GLOBAL property can't be set on non-imported
+ targets\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ HEADER_SETS property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ INTERFACE_HEADER_SETS property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ MANUALLY_ADDED_DEPENDENCIES property is read-only for
+ target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ NAME property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ TYPE property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ ALIAS_GLOBAL property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ BINARY_DIR property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ CXX_MODULE_SETS property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ IMPORTED property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ INTERFACE_CXX_MODULE_SETS property is read-only for
+ target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ LOCATION property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ LOCATION_CONFIG property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ SOURCE_DIR property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ EXPORT_NAME property can't be set on imported targets\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ SOURCES property can't be set on imported targets\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-NEW.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMP0160/CMP0160-NEW.cmake b/Tests/RunCMake/CMP0160/CMP0160-NEW.cmake
new file mode 100644
index 0000000..ed3a256
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/CMP0160-NEW.cmake
@@ -0,0 +1,4 @@
+
+project(ReadOnly LANGUAGES NONE)
+cmake_policy(SET CMP0160 NEW)
+include(${CMAKE_CURRENT_LIST_DIR}/READONLY_PROPERTIES.cmake)
diff --git a/Tests/RunCMake/CMP0160/CMP0160-OLD-result.txt b/Tests/RunCMake/CMP0160/CMP0160-OLD-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/CMP0160-OLD-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMP0160/CMP0160-OLD-stderr.txt b/Tests/RunCMake/CMP0160/CMP0160-OLD-stderr.txt
new file mode 100644
index 0000000..e57cd9d
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/CMP0160-OLD-stderr.txt
@@ -0,0 +1,104 @@
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ HEADER_SETS property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ INTERFACE_HEADER_SETS property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ MANUALLY_ADDED_DEPENDENCIES property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ NAME property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ TYPE property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ IMPORTED_GLOBAL property can't be set on non-imported
+ targets\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ HEADER_SETS property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ INTERFACE_HEADER_SETS property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ MANUALLY_ADDED_DEPENDENCIES property is read-only for
+ target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ NAME property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ TYPE property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ EXPORT_NAME property can't be set on imported targets\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ SOURCES property can't be set on imported targets\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-OLD.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMP0160/CMP0160-OLD.cmake b/Tests/RunCMake/CMP0160/CMP0160-OLD.cmake
new file mode 100644
index 0000000..6c6f1f8
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/CMP0160-OLD.cmake
@@ -0,0 +1,4 @@
+
+project(ReadOnly LANGUAGES NONE)
+cmake_policy(SET CMP0160 OLD)
+include(${CMAKE_CURRENT_LIST_DIR}/READONLY_PROPERTIES.cmake)
diff --git a/Tests/RunCMake/CMP0160/CMP0160-WARN-result.txt b/Tests/RunCMake/CMP0160/CMP0160-WARN-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/CMP0160-WARN-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CMP0160/CMP0160-WARN-stderr.txt b/Tests/RunCMake/CMP0160/CMP0160-WARN-stderr.txt
new file mode 100644
index 0000000..b15104e
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/CMP0160-WARN-stderr.txt
@@ -0,0 +1,297 @@
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ HEADER_SETS property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ INTERFACE_HEADER_SETS property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ MANUALLY_ADDED_DEPENDENCIES property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ NAME property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ TYPE property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ ALIAS_GLOBAL property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ BINARY_DIR property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ CXX_MODULE_SETS property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ IMPORTED property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ INTERFACE_CXX_MODULE_SETS property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ LOCATION property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ LOCATION_CONFIG property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ SOURCE_DIR property is read-only for target\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ IMPORTED_GLOBAL property can't be set on non-imported
+ targets\("ReadOnlyLib"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ HEADER_SETS property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ INTERFACE_HEADER_SETS property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ MANUALLY_ADDED_DEPENDENCIES property is read-only for
+ target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ NAME property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ TYPE property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ ALIAS_GLOBAL property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ BINARY_DIR property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ CXX_MODULE_SETS property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ IMPORTED property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ INTERFACE_CXX_MODULE_SETS property is read-only for
+ target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ LOCATION property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ LOCATION_CONFIG property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ Policy CMP0160 is not set: More read-only target properties now error when
+ trying to set them. Run "cmake --help-policy CMP0160" for policy details.
+ Use the cmake_policy command to set the policy and suppress this warning.
+
+ SOURCE_DIR property is read-only for target\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ EXPORT_NAME property can't be set on imported targets\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error at READONLY_PROPERTIES.cmake:44 \(set_target_properties\):
+ SOURCES property can't be set on imported targets\("ReadOnlyImport"\)
+
+Call Stack \(most recent call first\):
+ CMP0160-WARN.cmake:3 \(include\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMP0160/CMP0160-WARN.cmake b/Tests/RunCMake/CMP0160/CMP0160-WARN.cmake
new file mode 100644
index 0000000..e9e99bb
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/CMP0160-WARN.cmake
@@ -0,0 +1,3 @@
+
+project(ReadOnly LANGUAGES NONE)
+include(${CMAKE_CURRENT_LIST_DIR}/READONLY_PROPERTIES.cmake)
diff --git a/Tests/RunCMake/CMP0160/CMakeLists.txt b/Tests/RunCMake/CMP0160/CMakeLists.txt
new file mode 100644
index 0000000..6a9ce76
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.28)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0160/READONLY_PROPERTIES.cmake b/Tests/RunCMake/CMP0160/READONLY_PROPERTIES.cmake
new file mode 100644
index 0000000..07bbe78
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/READONLY_PROPERTIES.cmake
@@ -0,0 +1,52 @@
+
+set(read_only_properties
+ "HEADER_SETS"
+ "INTERFACE_HEADER_SETS"
+ "MANUALLY_ADDED_DEPENDENCIES"
+ "NAME"
+ "TYPE"
+ )
+set(read_only_properties_imported
+ "EXPORT_NAME"
+ "SOURCES"
+ )
+set(read_only_properties_nonimported
+ "IMPORTED_GLOBAL"
+ )
+set(read_only_properties_160
+ "ALIAS_GLOBAL"
+ "BINARY_DIR"
+ "CXX_MODULE_SETS"
+ "IMPORTED"
+ "INTERFACE_CXX_MODULE_SETS"
+ "LOCATION"
+ "LOCATION_CONFIG"
+ "SOURCE_DIR"
+ )
+
+cmake_policy(GET CMP0160 policy160)
+add_library(ReadOnlyLib )
+add_library(ReadOnlyImport IMPORTED UNKNOWN)
+
+foreach(target ReadOnlyLib ReadOnlyImport)
+ get_target_property(is_imported ${target} IMPORTED)
+ set(are_read_only ${read_only_properties})
+ if(NOT policy160 STREQUAL "OLD")
+ list(APPEND are_read_only ${read_only_properties_160})
+ endif()
+ if(is_imported)
+ list(APPEND are_read_only ${read_only_properties_imported})
+ else()
+ list(APPEND are_read_only ${read_only_properties_nonimported})
+ endif()
+
+ foreach(prop IN LISTS are_read_only)
+ set_target_properties(${target} PROPERTIES ${prop} "a_value")
+ endforeach()
+
+ if(policy160 STREQUAL "OLD")
+ foreach(prop IN LISTS read_only_properties_160)
+ set_target_properties(${target} PROPERTIES ${prop} "a_value")
+ endforeach()
+ endif()
+endforeach()
diff --git a/Tests/RunCMake/CMP0160/RunCMakeTest.cmake b/Tests/RunCMake/CMP0160/RunCMakeTest.cmake
new file mode 100644
index 0000000..60380b5
--- /dev/null
+++ b/Tests/RunCMake/CMP0160/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0160-WARN)
+run_cmake(CMP0160-OLD)
+run_cmake(CMP0160-NEW)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index ef088aa..4aad417 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -168,6 +168,7 @@ endif()
add_RunCMake_test(CMP0153)
add_RunCMake_test(CMP0156 -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
-DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION})
+add_RunCMake_test(CMP0160)
# The test for Policy 65 requires the use of the
# CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
index 11d59b7..6b462d0 100644
--- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
+++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
@@ -41,6 +41,7 @@
\* CMP0155
\* CMP0156
\* CMP0157
+ \* CMP0160
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/set_property/IMPORTED_GLOBAL-stderr.txt b/Tests/RunCMake/set_property/IMPORTED_GLOBAL-stderr.txt
index e45fc64..8f575b5 100644
--- a/Tests/RunCMake/set_property/IMPORTED_GLOBAL-stderr.txt
+++ b/Tests/RunCMake/set_property/IMPORTED_GLOBAL-stderr.txt
@@ -23,8 +23,8 @@ Call Stack \(most recent call first\):
CMake Error at IMPORTED_GLOBAL.cmake:32 \(set_property\):
- IMPORTED_GLOBAL property can't be set on non-imported targets
- \(\"NonImportedTarget\"\)
+ IMPORTED_GLOBAL property can't be set on non-imported
+ targets\(\"NonImportedTarget\"\)
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_sources/FileSetReadOnlyInterface-stderr.txt b/Tests/RunCMake/target_sources/FileSetReadOnlyInterface-stderr.txt
index 2307d13..50901fe 100644
--- a/Tests/RunCMake/target_sources/FileSetReadOnlyInterface-stderr.txt
+++ b/Tests/RunCMake/target_sources/FileSetReadOnlyInterface-stderr.txt
@@ -1,5 +1,5 @@
^CMake Error at FileSetReadOnlyInterface\.cmake:[0-9]+ \(set_property\):
- INTERFACE_HEADER_SETS property is read-only
+ INTERFACE_HEADER_SETS property is read-only for target\("lib1"\)
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate-stderr.txt b/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate-stderr.txt
index 5f955da..4767894 100644
--- a/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate-stderr.txt
+++ b/Tests/RunCMake/target_sources/FileSetReadOnlyPrivate-stderr.txt
@@ -1,5 +1,5 @@
^CMake Error at FileSetReadOnlyPrivate\.cmake:[0-9]+ \(set_property\):
- HEADER_SETS property is read-only
+ HEADER_SETS property is read-only for target\("lib1"\)
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)$