[CMake] determine 32 vs 64 bit linux

Jean-Christophe Fillion-Robin jchris.fillionr at kitware.com
Wed Jun 22 21:31:17 EDT 2011


Hi Karl,

You could do so something like that:

set(bitness 32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  set(bitness 64)
endif()

The following macro provides a more complete example...
http://viewvc.slicer.org/viewvc.cgi/Slicer4/trunk/CMake/SlicerMacroGetPlatformArchitectureBitness.cmake?view=markup

#
# SlicerMacroGetPlatformArchitectureBitness(<var-prefix>)
# is used to extract information associated with the current platform.
#
# The macro defines the following variables:
#  <var-prefix>_BITNESS - bitness of the platform: 32 or 64
#  <var-prefix>_PLATFORM - which is on the this value: linux, macosx, win
#  <var-prefix>_ARCHITECTURE - which is on the this value: i386, amd64, ppc



Hth
Jc


On Wed, Jun 22, 2011 at 7:33 PM, Karl Merkley <karl at elemtech.com> wrote:

>
> I need to install a library into a directory whose name depends on the
> machine type.   For example
>
> if (WIN32)
>  if (CMAKE_CL_64)
>      set(ARCH_DIR "win32")
>  else()
>      set(ARCH_DIR "win64")
>  endif()
>
> elseif (UNIX)
>  if (????)
>      set(ARCH_DIR "linux32")
>  else()
>     set(ARCH_DIR "linux64")
> endif()
>
> Is there a better way to do this?   The win64 version seems to work
> correctly.   What variable do I check for 32 vs 64 bit linux?
>
>  Thanks,
>        Karl
>
>
>
>
>
>
> _______________________________________________
> 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
>



-- 
+1 919 869 8849
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110622/7dc1ce36/attachment-0001.htm>


More information about the CMake mailing list