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.
相关问题
- Angular: ngc or tsc?
- Where is the implementation of included C++/C head
- Avoid cmake to add the flags -search_paths_first a
- CMakeList file to generate LLVM bitcode file from
- How to fix NDK build error for HelloCardboard samp
相关文章
- Target requires the language dialect “CXX17” (with
- php module does not compile. Does not recognize “s
- Why does the C++ compiler give errors after lines
- Compile drools guided decision table into rules
- How do I tell cmake not to create a console window
- Why doesn't there exists a subi opcode for MIP
- Mvn compile before exec
- Is C# code compiled to native binaries?
If CMAKE_OSX_ARCHITECTURES=i386 gives you the error "unrecognized option -arch" start over and instead try:
There is a CMake tutorial available online to go over the basics, this is taken from the CMake book. The CMake philosophy is to use multiple build directories, with a single source tree. So you could use Visual Studio on Windows and create a build directory using the 32 bit compiler, and another using the 64 bit compiler.
CMake targets a large number of compilers and operating systems, but you don't mention what language you are using, what operating system/compiler/architectures you are thinking of and if you are using any toolkits/libraries.
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