summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-08-28 16:57:08 -0300
committerGravatar Yuri Kunde Schlesner2015-09-08 19:35:12 -0300
commit078969bdd09204fa2ce7b36960b2134a53b9ce41 (patch)
treecd35d535ad8223a85886fd9c80fc77b300f6956c
parentCMake: Fix architecture detection on MSVC (diff)
downloadyuzu-078969bdd09204fa2ce7b36960b2134a53b9ce41.tar.gz
yuzu-078969bdd09204fa2ce7b36960b2134a53b9ce41.tar.xz
yuzu-078969bdd09204fa2ce7b36960b2134a53b9ce41.zip
CMake: Add option to download Qt and GLFW binaries over HTTP
-rw-r--r--CMakeLists.txt86
-rw-r--r--appveyor.yml2
-rw-r--r--src/citra/CMakeLists.txt3
3 files changed, 45 insertions, 46 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 967e7ff24..f7844eb38 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,6 +2,20 @@
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/yuriks/citra-depends/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
5include(CheckSymbolExists) 19include(CheckSymbolExists)
6function(detect_architecture symbol arch) 20function(detect_architecture symbol arch)
7 if (NOT DEFINED ARCHITECTURE) 21 if (NOT DEFINED ARCHITECTURE)
@@ -116,59 +130,29 @@ find_package(OpenGL REQUIRED)
116include_directories(${OPENGL_INCLUDE_DIR}) 130include_directories(${OPENGL_INCLUDE_DIR})
117 131
118option(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)
119if (ENABLE_GLFW) 134if (ENABLE_GLFW)
120 if (WIN32) 135 if (CITRA_USE_BUNDLED_GLFW)
121 # Detect toolchain and platform 136 # Detect toolchain and platform
122 if (MSVC) 137 if (MSVC14 AND ARCHITECTURE_x86_64)
123 if (CMAKE_SIZEOF_VOID_P EQUAL 8) 138 set(GLFW_VER "glfw-3.1.1-msvc2015_64")
124 set(TMP_ARCH "x64") 139 elseif (MSVC12 AND ARCHITECTURE_x86_64)
125 elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) 140 set(GLFW_VER "glfw-3.1.1-msvc2013_64")
126 set(TMP_ARCH "Win32")
127 else()
128 set(TMP_ARCH "UNKNOWN")
129 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.)")
130 endif()
131
132 if (MSVC11) # Visual C++ 2012
133 set(TMP_TOOLSET "v110")
134 elseif (MSVC12) # Visual C++ 2013
135 set(TMP_TOOLSET "v120")
136 else()
137 set(TMP_TOOLSET "UNSUPPORTED")
138 message(SEND_ERROR "We don't supply GLFW binaries for your version of MSVC, you might have to provide them yourself.")
139 endif()
140
141 set(TMP_TOOLSET "msvc_${TMP_TOOLSET}-${TMP_ARCH}")
142 else() 141 else()
143 # Assume mingw 142 message(FATAL_ERROR "No bundled GLFW binaries for your toolchain. Disable CITRA_USE_BUNDLED_GLFW and provide your own.")
144 if (CMAKE_SIZEOF_VOID_P EQUAL 8)
145 set(TMP_ARCH "x86_64")
146 elseif (CMAKE_SIZEOF_VOID_P EQUAL 4)
147 set(TMP_ARCH "i686")
148 else()
149 set(TMP_ARCH "UNKNOWN")
150 message(SEND_ERROR "Couldn't detect your compiler's architecture, you'll have to manually specify the GLFW library to use.")
151 endif()
152
153 set(TMP_TOOLSET "mingw-${TMP_ARCH}")
154 endif() 143 endif()
155 144
156 set(GLFW_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/externals/glfw-3.1.1.bin") 145 if (DEFINED GLFW_VER)
157 set(GLFW_INCLUDE_DIRS "${GLFW_PREFIX}/include" CACHE PATH "Path to GLFW3 headers") 146 download_bundled_external("glfw/" ${GLFW_VER} GLFW_PREFIX)
158 set(GLFW_LIBRARY_DIRS "${GLFW_PREFIX}/lib-${TMP_TOOLSET}" CACHE PATH "Path to GLFW3 libraries") 147 endif()
159
160 # Clean up after ourselves
161 unset(TMP_TOOLSET)
162 unset(TMP_ARCH)
163 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")
164 set(GLFW_LIBRARIES glfw3) 151 set(GLFW_LIBRARIES glfw3)
165 else() 152 else()
166 find_package(PkgConfig REQUIRED) 153 find_package(PkgConfig REQUIRED)
167 pkg_search_module(GLFW REQUIRED glfw3) 154 pkg_search_module(GLFW REQUIRED glfw3)
168 endif() 155 endif()
169
170 include_directories(${GLFW_INCLUDE_DIRS})
171 link_directories(${GLFW_LIBRARY_DIRS})
172endif() 156endif()
173 157
174IF (APPLE) 158IF (APPLE)
@@ -193,11 +177,23 @@ ELSE()
193ENDIF (APPLE) 177ENDIF (APPLE)
194 178
195option(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)
196option(CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF) 181option(CITRA_FORCE_QT4 "Use Qt4 even if Qt5 is available." OFF)
197if (ENABLE_QT) 182if (ENABLE_QT)
198 # Set CMAKE_PREFIX_PATH if QTDIR is defined in the environment This allows CMake to 183 if (CITRA_USE_BUNDLED_QT)
199 # automatically find the Qt packages on Windows 184 if (MSVC14 AND ARCHITECTURE_x86_64)
200 if (DEFINED ENV{QTDIR}) 185 set(QT_VER qt-5.5-msvc2015_64)
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 list(APPEND CMAKE_PREFIX_PATH "${QT_PREFIX}")
193 endif()
194 elseif (DEFINED ENV{QTDIR})
195 # Set CMAKE_PREFIX_PATH if QTDIR is defined in the environment This allows CMake to
196 # automatically find the Qt packages on Windows
201 list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}") 197 list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}")
202 endif() 198 endif()
203 199
diff --git a/appveyor.yml b/appveyor.yml
index 5dc147639..4d6f53f96 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 ..
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)