summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--CMakeLists.txt36
1 files changed, 31 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ebffc0d85..967e7ff24 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,23 @@
# dependent libraries.
cmake_minimum_required(VERSION 2.8.11)
+include(CheckSymbolExists)
+function(detect_architecture symbol arch)
+ if (NOT DEFINED ARCHITECTURE)
+ set(CMAKE_REQUIRED_QUIET 1)
+ check_symbol_exists("${symbol}" "" ARCHITECTURE_${arch})
+ unset(CMAKE_REQUIRED_QUIET)
+
+ # The output variable needs to be unique across invocations otherwise
+ # CMake's crazy scope rules will keep it defined
+ if (ARCHITECTURE_${arch})
+ set(ARCHITECTURE "${arch}" PARENT_SCOPE)
+ set(ARCHITECTURE_${arch} 1 PARENT_SCOPE)
+ add_definitions(-DARCHITECTURE_${arch}=1)
+ endif()
+ endif()
+endfunction()
+
project(citra)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit)
@@ -10,12 +27,21 @@ if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit)
DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks)
endif()
-# Platform-agnostic definition to check if we are on x86_64
-if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "[xX]86_64" OR
- ${CMAKE_SYSTEM_PROCESSOR} MATCHES "[aA][mM][dD]64")
- set(ARCHITECTURE_x86_64 1)
- add_definitions(-DARCHITECTURE_x86_64=1)
+if (MSVC)
+ detect_architecture("_M_AMD64" x86_64)
+ detect_architecture("_M_IX86" x86)
+ detect_architecture("_M_ARM" ARM)
+else()
+ detect_architecture("__x86_64__" x86_64)
+ detect_architecture("__i386__" x86)
+ detect_architecture("__arm__" ARM)
+endif()
+if (NOT DEFINED ARCHITECTURE)
+ set(ARCHITECTURE "GENERIC")
+ set(ARCHITECTURE_GENERIC 1)
+ add_definitions(-DARCHITECTURE_GENERIC=1)
endif()
+message(STATUS "Target architecture: ${ARCHITECTURE}")
if (NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread")