From fb3c5bfdbe87786169dfe6d3ddaa86f4f6a5676f Mon Sep 17 00:00:00 2001
From: Ben Boeckel <ben.boeckel@kitware.com>
Date: Tue, 21 Nov 2017 11:35:41 -0500
Subject: cmTargetPropertyComputer: whitelist custom properties

CMake's properties will never begin with an underscore or a lowercase
letter, so allow them to be set by projects.
---
 Help/release/dev/whitelist-more-interface-properties.rst |  7 +++++++
 Source/cmTargetPropertyComputer.cxx                      |  7 +++++++
 Tests/RunCMake/interface_library/whitelist.cmake         | 10 ++++++++++
 3 files changed, 24 insertions(+)
 create mode 100644 Help/release/dev/whitelist-more-interface-properties.rst

diff --git a/Help/release/dev/whitelist-more-interface-properties.rst b/Help/release/dev/whitelist-more-interface-properties.rst
new file mode 100644
index 0000000..793361c
--- /dev/null
+++ b/Help/release/dev/whitelist-more-interface-properties.rst
@@ -0,0 +1,7 @@
+whitelist-more-interface-properties
+-----------------------------------
+
+* ``INTERFACE`` libraries may now have custom properties set on them if they
+  start with either an underscore (``_``) or a lowercase ASCII character. The
+  original intention was to only allow properties which made sense for
+  ``INTERFACE`` libraries, but it also blocked usage of custom properties.
diff --git a/Source/cmTargetPropertyComputer.cxx b/Source/cmTargetPropertyComputer.cxx
index ed9026e..06ce0b1 100644
--- a/Source/cmTargetPropertyComputer.cxx
+++ b/Source/cmTargetPropertyComputer.cxx
@@ -3,6 +3,7 @@
 
 #include "cmTargetPropertyComputer.h"
 
+#include <cctype>
 #include <sstream>
 #include <unordered_set>
 
@@ -49,6 +50,12 @@ bool cmTargetPropertyComputer::WhiteListedInterfaceProperty(
   if (cmHasLiteralPrefix(prop, "INTERFACE_")) {
     return true;
   }
+  if (cmHasLiteralPrefix(prop, "_")) {
+    return true;
+  }
+  if (std::islower(prop[0])) {
+    return true;
+  }
   static std::unordered_set<std::string> builtIns;
   if (builtIns.empty()) {
     builtIns.insert("COMPATIBLE_INTERFACE_BOOL");
diff --git a/Tests/RunCMake/interface_library/whitelist.cmake b/Tests/RunCMake/interface_library/whitelist.cmake
index 98ef05c..bf64f01 100644
--- a/Tests/RunCMake/interface_library/whitelist.cmake
+++ b/Tests/RunCMake/interface_library/whitelist.cmake
@@ -4,3 +4,13 @@ add_library(iface INTERFACE)
 set_property(TARGET iface PROPERTY OUTPUT_NAME output)
 set_property(TARGET iface APPEND PROPERTY OUTPUT_NAME append)
 get_target_property(outname iface OUTPUT_NAME)
+
+# Properties starting with `_` are allowed.
+set_property(TARGET iface PROPERTY "_custom_property" output)
+set_property(TARGET iface APPEND PROPERTY "_custom_property" append)
+get_target_property(outname iface "_custom_property")
+
+# Properties starting with a lowercase letter are allowed.
+set_property(TARGET iface PROPERTY "custom_property" output)
+set_property(TARGET iface APPEND PROPERTY "custom_property" append)
+get_target_property(outname iface "custom_property")
-- 
cgit v0.12