From d7a4e3b1b6938ce3e0c7f0597c4b16c2018552d5 Mon Sep 17 00:00:00 2001 From: Hugues Delorme Date: Tue, 3 Mar 2015 10:27:39 +0100 Subject: [PATCH] cmake: detection of the targer architecture bit size --- CMakeLists.txt | 2 ++ src/gmio_core/config.h.cmake | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ccb02d..ecfe9da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,8 @@ option(BUILD_WITH_LIBSTL "Build the libSTL module" ON) file(GLOB ALL_SRC_FILES src/gmio_core/* src/gmio_core/internal/*) set(ALL_SRC_FILES ${ALL_SRC_FILES}) +math(EXPR GMIO_TARGET_ARCH_BIT_SIZE "8 * ${CMAKE_SIZEOF_VOID_P}") + if(NOT BUILD_STRICT_C90) # Have ? check_include_files(stdint.h GMIO_HAVE_STDINT_H) diff --git a/src/gmio_core/config.h.cmake b/src/gmio_core/config.h.cmake index 2c463a6..24645ca 100644 --- a/src/gmio_core/config.h.cmake +++ b/src/gmio_core/config.h.cmake @@ -29,4 +29,16 @@ #cmakedefine GMIO_HAVE_MSVC_BUILTIN_BSWAP_FUNC +#if defined(__APPLE__) +# if defined(__i386__) || defined(__ppc__) +# define GMIO_TARGET_ARCH_BIT_SIZE 32 +# elif defined(__x86_64__) || defined(__ppc64__) +# define GMIO_TARGET_ARCH_BIT_SIZE 64 +# else +# error "Unknown architecture!" +# endif +#else +# define GMIO_TARGET_ARCH_BIT_SIZE @GMIO_TARGET_ARCH_BIT_SIZE@ +#endif + #endif /* GMIO_CONFIG_H_CMAKE */