I think that all variables can be used with
set(). With this said, this is not documented because there is no such limitation per se (there are no read-only variables).
For every variable you must understand how to use it correctly:
set( CMAKE_CURRENT_BINARY_DIR "hello world" )
While this is a valid instruction their application is completely nonsense. The documentation explains exactly how this variable is being set, what information it contains and for which scope it applies. This doesn’t mean above instruction is forbidden.
For all variables, generally speaking they must be defined in their scope before being used. This includes build-in commands like
enable_language, as well, which is why
- Language variables like
*_INIT must be defined before the language is enabled
- Variables like
CPACK_ must be defined before
cpack is called
The build-in commands make this process as convenient as possible. They automatically set the correct variables for the user. You should generally always use the build-in commands as much as possible. For general usage you do not need to manipulate any of these variables. For anything that is not supported otherwise you’ll have to rely on the documentation.
There are some books or block articles that go into this topic in some more detail, I don’t think there is any complete answer anywhere, though.