MantisBT - CMake
View Issue Details
0014695CMakeCMakepublic2014-01-14 04:402014-06-02 08:38
Juho Frits 
 
normalmajoralways
closedno change required 
Mac OS XOS X10.7
CMake 2.8.12.1 
 
0014695: CMake fails with XCode 4.6 and Qt 4 with CMAKE_OSX_DEPLOYMENT_TARGET
CMake fails to set up CMAKE_OSX_SYSROOT when using XCode 4.6 with command line tools installed. I have only 10.7 and 10.8 SDKs installed.

A minimal CMakeLists.txt to reproduce the issue is:

PROJECT(test)
SET(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)
FIND_PACKAGE(Qt4 COMPONENTS QtCore)


CMake outputs the following errors:

CMake Warning at /opt/local/cmake/Contents/share/cmake-2.8/Modules/Platform/Darwin.cmake:145 (message):
  CMAKE_OSX_DEPLOYMENT_TARGET is '10.5' but the matching SDK does not exist
  at:

 "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.5.sdk"

  Instead using SDK:

 "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk"

  matching the host OS X version.
Call Stack (most recent call first):
  /opt/local/cmake/Contents/share/cmake-2.8/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
  CMakeLists.txt:2 (PROJECT)

CMake Error at /opt/local/cmake/Contents/share/cmake-2.8/Modules/Platform/Darwin.cmake:213 (message):
  CMAKE_OSX_DEPLOYMENT_TARGET is '10.5' but CMAKE_OSX_SYSROOT:

   ""

  is not set to a MacOSX SDK with a recognized version. Either set
  CMAKE_OSX_SYSROOT to a valid SDK or set CMAKE_OSX_DEPLOYMENT_TARGET to
  empty.
Call Stack (most recent call first):
  /opt/local/cmake/Contents/share/cmake-2.8/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
  CMakeLists.txt:2 (PROJECT)

CMake Error: Internal CMake error, TryCompile configure of cmake failed


CMake 2.8.9 works fine. I haven't tested with CMake 2.8.10 or 2.8.11.
No tags attached.
related to 0014324closed Brad King bootstrap fails when CMAKE_OSX_DEPLOYMENT_TARGET is set and CFLAGS has -isysroot 
txt cmake-output.txt (264,823) 2014-01-16 03:54
https://public.kitware.com/Bug/file/5045/cmake-output.txt
Issue History
2014-01-14 04:40Juho FritsNew Issue
2014-01-14 09:01Brad KingRelationship addedrelated to 0014324
2014-01-14 09:05Brad KingNote Added: 0034934
2014-01-14 09:14Brad KingNote Added: 0034936
2014-01-16 03:54Juho FritsFile Added: cmake-output.txt
2014-01-16 04:29Juho FritsNote Added: 0034948
2014-01-16 09:14Brad KingNote Added: 0034950
2014-01-16 09:32Juho FritsNote Added: 0034951
2014-01-16 10:24Brad KingNote Added: 0034953
2014-01-16 10:24Brad KingStatusnew => resolved
2014-01-16 10:24Brad KingResolutionopen => no change required
2014-06-02 08:38Robert MaynardNote Added: 0036085
2014-06-02 08:38Robert MaynardStatusresolved => closed

Notes
(0034934)
Brad King   
2014-01-14 09:05   
Related post-2.8.9 changes:

OS X: Do not default to non-existent deployment target SDK
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=335a1278 [^]

OS X: Teach deployment target sanity check about SDK names
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e7e613ef [^]
(0034936)
Brad King   
2014-01-14 09:14   
I can reproduce the (post-2.8.9) warning about not having the deployment target's SDK available, but not the error message about an empty CMAKE_OSX_SYSROOT. The warning is telling you that CMake is setting the default CMAKE_OSX_SYSROOT to the SDK for the host OS X version instead of the deployment target. However, this will not override any existing cached value of CMAKE_OSX_SYSROOT, even an empty string.

You should not set

 SET(CMAKE_OSX_DEPLOYMENT_TARGET 10.5)

after the project() command because the language and platform initialization has already taken place by that point. You should set it on the command line or prior to the first project() command.
(0034948)
Juho Frits   
2014-01-16 04:29   
Setting the CMAKE_OSX_DEPLOYMENT_TARGET before project() command works.

I attached the output of running

  cmake --trace ..

If the execution went inside the following elseif in line 114 of Darwin.cmake:

elseif("${CMAKE_GENERATOR}" MATCHES Xcode
       OR CMAKE_OSX_DEPLOYMENT_TARGET
       OR CMAKE_OSX_ARCHITECTURES MATCHES "[^;]"
       OR NOT EXISTS "/usr/include/sys/types.h")

then the sysroot gets set correctly. However, I don't know how could the elseif be modified to make it work in my setup but not break any other setups. Running with Xcode generator works.

Setting CMAKE_OSX_ARCHITECTURES to something else than ";" with e.g. -DCMAKE_OSX_ARCHITECTURES="i386;x86_64" causes cmake to succeed. I don't quite understand the meaning of the architectures check.
(0034950)
Brad King   
2014-01-16 09:14   
Re 0014695:0034948: That elseif() checks for a value of CMAKE_OSX_ARCHITECTURES because one must use -isysroot when using -arch, or at least had to at one time in the past, especially to build universal binaries.

Setting CMAKE_OSX_DEPLOYMENT_TARGET after project() is not officially supported. With that fix, is anything still not working?
(0034951)
Juho Frits   
2014-01-16 09:32   
Everything seems to work after that change. I was just wondering that is it mentioned somewhere in the CMake documentation that CMAKE_OSX_DEPLOYMENT_TARGET should be set before project(). If not, it would be nice to have it mentioned to avoid confusion.
(0034953)
Brad King   
2014-01-16 10:24   
Actually it looks like the CMAKE_OSX_* variables are missing from the documentation altogether. I added entries for them:

 Help: Document CMAKE_OSX_* variables
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=45056264 [^]
(0036085)
Robert Maynard   
2014-06-02 08:38   
Closing resolved issues that have not been updated in more than 4 months.