[CMake] Strange behavior with OSX_DEPLOYMENT_TARGET

Zaak Beekman zbeekman at gmail.com
Thu Apr 17 18:41:16 EDT 2014


I'm not sure if this is a bug, but in my top level CMakeLists.txt file I
try to do something like this:

cmake_minimum_required ( VERSION 2.8.11 FATAL_ERROR )
include ( checkOutOfSource.cmake )
include ( configureBuilds.cmake )
include ( configurePlatform.cmake )
enable_language ( C )
enable_language ( Fortran )

project ( ...
...


Then in configurePlatform.cmake I have the following code:

if (APPLE)
    set ( CMAKE_OSX_DEPLOYMENT_TARGET "10.6"
      CACHE STRING "Oldest OS X version to compile and link for." )
    set_property ( CACHE CMAKE_OSX_DEPLOYMENT_TARGET PROPERTY STRINGS
      "10.6" "10.7" "10.8" "10.9" )
...
endif (APPLE)

I'm using the Makefile generator, not Xcode, etc.

The odd thing is that if I move the `include ( configurePlatform.cmake )`
line after the calls to `enable_language` then CMAKE_OSX_DEPLOYMENT_TARGET
*AND* CMAKE_OSX_SYSROOT become undefined even though I don't explicitly set
or unset OSX_SYSROOT anywhere in my project. If I then set
OSX_DEPLOYMENT_TARGET to a value, say 10.6, then the configure and generate
steps fail with an error about how DEPLOYMENT_TARGET is set but not SYSROOT
and it can't find the proper SDK.

I thought this might be related to this bug report:
http://cmake.3232098.n2.nabble.com/OSX-deployment-target-confusion-for-2-8-10-td7582284.html
so
I upgraded to the latest CMake (2.8.12) to see if it's fixed. The unset
value of SYSROOT persists if DEPLOYMENT_TARGET is set after
enable_language, but gets set by CMake if I set before these calls.
Furthermore, a new warning is now issued:

CMAKE_OSX_DEPLOYMENT_TARGET is '10.6' but the matching SDK does not exist

However, according to the Xcode documentation this is a common, desired
situation: DEPLOYMENT_TARGET specifies the oldest compatible OS X the code
will work for, and the Apple developer docs urge developers to use the
latest SDK with weak  linking etc.

Does anyone have any insight as to what is going on here?

Izaak Beekman
===================================
(301)244-9367
Princeton University Doctoral Candidate
Mechanical and Aerospace Engineering
ibeekman at princeton.edu

UMD-CP Visiting Graduate Student
Aerospace Engineering
ibeekman at umiacs.umd.edu
ibeekman at umd.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140417/87ee1646/attachment.html>


More information about the CMake mailing list