summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2015-09-08 18:53:50 -0400
committerGravatar bunnei2015-09-08 18:53:50 -0400
commit9205aca95ca30f510f58316de8173cb35e984e87 (patch)
tree6e1d8b2217d04ab1519546ec4d77d9caa4327d2a
parentMerge pull request #1125 from yuriks/uilayout-config (diff)
parentCMake: Point binary downloads to new official repo (diff)
downloadyuzu-9205aca95ca30f510f58316de8173cb35e984e87.tar.gz
yuzu-9205aca95ca30f510f58316de8173cb35e984e87.tar.xz
yuzu-9205aca95ca30f510f58316de8173cb35e984e87.zip
Merge pull request #1020 from yuriks/qt-binaries
CMake: Add option to download Qt binaries
-rw-r--r--CMakeLists.txt131
-rw-r--r--appveyor.yml2
-rw-r--r--src/citra/CMakeLists.txt3
3 files changed, 81 insertions, 55 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ebffc0d85..0bf2df504 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,37 @@
2# dependent libraries. 2# dependent libraries.
3cmake_minimum_required(VERSION 2.8.11) 3cmake_minimum_required(VERSION 2.8.11)
4 4
5function(download_bundled_external remote_path lib_name prefix_var)
6 set(prefix "${CMAKE_BINARY_DIR}/externals/${lib_name}")
7 if (NOT EXISTS "${prefix}")
8 message(STATUS "Downloading binaries for ${lib_name}...")
9 file(DOWNLOAD
10 https://github.com/citra-emu/ext-windows-bin/raw/master/${remote_path}${lib_name}.7z
11 "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z" SHOW_PROGRESS)
12 execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z"
13 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals")
14 endif()
15 message(STATUS "Using bundled binaries at ${prefix}")
16 set(${prefix_var} "${prefix}" PARENT_SCOPE)
17endfunction()
18
19include(CheckSymbolExists)
20function(detect_architecture symbol arch)
21 if (NOT DEFINED ARCHITECTURE)
22 set(CMAKE_REQUIRED_QUIET 1)
23 check_symbol_exists("${symbol}" "" ARCHITECTURE_${arch})
24 unset(CMAKE_REQUIRED_QUIET)
25
26 # The output variable needs to be unique across invocations otherwise
27 # CMake's crazy scope rules will keep it defined
28 if (ARCHITECTURE_${arch})
29 set(ARCHITECTURE "${arch}" PARENT_SCOPE)
30 set(ARCHITECTURE_${arch} 1 PARENT_SCOPE)
31 add_definitions(-DARCHITECTURE_${arch}=1)
32 endif()
33 endif()
34endfunction()
35
5project(citra) 36project(citra)
6 37
7if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit) 38if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit)
@@ -10,12 +41,21 @@ if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit)
10 DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks) 41 DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks)
11endif() 42endif()
12 43
13# Platform-agnostic definition to check if we are on x86_64 44if (MSVC)
14if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "[xX]86_64" OR 45 detect_architecture("_M_AMD64" x86_64)
15 ${CMAKE_SYSTEM_PROCESSOR} MATCHES "[aA][mM][dD]64") 46 detect_architecture("_M_IX86" x86)
16 set(ARCHITECTURE_x86_64 1) 47 detect_architecture("_M_ARM" ARM)
17 add_definitions(-DARCHITECTURE_x86_64=1) 48else()
49 detect_architecture("__x86_64__" x86_64)
50 detect_architecture("__i386__" x86)
51 detect_architecture("__arm__" ARM)
18endif() 52endif()
53if (NOT DEFINED ARCHITECTURE)
54 set(ARCHITECTURE "GENERIC")
55 set(ARCHITECTURE_GENERIC 1)
56 add_definitions(-DARCHITECTURE_GENERIC=1)
57endif()
58message(STATUS "Target architecture: ${ARCHITECTURE}")
19 59
20if (NOT MSVC) 60if (NOT MSVC)
21 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread") 61 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread")
@@ -75,7 +115,7 @@ else()
75 message(STATUS "libpng not found. Some debugging features have been disabled.") 115 message(STATUS "libpng not found. Some debugging features have been disabled.")
76endif() 116endif()
77 117
78find_package(Boost 1.57.0) 118find_package(Boost 1.57.0 QUIET)
79if (Boost_FOUND) 119if (Boost_FOUND)
80 include_directories(${Boost_INCLUDE_DIRS}) 120 include_directories(${Boost_INCLUDE_DIRS})
81else() 121else()
@@ -90,59 +130,29 @@ find_package(OpenGL REQUIRED)
90include_directories(${OPENGL_INCLUDE_DIR}) 130include_directories(${OPENGL_INCLUDE_DIR})
91 131
92option(ENABLE_GLFW "Enable the GLFW frontend" ON) 132option(ENABLE_GLFW "Enable the GLFW frontend" ON)
133option(CITRA_USE_BUNDLED_GLFW "Download bundled GLFW binaries" OFF)
93if (ENABLE_GLFW) 134if (ENABLE_GLFW)
94 if (WIN32) 135 if (CITRA_USE_BUNDLED_GLFW)
95 # Detect toolchain and platform 136 # Detect toolchain and platform
96 if (MSVC) 137 if (MSVC14 AND ARCHITECTURE_x86_64)
97 if (CMAKE_SIZEOF_VOID_P EQUAL 8) 138 set(GLFW_VER "glfw-3.1.1-msvc2015_64")
98 set(TMP_ARCH "x64") 139 elseif (MSVC12 AND ARCHITECTURE_x86_64)
99 elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) 140 set(GLFW_VER "glfw-3.1.1-msvc2013_64")
100 set(TMP_ARCH "Win32")
101 else()
102 set(TMP_ARCH "UNKNOWN")
103 message(SEND_ERROR "Couldn't detect your compiler's architecture, you'll have to manually specify the GLFW library to use. (Try checking CMakeOutput.log to find out why.)")
104 endif()
105
106 if (MSVC11) # Visual C++ 2012
107 set(TMP_TOOLSET "v110")
108 elseif (MSVC12) # Visual C++ 2013
109 set(TMP_TOOLSET "v120")
110 else()
111 set(TMP_TOOLSET "UNSUPPORTED")
112 message(SEND_ERROR "We don't supply GLFW binaries for your version of MSVC, you might have to provide them yourself.")
113 endif()
114
115 set(TMP_TOOLSET "msvc_${TMP_TOOLSET}-${TMP_ARCH}")
116 else() 141 else()
117 # Assume mingw 142 message(FATAL_ERROR "No bundled GLFW binaries for your toolchain. Disable CITRA_USE_BUNDLED_GLFW and provide your own.")
118 if (CMAKE_SIZEOF_VOID_P EQUAL 8)
119 set(TMP_ARCH "x86_64")
120 elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
121 set(TMP_ARCH "i686")
122 else()
123 set(TMP_ARCH "UNKNOWN")
124 message(SEND_ERROR "Couldn't detect your compiler's architecture, you'll have to manually specify the GLFW library to use.")
125 endif()
126
127 set(TMP_TOOLSET "mingw-${TMP_ARCH}")
128 endif() 143 endif()
129 144
130 set(GLFW_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/externals/glfw-3.1.1.bin") 145 if (DEFINED GLFW_VER)
131 set(GLFW_INCLUDE_DIRS "${GLFW_PREFIX}/include" CACHE PATH "Path to GLFW3 headers") 146 download_bundled_external("glfw/" ${GLFW_VER} GLFW_PREFIX)
132 set(GLFW_LIBRARY_DIRS "${GLFW_PREFIX}/lib-${TMP_TOOLSET}" CACHE PATH "Path to GLFW3 libraries") 147 endif()
133
134 # Clean up after ourselves
135 unset(TMP_TOOLSET)
136 unset(TMP_ARCH)
137 148
149 set(GLFW_INCLUDE_DIRS "${GLFW_PREFIX}/include" CACHE PATH "Path to GLFW3 headers")
150 set(GLFW_LIBRARY_DIRS "${GLFW_PREFIX}/lib" CACHE PATH "Path to GLFW3 libraries")
138 set(GLFW_LIBRARIES glfw3) 151 set(GLFW_LIBRARIES glfw3)
139 else() 152 else()
140 find_package(PkgConfig REQUIRED) 153 find_package(PkgConfig REQUIRED)
141 pkg_search_module(GLFW REQUIRED glfw3) 154 pkg_search_module(GLFW REQUIRED glfw3)
142 endif() 155 endif()
143
144 include_directories(${GLFW_INCLUDE_DIRS})
145 link_directories(${GLFW_LIBRARY_DIRS})
146endif() 156endif()
147 157
148IF (APPLE) 158IF (APPLE)
@@ -167,22 +177,35 @@ ELSE()
167ENDIF (APPLE) 177ENDIF (APPLE)
168 178
169option(ENABLE_QT "Enable the Qt frontend" ON) 179option(ENABLE_QT "Enable the Qt frontend" ON)
180option(CITRA_USE_BUNDLED_QT "Download bundled Qt binaries" OFF)
170option(CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF) 181option(CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF)
171if (ENABLE_QT) 182if (ENABLE_QT)
172 # Set CMAKE_PREFIX_PATH if QTDIR is defined in the environment This allows CMake to 183 if (CITRA_USE_BUNDLED_QT)
173 # automatically find the Qt packages on Windows 184 if (MSVC14 AND ARCHITECTURE_x86_64)
174 if (DEFINED ENV{QTDIR}) 185 set(QT_VER qt-5.5-msvc2015_64)
175 list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}") 186 else()
187 message(FATAL_ERROR "No bundled Qt binaries for your toolchain. Disable CITRA_USE_BUNDLED_QT and provide your own.")
188 endif()
189
190 if (DEFINED QT_VER)
191 download_bundled_external("qt/" ${QT_VER} QT_PREFIX)
192 endif()
193
194 set(QT_PREFIX_HINT HINTS "${QT_PREFIX}")
195 else()
196 # Passing an empty HINTS seems to cause default system paths to get ignored in CMake 2.8 so
197 # make sure to not pass anything if we don't have one.
198 set(QT_PREFIX_HINT)
176 endif() 199 endif()
177 200
178 if (NOT CITRA_FORCE_QT4) 201 if (NOT CITRA_FORCE_QT4)
179 find_package(Qt5 COMPONENTS Widgets OpenGL) 202 find_package(Qt5 COMPONENTS Widgets OpenGL ${QT_PREFIX_HINT})
180 set(CITRA_QT_LIBS Qt5::Widgets Qt5::OpenGL) 203 set(CITRA_QT_LIBS Qt5::Widgets Qt5::OpenGL)
181 endif() 204 endif()
182 205
183 if (CITRA_FORCE_QT4 OR NOT Qt5_FOUND) 206 if (CITRA_FORCE_QT4 OR NOT Qt5_FOUND)
184 # Try to fallback to Qt4 207 # Try to fallback to Qt4
185 find_package(Qt4 REQUIRED COMPONENTS QtGui QtOpenGL) 208 find_package(Qt4 REQUIRED COMPONENTS QtGui QtOpenGL ${QT_PREFIX_HINT})
186 set(CITRA_QT_LIBS Qt4::QtGui Qt4::QtOpenGL) 209 set(CITRA_QT_LIBS Qt4::QtGui Qt4::QtOpenGL)
187 endif() 210 endif()
188endif() 211endif()
diff --git a/appveyor.yml b/appveyor.yml
index 5dc147639..6e073ece7 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -18,7 +18,7 @@ install:
18before_build: 18before_build:
19 - mkdir build 19 - mkdir build
20 - cd build 20 - cd build
21 - cmake -G "Visual Studio 12 Win64" .. 21 - cmake -G "Visual Studio 12 Win64" -DCITRA_USE_BUNDLED_GLFW=1 -DQt5_DIR=%QTDIR%/lib/cmake/Qt5 ..
22 - cd .. 22 - cd ..
23 23
24after_build: 24after_build:
diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt
index beb96bd30..e7f8a17f9 100644
--- a/src/citra/CMakeLists.txt
+++ b/src/citra/CMakeLists.txt
@@ -13,6 +13,9 @@ set(HEADERS
13 13
14create_directory_groups(${SRCS} ${HEADERS}) 14create_directory_groups(${SRCS} ${HEADERS})
15 15
16include_directories(${GLFW_INCLUDE_DIRS})
17link_directories(${GLFW_LIBRARY_DIRS})
18
16add_executable(citra ${SRCS} ${HEADERS}) 19add_executable(citra ${SRCS} ${HEADERS})
17target_link_libraries(citra core video_core common) 20target_link_libraries(citra core video_core common)
18target_link_libraries(citra ${GLFW_LIBRARIES} ${OPENGL_gl_LIBRARY} inih glad) 21target_link_libraries(citra ${GLFW_LIBRARIES} ${OPENGL_gl_LIBRARY} inih glad)