diff --git a/CMakeLists.txt b/CMakeLists.txt index bdabdcc..0d071db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,15 +89,32 @@ set(TARGET_CPU "" CACHE STRING "Target CPU, used as --target_cpu argument") set(TARGET_CPU_LIST x86 x64 arm arm64 mipsel) if (TARGET_CPU STREQUAL "") - if (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") + include(CheckSymbolExists) + if (WIN32) + check_symbol_exists("_M_X64" "" ARCH_X64) + if (NOT ARCH_X64) + check_symbol_exists("_M_AMD64" "" ARCH_X64) + if (NOT ARCH_X64) + check_symbol_exists("_M_IX86" "" ARCH_X86) + if (NOT ARCH_X86) + check_symbol_exists("_M_ARM" "" ARCH_ARM) + check_symbol_exists("_M_ARM64" "" ARCH_ARM64) + endif (NOT ARCH_X86) + endif (NOT ARCH_X64) + endif (NOT ARCH_X64) + else (WIN32) + check_symbol_exists("__i386__" "" ARCH_X86) + check_symbol_exists("__x86_64__" "" ARCH_X64) + check_symbol_exists("__arm__" "" ARCH_ARM) + check_symbol_exists("__aarch64__" "" ARCH_ARM64) + endif (WIN32) + if (ARCH_X86) set(TARGET_CPU "x86") - elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "^x86.64$") - set(TARGET_CPU "x64") - elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") + elseif (ARCH_X64) set(TARGET_CPU "x64") else () set(TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR}) - endif (CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$") + endif (ARCH_X86) endif (TARGET_CPU STREQUAL "") if (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST) @@ -105,9 +122,9 @@ if (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST) endif (NOT ${TARGET_CPU} IN_LIST TARGET_CPU_LIST) if (UNIX) - if (TARGET_CPU STREQUAL "x86") + if (ARCH_X86) set(LIBWEBRTC_REQUIRED_CXX_FLAGS "-m32") - endif (TARGET_CPU STREQUAL "x86") + endif (ARCH_X86) set(LIBWEBRTC_REQUIRED_CXX_FLAGS "${LIBWEBRTC_REQUIRED_CXX_FLAGS} -std=gnu++0x") list(APPEND LIBWEBRTC_DEFINITIONS WEBRTC_POSIX _GLIBCXX_USE_CXX11_ABI=0) elseif (WIN32)