Sign in to follow this  
Alundra

CMake GCC x86/x64

Recommended Posts

Hi,

Using CMake you can choose Visual Studio x86 or x64, but using GCC apparently you have to set yourself -m32 because it's based on the system.

The only way to have x86/x64 on GCC is to have a param which force -m32 or -m64 to be set when enabled ?

Thanks

Edited by Alundra

Share this post


Link to post
Share on other sites

Yes exactly and I need to have x86 and x64 possible, for windows using visual studio is easily possible, but for gcc looks less precise how do it correctly.

I'm using this code to select the good name of the output, project's name and libs used for shared lib, but only works for windows :

include(CheckTypeSize)
check_type_size(void* SIZEOF_VOID_PTR)
if("${SIZEOF_VOID_PTR}" STREQUAL "4")
  set(ARCH_32BITS 1)
elseif("${SIZEOF_VOID_PTR}" STREQUAL "8")
  set(ARCH_64BITS 1)
else()
  message(FATAL_ERROR "Unsupported architecture")
  return()
endif()
Edited by Alundra

Share this post


Link to post
Share on other sites
if(SIZEOF_VOID_PTR EQUAL 8)
  set(ARCH_64BITS 1)
else()
  set(ARCH_32BITS 1)
else()
  message(FATAL_ERROR "Unsupported architecture")
  return()
endif()

What makes you think that it isn't crossplatform?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this