Issue
CMake variables and properties seem to accomplish very similar things, and I have been unable to understand the difference between them.
They each have their own sections of documentation, but both can affect the build system, both "pre-exist", and both can be dynamically generated based on other CMake commands. It seems like they should have separate purposes. What are they?
Solution
I felt not entirely satisfied by the other answers, so I had to go and find my own. After some reading and consulting, I believe the roles CMake intends for variables and properties are indeed different, and in fact more or less straightforward.
Variables are arbitrarily named memory cells you use during calculations and to pass values around. They can also be assigned in the command line and exposed as GUI options, to accept inputs from outside of the script.
Properties are predefined slots that together describe all aspects of the environment, the state and the project being configured. Remember that the point of running CMake is to have the selected generator output a set of makefiles (or IDE project files). In turn, the point of the configuration stage is to evaluate and note down all the facts that the generator might want to know when it is making its decisions.
So in general, values would flow throug cmake like this:
command line/option > variable > some processing > property > generator > makefile
For example, CXX_STANDARD prop can be set via set_property(), but will also initialize from the CMAKE_CXX_STANDARD var if it was given a value.
In "modern" CMake we are encouraged to think in terms of targets and the properties they have, instead of setting values to a disorganized bunch of variables, but properties weren't there initially it seems so some aspects can still be configured using variables. For example, CMAKE_CXX_FLAGS var can be set to "-std=c++11" and will then affect the generation directly. The modern way is to set CXX_STANDARD prop instead.
Answered By - Андрей Вахрушев Answer Checked By - Marie Seifert (WPSolving Admin)