[CMake] 32/64 bit flag

Eric Noulard eric.noulard at gmail.com
Mon Dec 9 07:26:14 EST 2013


2013/12/9 pellegrini <pellegrini at ill.fr>:
> Dear CMakers,
>
> I have to build cmake files for a Fortran project using ifort compiler on
> Windows, linux and macos platform.
> That project will be linked to Winteracter Fortran library whose
> installation paths are different depending on the 32
> or 64 bit versions. Is there a way to automatically detect whether the build
> is a 32 bit or 64 bit one in order to define
> the correct path for Winteracter library ? Up to now, the only way I found
> to do this was by introducing a cmake
> option to my build (ON for 64bit build and OFF for a 32 one). I also saw the
> CMAKE_CL_64 flag that could have been
> interesting but unfortunately it is only for microsoft.

Usually you chekc the value of CMAKE_SIZEOF_VOID_P
which will be 8 on 64 bits system and 4 on 32 bits ones.

e.g. here is what I use:
# Test 32/64 bits
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
   message(STATUS "Target is 64 bits")
   if (WIN32)
       set(WINXXBITS Win64)
   endif(WIN32)
else("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
   message(STATUS "Target is 32 bits")
   if (WIN32)
       set(WINXXBITS Win32)
   endif(WIN32)
endif("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")


See:
http://www.cmake.org/pipermail/cmake/2011-February/042752.html
or
cmake --help-variable CMAKE_SIZEOF_VOID_P
>
> thanks for your help
>
> Eric
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



-- 
Erk
L'élection n'est pas la démocratie -- http://www.le-message.org


More information about the CMake mailing list