diff options
| author | 2015-08-28 16:55:22 -0300 | |
|---|---|---|
| committer | 2015-09-08 19:35:11 -0300 | |
| commit | eb26a1941edd76b11066fe3e013bdf060308a25b (patch) | |
| tree | ae150cf0bdbd36557243972b2f4810b9d39ee6d0 | |
| parent | Merge pull request #1125 from yuriks/uilayout-config (diff) | |
| download | yuzu-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.txt | 36 |
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. |
| 3 | cmake_minimum_required(VERSION 2.8.11) | 3 | cmake_minimum_required(VERSION 2.8.11) |
| 4 | 4 | ||
| 5 | include(CheckSymbolExists) | ||
| 6 | function(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() | ||
| 20 | endfunction() | ||
| 21 | |||
| 5 | project(citra) | 22 | project(citra) |
| 6 | 23 | ||
| 7 | if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit) | 24 | 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) | |||
| 10 | DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks) | 27 | DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks) |
| 11 | endif() | 28 | endif() |
| 12 | 29 | ||
| 13 | # Platform-agnostic definition to check if we are on x86_64 | 30 | if (MSVC) |
| 14 | if(${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) | 34 | else() |
| 35 | detect_architecture("__x86_64__" x86_64) | ||
| 36 | detect_architecture("__i386__" x86) | ||
| 37 | detect_architecture("__arm__" ARM) | ||
| 38 | endif() | ||
| 39 | if (NOT DEFINED ARCHITECTURE) | ||
| 40 | set(ARCHITECTURE "GENERIC") | ||
| 41 | set(ARCHITECTURE_GENERIC 1) | ||
| 42 | add_definitions(-DARCHITECTURE_GENERIC=1) | ||
| 18 | endif() | 43 | endif() |
| 44 | message(STATUS "Target architecture: ${ARCHITECTURE}") | ||
| 19 | 45 | ||
| 20 | if (NOT MSVC) | 46 | if (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") |