[CMake] Correct way to set machos-min-version in Cmake 3.2.1

Gregor Jasny gjasny at googlemail.com
Wed Mar 18 13:02:09 EDT 2015


Hello,

On 18/03/15 06:08, James Turner wrote:
> I’d imagine this is a FAQ, but I’ve Googled without success. Apologies if the answer is out there.
> 
> With Cmake 3.2.1, some behaviour seems to have changed, in the handling of CMAKE_OSX_DEPLOYMENT_TARGET.
> 
> I am trying to build using the 10.9 SDK, but with macosx-min-version set to 10.7 (I need to code-sign on 10.9 for Gatekeeper v2).
> 
> Previously I was doing:
> 
> 	set(CMAKE_OSX_DEPLOYMENT_TARGET 10.7)
> 
> And this would cause cmake to set:
> 
> 	 -mmacosx-version-min=10.7
> 
> As of 3.2.1, setting CMAKE_OSX_DEPLOYMENT_TARGET to 10.7 fail (with newest Xcode) because there is no 10.7 SDK. So I changed my CMake files to do:
> 
> 	SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7”)
> 
> This works but unfortunately CMake i.s explicitly setting the flag too, so I end up with both value in my CXXFLAGS:
> 
> 	-mmacosx-version-min=10.9
> 	-mmacosx-version-min=10.7
> 
> What is the correct way to request this now, such that the flag is only generated once? 

As far as I remember if you don't set a SDK CMake tries to use the
min-version as such. So in your case you could try:
-DCMAKE_OSX_SYSROOT=macosx -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7

If you set CMAKE_OSX_SYSROOT to macosx it will use the latest one.
Otherwise you could also specify a version like macosx10.9.

Hope that helps,
Gregor


More information about the CMake mailing list