custom properties for target

I’m adding an external library (subdirectory). In this case, it is necessary to specify some configuration properties for this library. Now I do this by setting the values of global variables, because these properties are not in “CMAKE Properties on Targets”. This doesn’t seem like a very good solution. Can I add my custom properties to the CMakeList of the library, which will have to set targets that use this library, for example using set_target_properties? And is it possible to specify valid values for these properties so that CMAKE checks them during script execution.

You can define whatever properties you want on targets, but only CMake-defined ones will be initialized from a CMAKE_ variable value. You’re probably best off with some add_library wrapper that does the variable to property forwarding for the properties you care about.

I don’t think CMake has validation for custom properties at all.

Oh, it looks like define_property can do it actually.