Detect 32-bit/64-bit correctly based on CFLAGS

The user might invoke cmake with CFLAGS containing "-m32" or (on OS X) "-arch i386" while on a 64-bit machine to indicate that it should build for 32-bit instead.
This commit is contained in:
Ryan Schmidt
2015-05-11 11:16:39 -05:00
committed by Tres Finocchiaro
parent 4da73f345c
commit 571e4fd31a

View File

@@ -24,7 +24,7 @@ IF(WIN32)
SET(IS_X86 TRUE)
ENDIF(WIN64)
ELSE(WIN32)
EXEC_PROGRAM( ${CMAKE_C_COMPILER} ARGS "-dumpmachine" OUTPUT_VARIABLE Machine )
EXEC_PROGRAM( ${CMAKE_C_COMPILER} ARGS "-dumpmachine ${CMAKE_C_FLAGS}" OUTPUT_VARIABLE Machine )
MESSAGE("Machine: ${Machine}")
STRING(REGEX MATCH "i.86" IS_X86 "${Machine}")
STRING(REGEX MATCH "86_64" IS_X86_64 "${Machine}")