Deriving CMAKE_OSX_SYSROOT from CMAKE_OSX_DEPLOYMENT_TARGET is not correct
The problem is that
If not set explicitly the value is initialized by the SDKROOT environment variable, if set, and otherwise computed based on the CMAKE_OSX_DEPLOYMENT_TARGET or the host platform.
The purpose of
CMAKE_OSX_DEPLOYMENT_TARGET is to set the minimum OS X version on which the product should run.
CMAKE_OSX_SYSROOT should not concern itself with
CMAKE_OSX_DEPLOYMENT_TARGET at all.
Here is an example to illustrate:
Let's say I write a project on 10.12. I want it to stay compatible for 10.12, even if 10.13/14/15... comes out and I compile it with the newer OS X/Xcode.
I therefore set the
CMAKE_OSX_DEPLOYMENT_TARGET to 10.12. What I do not want, is to manually set
CMAKE_OSX_SYSROOT everytime a new OS X version comes out. It's not neccessary.
If I don't set
CMAKE_OSX_SYSROOT manually, then in newer OS X versions the SDK might not be present for 10.12 and cmake fails! But the presence of the 10.12 SDK is not needed to use the
-mmacosx-version-min option generated by