[CMake] How to set flags to build in Linux64 and Linux32?

Matthew Woehlke mw_triad at users.sourceforge.net
Wed Feb 11 16:28:22 EST 2009


Cherry Liu wrote:
> I'm pretty green with CMake and I'm trying to build a project in both
> Linux64 and Linux32, respectively. The compiler I'm using is GCC. Right
> now, I don't know what flags or what special commands to pass into my
> CMake template for this to happen.
> 
> The code I'm thinking of is:
> 
> if( GCC )
>       add_definitions( -DAW_NEW_IOSTREAMS )
>       set_target_properties( DEBUG RELEASE PROPERTIES COMPILE_FLAGS -m64
> LINK_FLAGS -m64 )
> endif()
> 
> the -m64 flag is borrowed from BJam, but it doesn't work at all. There
> has to be a CMake flag that tells the compiler to build either 64 or 32
> bit, right?

There is; -m64/-m32.

What isn't working in the above example? Do you get a 64-bit binary? 
(Note that x86_64 Linux distros tend to default to -m64.) What happens 
if you try -m32?

-- 
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
-- 
"Braaaaaaaaiins!" -- Zombies



More information about the CMake mailing list