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

James Turner james.turner at kdab.com
Wed Mar 18 01:08:54 EDT 2015


Hello,

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? 

All of the above with latest Xcode and using Xcode project files.

Kind regards,
James




More information about the CMake mailing list