Setting of CMAKE_OSX_DEPLOYMENT_TARGET discards non-cache variable
The first time CMake is run in a build directory on macOS, the CMAKE_OSX_DEPLOYMENT_TARGET
cache variable will be set. It takes its default value from $ENV{MACOSX_DEPLOYMENT_TARGET}
, but it ignores and discards any existing non-cache CMAKE_OSX_DEPLOYMENT_TARGET
variable. It is more reasonable to respect the non-cache variable over an environment variable, especially since it is the project that most likely knows what deployment target should be set, not the invoking environment. A project should really be able to set CMAKE_OSX_DEPLOYMENT_TARGET
as a non-cache variable before the first project()
call and have it be honoured, but at the moment it is discarded.
This appears to be a long-standing issue (e.g. see here) and the code line has been that way at least as far back as CMake 3.0