Skip to content
Snippets Groups Projects
Commit fb3c5bfd authored by Ben Boeckel's avatar Ben Boeckel
Browse files

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.
parent daeadde8
No related branches found
No related tags found
No related merge requests found
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.
......@@ -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");
......
......@@ -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")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment