[cmake-developers] Issue on CMAKE_OSX_SYSROOT

Brad King brad.king at kitware.com
Mon Oct 5 11:27:33 EDT 2015


On 10/03/2015 05:00 AM, Francesco Romano wrote:
> I don't know if this is the right mailing list

This is a good place since it concerns a new OS X release.

> I needed to set the variable `CMAKE_OSX_DEPLOYMENT_TARGET` to 10.10 and this
> was done after the first "project" call.

That should be right, though I cannot say for sure without seeing the code.
Typically we do not have the project code set this value but instead add
it to the CMake command line when building for deployment:

 -DCMAKE_OSX_DEPLOYMENT_TARGET=10.10

> elseif("${CMAKE_GENERATOR}" MATCHES Xcode
>        OR CMAKE_OSX_DEPLOYMENT_TARGET
>        OR CMAKE_OSX_ARCHITECTURES MATCHES "[^;]"
>        OR NOT EXISTS "/usr/include/sys/types.h")
> 
> Now, the question is: why the Unix Makefile should  not  need the
> variable "CMAKE_OSX_SYSROOT" but only if the deployment target is not set?
> Shouldn't be correct to set anyway the sysroot (which by the way can be
> easily found because Xcode is present on the machine)?

The Unix Makefiles generator also supports the Xcode command-line tools,
third-party compilers, etc. that all build for the host system.  If you
are explicitly building for deployment then you should specify

 -DCMAKE_OSX_SYSROOT=/path/to/10.10/SDK

The Xcode generator searches for a sysroot even when not using an
explicit deployment target because Xcode always wants one specified
and does not support the pure command-line tools.

-Brad



More information about the cmake-developers mailing list