The architecture (32/64 bits) is now detected only on Windows

This commit is contained in:
Laurent Gomila 2012-01-03 18:02:18 +01:00
parent 88683504ba
commit 91705fe25c
3 changed files with 15 additions and 17 deletions

View file

@ -2,6 +2,18 @@
# detect the OS
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(WINDOWS 1)
# detect the architecture (note: this test won't work for cross-compilation)
include(CheckTypeSize)
check_type_size(void* SIZEOF_VOID_PTR)
if(${SIZEOF_VOID_PTR} EQUAL "4")
set(ARCH_32BITS 1)
elseif(${SIZEOF_VOID_PTR} EQUAL "8")
set(ARCH_64BITS 1)
else()
message(FATAL_ERROR "Unsupported architecture")
return()
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX 1)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
@ -17,25 +29,11 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
message(FATAL_ERROR "Unsupported version of OS X : ${MACOSX_VERSION_RAW}")
return()
endif()
else()
message(FATAL_ERROR "Unsupported operating system")
return()
endif()
# detect the architecture
# note: this test won't work for cross-compilation
include(CheckTypeSize)
check_type_size(void* SIZEOF_VOID_PTR)
if(${SIZEOF_VOID_PTR} MATCHES "^4$")
set(ARCH_32BITS 1)
elseif(${SIZEOF_VOID_PTR} MATCHES "^8$")
set(ARCH_64BITS 1)
else()
message(FATAL_ERROR "Unsupported architecture")
return()
endif()
# detect the compiler and its version
# Note: on some platforms (OS X), CMAKE_COMPILER_IS_GNUCXX is true
# even when CLANG is used, therefore the Clang test is done first