Re: [firebreath-dev] How to Build both 32 and 64 bits on the same computer

1,442 views
Skip to first unread message

Neil Griffiths

unread,
May 7, 2013, 1:43:00 PM5/7/13
to firebre...@googlegroups.com
I'm fairly sure you can't do that from within CMake. But you could certainly write a script that outputs to two different directories that output a 64-bit and 32-bit project respectively. That's what I'd do anyway!

For Linux and OSX (so long as you generate Makefiles there) you'd want to set:

set(CMAKE_C_FLAGS -m32)
set(CMAKE_CXX_FLAGS -m32)

...though you may find it easier, in your script, to just pass the following parameters into cmake instead:

cmake -DCMAKE_C_FLAGS=-m32 --DCMAKE_CXX_FLAGS=-m32 ...

If you're creating an Xcode project then this should work:

if (Apple)
  set (CMAKE_OSX_ARCHITECTURES i386)
endif (Apple)

Not setting those, so long as you're on a 64-bit machine, would create 64-bit projects by default.

Good luck!

Neil


On Tue, May 7, 2013 at 12:24 PM, Massimiliano Pala <pa...@penango.com> wrote:
Hi FireBreath-ers,

I am looking for a way to generate, in one pass, both 32 and 64 bits of my plugin.

Question: Is there any settings in CMake files I can set to automatically generate the two versions (32 and 64 bits) ?

If not, I thought about creating a script that switches the PluginConfig.cmake file with different configurations for 32 and 64bits.. but would that be sufficient ? And what config options should I change in there to force compilation of 32 or 64 bits (i.e., I want to be able to also compile 32bits on 64bits operating system).

I need to do this for Linux, Win, and MacOS.

Thanks for your help!

Cheers,
Max

--
 
---
You received this message because you are subscribed to the Google Groups "firebreath-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebreath-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Richard Bateman

unread,
May 7, 2013, 4:36:00 PM5/7/13
to firebre...@googlegroups.com

Try something like this on windows in a batch file:


============
@echo off
REM buildboth.cmd
prep2010.cmd projects build_32
cmake --build build_32 --config RelWithDebInfo

prep2010_x64.cmd projects build_64
cmake --build build_64 --config RelWithDebInfo
============

That should about do it.  On linux it may be harder; I don't know myself offhand how to build for 32 bit on a 64 bit system, and I suspect you need a 64 bit system to build 64 bit.  On mac it'll build for both by default, and with a FAT binary which will work on both 32 and 64 bit.  Of course, on mac if you have a 32 bit it'll work on 64 bit browsers, so most people are better off just using a 32 bit binary. On windows cmake won't let you build both in the same project.

Richard

Dr. Pala

unread,
May 8, 2013, 10:46:44 AM5/8/13
to firebre...@googlegroups.com
Hello Richard, all,

thanks for the replies. I will try to add a script and see if that does the trick. On Linux platforms, I actually used the same approach - I passed the arguments to the prepmake.sh script via my Makefile, here's an example (for people who might want to do the same):

   prepmake.sh <src> <build> -DCMAKE_C_FLAGS="-m32" -DCMAKE_CXX_FLAGS="-m32"

this forces the architecture to be 32 bits. You can force the 64 bits by simply using -m64 instead of -m32. If you are linking some external libraries, you might need to check that the correct version of the library is available in your lib path.

Thanks again!

Cheers,
Max

  

On 05/07/2013 04:36 PM, Richard Bateman wrote:

Try something like this on windows in a batch file:


============
@echo off
REM buildboth.cmd
prep2010.cmd projects build_32
cmake --build build_32 --config RelWithDebInfo

prep2010_x64.cmd projects build_64
cmake --build build_64 --config RelWithDebInfo
============

That should about do it.  On linux it may be harder; I don't know myself offhand how to build for 32 bit on a 64 bit system, and I suspect you need a 64 bit system to build 64 bit.  On mac it'll build for both by default, and with a FAT binary which will work on both 32 and 64 bit.  Of course, on mac if you have a 32 bit it'll work on 64 bit browsers, so most people are better off just using a 32 bit binary. On windows cmake won't let you build both in the same project.

Richard



--

Best Regards,
Massimiliano Pala, Ph.D.
VP of Engineering

Penango
Tel. (603) 369-9332
skype: openca

Dr. Pala

unread,
May 8, 2013, 10:51:35 AM5/8/13
to firebre...@googlegroups.com
Hi all,

I am not sure if I should report this here or somewhere else, it is a very minor bug. I found that, if you have the ZipGenius installed on Windows platforms, the unpacking of the boost.tar.gz might fail - this is because the system-wide installed gets the precedence over the firebreath-distributed version (my version had a slightly different syntax, therefore it was failing).

To fix this, I just set the findprogram line (cmake/cmake.common:~260):

    find_program(SEVZIP 7za PATHS "${FB_ROOT}/cmake/")

and substituted with the following:

    file (GLOB SEVZIP
       ${FB_ROOT}/cmake/7za.*
    )

this, by making sure that the 7za used is from the firebreath\cmake directory, fixed the issue.

I hope this helps.


Cheers,
Max


On 05/07/2013 04:36 PM, Richard Bateman wrote:
Reply all
Reply to author
Forward
0 new messages