[CMake] Build doesn't work with Mac OS X Lion...

Daniel Dekkers d.dekkers at cthrough.nl
Thu Dec 8 15:13:21 EST 2011


Adventures reverse engineering...
Turning the thread in the direction of iOS, sorry about that, but similar problems I think.

If I don't fill in any CMake architecture related variables at all, I get a "standard" Mac OS X app for Intel. But universal, both 32/64 bit, very impressive:

Architectures					Standard (32/64-bit Intel) - $(ARCHS_STANDARD_32_64_BIT)
Base SDK					/Developer/SDKs/MacOSX10.7.sdk
Build Active Architecture Only	Yes
Supported Platforms			macosx
Valid Architectures			i386 x86_64

Now I would like an iOS app.
If I *only* change the root SDK (to iOS 5.0 in my case) the project files are automagically changed to a default iOS app, set(CMAKE_OSX_SYSROOT /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk) results in:

Architectures					$(ARCHS_STANDARD_32_64_BIT) - $(ARCHS_STANDARD_32_64_BIT)
Base SDK					/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk
Build Active Architecture Only	Yes
Supported Platforms			iphonesimulator iphoneos		<- smart
Valid Architectures			armv6 armv7					<- smart

But, the Architectures field is not "substituted". Xcode doesn't know how to handle "$(ARCHS_STANDARD_32_64_BIT)" in an iOS context. 
I *have* to choose something for CMAKE_OSX_ARCHITECTURES at this point (feels like a forced move).
Ok, I choose: set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_BIT)"), inspired by Xcodes standard iOS templates. This results in:

Architectures					Standard (armv7) - $(ARCHS_STANDARD_32_BIT)
Base SDK					/Developer/Plattforms/[blabla]/iPhoneOS5.0.sdk
Build Active Architecture Only	Yes
Supported Platforms			iphonesimulator iphoneos
Valid Architectures			armv6 armv7

Ok, now Xcode can substitute for its Architectures field.
The project builds and runs after I add set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator") setting, but that's more about finding a library.
Device run works, Simulator run works. It just doesn't archive, in release mode (but i've been staring at that problem for weeks).

So iOS in a nutshell, three lines:

set(CMAKE_OSX_SYSROOT SDKROOT /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk)
set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_BIT)")
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")

I'm not fiddling with anything else (CMAKE_XCODE_EFFECTIVE_PLATFORMS for instance, or compiler choice). If it's not broke, don't fix it.

Now if only iOS (release) archiving would work, i'd be very happy.

Thanks, Daniel


On Dec 8, 2011, at 5:54 PM, Michael Jackson wrote:

