[CMake] Detecting -m32 build target on 64-bit host

Mateusz Loskot mateusz at loskot.net
Wed Apr 29 16:04:20 EDT 2015


On 24 April 2015 at 21:00, Gregor Jasny <gjasny at googlemail.com> wrote:
> On 23/04/15 16:54, Mateusz Loskot wrote:
>> Surprisingly, I'm having trouble to figure out how to determine,
>> that in Linux 64-bit OS, I'm building a project with -m32 specified.
>> IOW, any CMake variable or macro to tell me target architecture
>> of a build that is being configured is 32 or 64 bit?
>
> Does this help?
>
> include(CheckSymbolExists)
>
> if(WIN32)
>   check_symbol_exists("_M_AMD64" "" RTC_ARCH_X64)
>   if(NOT RTC_ARCH_X64)
>     check_symbol_exists("_M_IX86" "" RTC_ARCH_X86)
>   endif(NOT RTC_ARCH_X64)
>   # add check for arm here
>   # see http://msdn.microsoft.com/en-us/library/b0084kay.aspx
> else(WIN32)
>   check_symbol_exists("__i386__" "" RTC_ARCH_X86)
>   check_symbol_exists("__x86_64__" "" RTC_ARCH_X64)
>   check_symbol_exists("__arm__" "" RTC_ARCH_ARM)
> endif(WIN32)

Gregor, yes, indeed.

Thanks!

-- 
Mateusz  Loskot, http://mateusz.loskot.net


More information about the CMake mailing list