summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-08-28 16:55:22 -0300
committerGravatar Yuri Kunde Schlesner2015-09-08 19:35:11 -0300
commiteb26a1941edd76b11066fe3e013bdf060308a25b (patch)
treeae150cf0bdbd36557243972b2f4810b9d39ee6d0
parentMerge pull request #1125 from yuriks/uilayout-config (diff)
downloadyuzu-eb26a1941edd76b11066fe3e013bdf060308a25b.tar.gz
yuzu-eb26a1941edd76b11066fe3e013bdf060308a25b.tar.xz
yuzu-eb26a1941edd76b11066fe3e013bdf060308a25b.zip
CMake: Fix architecture detection on MSVC
CMAKE_SYSTEM_ARCHICTETURE always returns the *host* not target arch when using the MSVC generators. (CMake bugs 15170 and 14342.)
-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 @@
2# dependent libraries. 2# dependent libraries.
3cmake_minimum_required(VERSION 2.8.11) 3cmake_minimum_required(VERSION 2.8.11)
4 4
5include(CheckSymbolExists)
6function(detect_architecture symbol arch)
7 if (NOT DEFINED ARCHITECTURE)
8 set(CMAKE_REQUIRED_QUIET 1)
9 check_symbol_exists("${symbol}" "" ARCHITECTURE_${arch})
10 unset(CMAKE_REQUIRED_QUIET)
11
12 # The output variable needs to be unique across invocations otherwise
13 # CMake's crazy scope rules will keep it defined
14 if (ARCHITECTURE_${arch})
15 set(ARCHITECTURE "${arch}" PARENT_SCOPE)
16 set(ARCHITECTURE_${arch} 1 PARENT_SCOPE)
17 add_definitions(-DARCHITECTURE_${arch}=1)
18 endif()
19 endif()
20endfunction()
21
5project(citra) 22project(citra)
6 23
7if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit) 24if(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)
10 DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks) 27 DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks)
11endif() 28endif()
12 29
13# Platform-agnostic definition to check if we are on x86_64 30if (MSVC)
14if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "[xX]86_64" OR 31 detect_architecture("_M_AMD64" x86_64)
15 ${CMAKE_SYSTEM_PROCESSOR} MATCHES "[aA][mM][dD]64") 32 detect_architecture("_M_IX86" x86)
16 set(ARCHITECTURE_x86_64 1) 33 detect_architecture("_M_ARM" ARM)
17 add_definitions(-DARCHITECTURE_x86_64=1) 34else()
35 detect_architecture("__x86_64__" x86_64)
36 detect_architecture("__i386__" x86)
37 detect_architecture("__arm__" ARM)
38endif()
39if (NOT DEFINED ARCHITECTURE)
40 set(ARCHITECTURE "GENERIC")
41 set(ARCHITECTURE_GENERIC 1)
42 add_definitions(-DARCHITECTURE_GENERIC=1)
18endif() 43endif()
44message(STATUS "Target architecture: ${ARCHITECTURE}")
19 45
20if (NOT MSVC) 46if (NOT MSVC)
21 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread") 47 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread")