Initialize CMAKE_EXPORT_COMPILE_COMMANDS from an environment variable of the same name.
The current approach requires the least amount of changes but I'm not sure if setting CMAKE_EXPORT_COMPILE_COMMANDS
to the value returned by $ENV{}
when an environment variable does not exist is the same as setting it to OFF
as is done now.
I've unset the environment variable in the same place that CMAKE_GENERATOR
is unset but I'm not sure this actually covers all the cases where we want this disabled.
Fixes: #18386 (closed)