View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014695CMakeCMakepublic2014-01-14 04:402014-06-02 08:38
ReporterJuho Frits 
Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
StatusclosedResolutionno change required 
PlatformMac OS XOSOS XOS Version10.7
Product VersionCMake 2.8.12.1 
Target VersionFixed in Version 
Summary0014695: CMake fails with XCode 4.6 and Qt 4 with CMAKE_OSX_DEPLOYMENT_TARGET
DescriptionCMake 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.
TagsNo tags attached.
Attached Filestxt file icon cmake-output.txt [^] (264,823 bytes) 2014-01-16 03:54

 Relationships
related to 0014324closedBrad King bootstrap fails when CMAKE_OSX_DEPLOYMENT_TARGET is set and CFLAGS has -isysroot 

  Notes
(0034934)
Brad King (manager)
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 (manager)
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 (reporter)
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 (manager)
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 (reporter)
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 (manager)
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 (manager)
2014-06-02 08:38

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2014-01-14 04:40 Juho Frits New Issue
2014-01-14 09:01 Brad King Relationship added related to 0014324
2014-01-14 09:05 Brad King Note Added: 0034934
2014-01-14 09:14 Brad King Note Added: 0034936
2014-01-16 03:54 Juho Frits File Added: cmake-output.txt
2014-01-16 04:29 Juho Frits Note Added: 0034948
2014-01-16 09:14 Brad King Note Added: 0034950
2014-01-16 09:32 Juho Frits Note Added: 0034951
2014-01-16 10:24 Brad King Note Added: 0034953
2014-01-16 10:24 Brad King Status new => resolved
2014-01-16 10:24 Brad King Resolution open => no change required
2014-06-02 08:38 Robert Maynard Note Added: 0036085
2014-06-02 08:38 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team