On Tue 30 Aug 2011 07:54:45 AM CEST, Dongsheng Song wrote: > Hi, > > In CMakeLists.txt, I want to know whether cmake has built-in mechanism that > I can know the target is 32-bit, or 64bit ? > > Thanks, > Dongsheng
Look at the CMAKE_SIZEOF_VOID_P variable. However, normally this is better handled in the code through #ifdef's, because on some platforms (e.g. Mac) it is possible to compile for multiple architecture at once with a single compiler invocation. I.e., something like gcc -arch i386 -arch ppc -arch x86_64 -arch ppc64 hello.c will compile hello.c *four* times, first with __i386__ defined, then with __ppc__, followed by __x86_64__ and finally with __ppc64__. If you ever plan to support Mac OS X and allow your users to set the CMAKE_OSX_ARCHITECTURES variable to a list of architectures with varying bit-sex and pointer sizes, you should *not* rely on CMAKE_SIZEOF_VOID_P, since that will only contain the pointer size of the *first* architecture. HTH Michael _______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake