[CMake] Ensuring not building for 64-bit

Michael Wild themiwi at gmail.com
Mon Aug 17 14:17:44 EDT 2009


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


More information about the CMake mailing list