[CMake] [Insight-developers] 64 bit build detection

Clinton Stimpson clinton at elemtech.com
Thu Jun 11 16:21:25 EDT 2009


I don't use that variable on Mac.
But it is still useful and sometimes needed for platforms that don't 
support universal binaries.
Consider that Linux might have lib/ lib64/ and/or lib32/, and Windows 
might have c:\program files\ and c:\program files (x86)\.
So find_library() and things like that need to still work right.
If the code needs to know bitness, then I think it should use compiler 
defined preprocessor defines, instead of relying on CMake.

Clint

Michael Jackson wrote:
> 529:[mjackson at Ferb:x64]$ export CXXFLAGS="-arch x86_64"
> 530:[mjackson at Ferb:x64]$ rm -rf *; cmake ../
> -- The C compiler identification is GNU
> -- The CXX compiler identification is GNU
> -- Check for working C compiler: /usr/bin/gcc
> -- Check for working C compiler: /usr/bin/gcc -- works
> -- Detecting C compiler ABI info
> -- Detecting C compiler ABI info - done
> -- Check for working CXX compiler: /usr/bin/c++
> -- Check for working CXX compiler: /usr/bin/c++ -- works
> -- Detecting CXX compiler ABI info
> -- Detecting CXX compiler ABI info - done
> -- CMAKE_SIZEOF_VOID_P: 8
> -- Configuring done
> -- Generating done
> -- Build files have been written to: /Users/mjackson/Desktop/Test/x64
>
> For those reading this after the fact or from a google search...
>
> So. where does this leave us? Basically if you ONLY do one arch or 
> another on OS X using this type of technique is probably fine. If you 
> are building Universal binaries then some thing more in-depth would be 
> needed if the explicit detection of the size of a void pointer is 
> needed. Probably something using the standard apple #ifdef __APPLE__ 
> && __LP64 or something like that.
>
>  This may still fall apart if someone wrote a program to spit out 
> various stats on the system, the executable was built as a universal 
> binary, ran as a 32 bit executable but the user was expecting a 64 bit 
> executable to be run. Maybe none of this matters.
>
> At least I figured out that much today. ;-)
>
> mike
>
> On Jun 11, 2009, at 3:37 PM, Bill Hoffman wrote:
>
>> Michael Jackson wrote:
>>
>>> So it builds a 32 bit executable.
>> :)
>>> Are you saying (from above) that if I have a 64 bit build of CMake 
>>> then I will get 64 bit binaries by default?
>> No, it depends on the flags given to the compiler.  I think you want 
>> -m64.  So if you do this:
>>
>> export CFLAGS=-m64
>> mkdir Build64
>> cd Build64
>> cmake ../Test
>> make
>>
>> Then you will get a 64 bit build.
>>
>> -Bill
>
> _______________________________________________
> 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