CMake多体系结构编译 [英] CMake Multiarchitecture Compilation
问题描述
我想知道如何编写一个CMake安装程序,允许使用任何编译器和操作系统对x86和x64架构进行编译。
这将是巨大的,如果CMake有一个32 / 64bit的选项开箱。它不会,所以你将需要应用不同的编译器或生成器依赖方法之一。例如:
-
GCC(在Linux上)和其他一些编译器,例如太阳工作室。设置
CFLAGS
和CXXFLAGS
以包括-m32
位构建)或-m64
(64位构建)。 -
使用64位发生器,例如。
cmake -GVisual Studio 10 Win64path\to\source\dir
编译64位(x64)。使用
CMAKE_OSX_ARCHITECTURES
在生成器名称中省略Win64以构建32位 - CMake变量。
cmake -DCMAKE_OSX_ARCHITECTURES = i386 / path / to / source / dir
将编译32位版本
cmake -DCMAKE_OSX_ARCHITECTURES = x86_64 / path / to / source / dir
将编译64位。
cmake-DCMAKE_OSX_ARCHITECTURES = x86_64; i386/ path / to / source / dir
将创建96位通用二进制文件:)
上述内容稍作修改。
http://dev.mysql.com/doc/internals/ en / compiling-for-different-hardware-achitectures.html
I want to know how I could write a CMake setup which allows compilation for both x86 and x64 architectures using any compiler and OS.
It would be great if CMake had an 32/64bit option out of the box. It does not, so you will need to apply one of different compiler or generator dependend methods. E.g.:
GCC (on Linux) and some other compilers, e.g. Sun Studio. Set
CFLAGS
andCXXFLAGS
to include-m32
(32-bit build) or-m64
(64-bit build).Windows, Visual Studio generator. Use 64 bit generator, e.g.
cmake -G "Visual Studio 10 Win64" path\to\source\dir
to compile 64-bit (x64). Omit "Win64" in generator name, to build for 32 bit
Mac OS X. Use
CMAKE_OSX_ARCHITECTURES
CMake variable.cmake -DCMAKE_OSX_ARCHITECTURES=i386 /path/to/source/dir
will compile 32 bit buildcmake -DCMAKE_OSX_ARCHITECTURES=x86_64 /path/to/source/dir
will compile 64 bit.cmake "-DCMAKE_OSX_ARCHITECTURES=x86_64;i386" /path/to/source/dir
will create 96-bit universal binaries :)
The above is slightly reworded.
http://dev.mysql.com/doc/internals/en/compiling-for-different-hardware-achitectures.html
这篇关于CMake多体系结构编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!