> Maybe this will help:
> 
> On Lion 10.7.x (and I think Snow Leopard 10.6.x) if you leave the CMAKE_OSX_ARCHITECTURES blank you will get the default compile which is x86_64 (64 bit). OS X 10.5 and below you will get i386 (32 bit).
> 
> If you want to specifically build for certain architectures then fill in the CMAKE_OSX_ARCHITECTURES with any of the following:
> i386
> x86_64
> ppc
> ppc64
>  The PowerPC (ppc) archs I think you can only build for if you build against the 10.5 SDK. (Someone else can verify that). If you want to build a "Universal Binary" then put multiple values on a single line like so:
> 
> CMAKE_OSX_ARCHITECTURES   i386;x86_64
> 
> All of this is for OS X Applications. I have no idea how any of this relates to iOS development.
> --
> Mike Jackson <www.bluequartz.net>
> 
> On Dec 8, 2011, at 11:49 AM, Daniel Dekkers wrote:
> 
>> Hi,
>> 
>> And which one is which?
>> In Xcode (4.2), Lion, 64 bit Intel platform, a standard Xcode Mac OS X "template" will give these build settings in the Architectures section:
>> 
>> Architectures
>>  Additional SDKs
>>  Architectures					64-bit Intel - $(ARCHS_STANDARD_64_BIT) (this last value is grayed out)
>>  Base SDK						Latest Mac OS X (Mac OS X 10.7)
>>  Build Active Architecture Only		<Multiple values>
>>  Supported Platforms				macosx
>>  Valid Architectures				i386 x86_64
>> 
>> I always thought that the CMAKE_OSX_ARCHITECTURES value corresponded with the "first" Architectures Xcode field. So I set:
>> set(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_64_BIT)") in my CMake builds.
>> But with your last mail i'm confused if it corresponds to the Valid Architectures field instead. 
>> Or are these fields related? 64-bit Intel *implies* i386 and x86_64, although you could remove one of the two.
>> 
>> For an iOS "template" on the same system I get this:
>> 
>> Architectures
>>  Additional SDKs
>>  Architectures					Standard (armv7) - $(ARCHS_STANDARD_32_BIT) (this last value is grayed out)
>>  Base SDK						/Developer/[blabla]/iPhoneOS5.0.sdk
>>  Build Active Architecture Only		No
>>  Supported Platforms				iphonesimulator iphoneos
>>  Valid Architectures				armv6 armv7
>> 
>> Thanks,
>> Daniel
>> 
>> On Dec 8, 2011, at 3:35 PM, Nicolas Rannou wrote:
>> 
>>> What about moving to 64 bits?
>>> (which I guess is more relevant for Lion apps)
>>> 
>>> In your build directory:
>>> ccmake .
>>> Then modify:
>>> CMAKE_OSX_ARCHITECTURES          x86_64                                       
>>> CMAKE_OSX_DEPLOYMENT_TARGET      10.7                                         
>>> CMAKE_OSX_SYSROOT                /Developer/SDKs/MacOSX10.7.sdk
>>> 
>>> Nicolas
>>> 
>>> On Tue, Dec 6, 2011 at 5:35 PM, Dick Munroe <munroe at csworks.com> wrote:
>>> Yes I'm using 2.8.6.  Best,  Dick Munroe
>>> 
>>> 
>>> On 11/26/11 11:18 AM, David Cole wrote:
>>> Are you using CMake 2.8.6...? Older CMake versions have not been used
>>> much on Lion. It wouldn't surprise me if 2.8.6 works, but earlier
>>> versions have issues...
>>> 
>>> 
>>> HTH,
>>> David
>>> 
>>> 
>>> On Sat, Nov 26, 2011 at 6:37 AM, Daniel Dekkers<d.dekkers at cthrough.nl>  wrote:
>>> This:
>>> 
>>> SET(CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_BIT)")
>>> seems to result in a "standard" Xcode setting (armv7 (standard)) which is also set when you let Xcode create a fresh iOS app (from its own templates).
>>> 
>>> But you also see this a lot on the fora:
>>> SET(CMAKE_OSX_ARCHITECTURES "$(ARCHS_UNIVERSAL_IPHONE_OS)")
>>> 
>>> Not sure.
>>> 
>>> On Nov 26, 2011, at 4:38 AM, Michael Jackson wrote:
>>> 
>>> There is a cmake variable that you set during  onfiguration time.
>>> Something like os_x_architectures. There you can add the specific arch
>>> that you want to build for.
>>> 
>>> -----
>>> Mike Jackson                     www.bluequartz.net
>>> Principal Software Engineer       mike.jackson at bluequartz.net
>>> BlueQuartz Software               Dayton, Ohio
>>> ____________________________
>>> Sent from my mobile device. Please excuse the shortness of the reply.
>>> 
>>> On Nov 25, 2011, at 14:47, Dick Munroe<munroe at csworks.com>  wrote:
>>> 
>>> I've got a build that works just fine with Leopard.
>>> 
>>> For reasons I won't get into, I had to upgrade one of my systems to Lion and now (I've installed XCode 4.2) the build won't work.  I get the following error:
>>> 
>>> [  0%] Reaping winning child 0x10260c510 PID 1009
>>> Live child 0x10260c510 (libxp/CMakeFiles/xp.dir/Users/munroe/Documents/My_SVN/ESPlanner_Computation_Engine.U2011-11-01/Common/xmllib/print/libxp.cpp.o) PID 1010
>>> Building CXX object libxp/CMakeFiles/xp.dir/Users/munroe/Documents/My_SVN/ESPlanner_Computation_Engine.U2011-11-01/Common/xmllib/print/libxp.cpp.o
>>> Reaping winning child 0x10260c510 PID 1010
>>> Live child 0x10260c510 (libxp/CMakeFiles/xp.dir/Users/munroe/Documents/My_SVN/ESPlanner_Computation_Engine.U2011-11-01/Common/xmllib/print/libxp.cpp.o) PID 1011
>>> llvm-g++-4.2: Invalid arch name : -O2
>>> Reaping losing child 0x10260c510 PID 1011
>>> make[2]: *** [libxp/CMakeFiles/xp.dir/Users/munroe/Documents/My_SVN/ESPlanner_Computation_Engine.U2011-11-01/Common/xmllib/print/libxp.cpp.o] Error 1
>>> Removing child 0x10260c510 PID 1011 from chain.
>>> Reaping losing child 0x10c20c290 PID 1008
>>> make[1]: *** [libxp/CMakeFiles/xp.dir/all] Error 2
>>> Removing child 0x10c20c290 PID 1008 from chain.
>>> Reaping losing child 0x10940e730 PID 996
>>> 
>>> If I dig around, I find the CXX flags to be:
>>> 
>>> -arch  -O2 -fPIC
>>> 
>>> and for some reason the Lion g++ compiler is choking thinking that there should be and arch value.  Which if I dig around in the Leopard build I find:
>>> 
>>> -Dxp_EXPORTS  -arch i386 -O2 -g -fPIC
>>> 
>>> Which brings up the questions, (1) with the same CMakeLists.txt file, why am I getting different values and (2) how do I get the arch to be i386 on the Lion build.
>>> 
>>> Best,
>>> 
>>> Dick Munroe
>>> 
>>> --
>>> 
>>> Powered by www.kitware.com
>>> 
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>> 
>>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>> 
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>> --
>>> 
>>> Powered by www.kitware.com
>>> 
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>> 
>>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>> 
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>> --
>>> 
>>> Powered by www.kitware.com
>>> 
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>> 
>>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>> 
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>> 
>>> --
>>> 
>>> Powered by www.kitware.com
>>> 
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>> 
>>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>> 
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>>> 
>>> --
>>> 
>>> Powered by www.kitware.com
>>> 
>>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>>> 
>>> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>>> 
>>> Follow this link to subscribe/unsubscribe:
>>> http://www.cmake.org/mailman/listinfo/cmake
>> 
> 
> --
> 
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list