[CMake] Ensuring not building for 64-bit

Michael Jackson mike.jackson at bluequartz.net
Mon Aug 17 14:21:06 EDT 2009


On Aug 17, 2009, at 2:16 PM, Michael Wild wrote:

>
> On 17. Aug, 2009, at 18:40, Michael Jackson wrote:
>
>>
>> On Aug 17, 2009, at 12:30 PM, ML wrote:
>>
>>> Hi Mike,
>>>
>>>> The double __LP64__ is making sure it (__LP64__) is both DEFINED  
>>>> and TRUE.
>>>>
>>>> # if defined ((__APPLE__)) && defined(__LP64__) && __LP64__
>>>> typedef CIconHandle  OSColorIcon;  // Mac CIcon
>>>> #else
>>>
>>> To to help me fine tune a bit..
>>>
>>> Wouldn't (__APPLE__) be automatically defined if I am compiling on  
>>> OS X?
>>>
>>> Is there a place where I can see what others like __LP64__ are  
>>> available?
>>>
>>> -Jason
>>>
>>>
>>
>> The last email will default to 32 bit i386 compiles:
>>
>> echo | gcc -arch x86_64 -E -dM -
>>
>> for 64 bit intel builds
>>
>> Mike
>
>
> My favorite for i386 is:
>
> gcc -arch i386 -E -dM - < /dev/null
>
> if I want to see the x86_64 stuff I do
>
> gcc -arch x86_64 -E -dM - < /dev/null
>
>
> If you want to force a 32 bit compile, set the  
> CMAKE_OSX_ARCHITECTURES variable to i386 and/or ppc and you're done!  
> You can check that you're compiling for 32 bit in your source files,  
> but you can't FORCE it. You have to do that in your build system.  
> You can do something like this in your CMake-code:
>
> list( FIND CMAKE_OSX_ARCHITECTURES x86_64 __HAS_X86_64 )
> list( FIND CMAKE_OSX_ARCHITECTURES ppc64 __HAS_PPC64 OR  
> CMAKE_SIZEOF_VOID_P EQUALS 8 )
> if( __HAS_X86_64 OR __HAS_PPC64 OR )
>  message( SEND_ERROR "NO 64-bit architectures allowed! Adjust  
> CMAKE_OSX_ARCHITECTURES" )
> endif()
>
> Michael

he _could_ force an error on 64 bit compile:

#if defined (__LP64__) && (__LP64__)
#error NO 64 BIT COMPILES ALLOWED.
#endif

I agree that catching it at the build system level would be better but  
if he _really_ wanted to stop the compilation dead in its tracks then  
the above _should_ do the trick.

Mike Jackson



More information about the CMake mailing list