diff options
Diffstat (limited to 'CMakeLists.txt')
| -rw-r--r-- | CMakeLists.txt | 270 |
1 files changed, 149 insertions, 121 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1d13dc74e..b2fbe8806 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | # SPDX-FileCopyrightText: 2018 yuzu Emulator Project | 1 | # SPDX-FileCopyrightText: 2018 yuzu Emulator Project |
| 2 | # SPDX-License-Identifier: GPL-2.0-or-later | 2 | # SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | cmake_minimum_required(VERSION 3.15) | 4 | cmake_minimum_required(VERSION 3.22) |
| 5 | 5 | ||
| 6 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") | 6 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") |
| 7 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules") | 7 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules") |
| @@ -19,6 +19,9 @@ CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" ON | |||
| 19 | CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ON "ENABLE_SDL2;NOT MSVC" OFF) | 19 | CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ON "ENABLE_SDL2;NOT MSVC" OFF) |
| 20 | 20 | ||
| 21 | option(ENABLE_QT "Enable the Qt frontend" ON) | 21 | option(ENABLE_QT "Enable the Qt frontend" ON) |
| 22 | option(ENABLE_QT6 "Allow usage of Qt6 to be attempted" OFF) | ||
| 23 | set(QT6_LOCATION "" CACHE PATH "Additional Location to search for Qt6 libraries like C:/Qt/6.3.1/msvc2019_64/") | ||
| 24 | |||
| 22 | option(ENABLE_QT_TRANSLATION "Enable translations for the Qt frontend" OFF) | 25 | option(ENABLE_QT_TRANSLATION "Enable translations for the Qt frontend" OFF) |
| 23 | CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" "${MSVC}" "ENABLE_QT" OFF) | 26 | CMAKE_DEPENDENT_OPTION(YUZU_USE_BUNDLED_QT "Download bundled Qt binaries" "${MSVC}" "ENABLE_QT" OFF) |
| 24 | 27 | ||
| @@ -28,6 +31,8 @@ option(YUZU_USE_BUNDLED_LIBUSB "Compile bundled libusb" OFF) | |||
| 28 | 31 | ||
| 29 | option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" "${WIN32}") | 32 | option(YUZU_USE_BUNDLED_FFMPEG "Download/Build bundled FFmpeg" "${WIN32}") |
| 30 | 33 | ||
| 34 | option(YUZU_USE_QT_MULTIMEDIA "Use QtMultimedia for Camera" OFF) | ||
| 35 | |||
| 31 | option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF) | 36 | option(YUZU_USE_QT_WEB_ENGINE "Use QtWebEngine for web applet implementation" OFF) |
| 32 | 37 | ||
| 33 | option(ENABLE_CUBEB "Enables the cubeb audio backend" ON) | 38 | option(ENABLE_CUBEB "Enables the cubeb audio backend" ON) |
| @@ -213,128 +218,166 @@ if (MINGW) | |||
| 213 | find_library(MSWSOCK_LIBRARY mswsock REQUIRED) | 218 | find_library(MSWSOCK_LIBRARY mswsock REQUIRED) |
| 214 | endif() | 219 | endif() |
| 215 | 220 | ||
| 221 | # Please consider this as a stub | ||
| 222 | if(ENABLE_QT6 AND Qt6_LOCATION) | ||
| 223 | list(APPEND CMAKE_PREFIX_PATH "${Qt6_LOCATION}") | ||
| 224 | endif() | ||
| 225 | |||
| 226 | function(set_yuzu_qt_components) | ||
| 227 | # Best practice is to ask for all components at once, so they are from the same version | ||
| 228 | set(YUZU_QT_COMPONENTS2 Core Widgets Concurrent) | ||
| 229 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | ||
| 230 | list(APPEND YUZU_QT_COMPONENTS2 DBus) | ||
| 231 | endif() | ||
| 232 | if (YUZU_USE_QT_MULTIMEDIA) | ||
| 233 | list(APPEND YUZU_QT_COMPONENTS2 Multimedia) | ||
| 234 | endif() | ||
| 235 | if (YUZU_USE_QT_WEB_ENGINE) | ||
| 236 | list(APPEND YUZU_QT_COMPONENTS2 WebEngineCore WebEngineWidgets) | ||
| 237 | endif() | ||
| 238 | if (ENABLE_QT_TRANSLATION) | ||
| 239 | list(APPEND YUZU_QT_COMPONENTS2 LinguistTools) | ||
| 240 | endif() | ||
| 241 | set(YUZU_QT_COMPONENTS ${YUZU_QT_COMPONENTS2} PARENT_SCOPE) | ||
| 242 | endfunction(set_yuzu_qt_components) | ||
| 243 | |||
| 216 | # Qt5 requires that we find components, so it doesn't fit our pretty little find package function | 244 | # Qt5 requires that we find components, so it doesn't fit our pretty little find package function |
| 217 | if(ENABLE_QT) | 245 | if(ENABLE_QT) |
| 218 | set(QT_VERSION 5.15) | 246 | set(QT_VERSION 5.15) |
| 247 | # These are used to specify minimum versions | ||
| 248 | set(QT5_VERSION 5.15) | ||
| 249 | set(QT6_VERSION 6.3.1) | ||
| 219 | 250 | ||
| 220 | # Check for system Qt on Linux, fallback to bundled Qt | 251 | set_yuzu_qt_components() |
| 221 | if (UNIX AND NOT APPLE) | 252 | if (ENABLE_QT6) |
| 222 | if (NOT YUZU_USE_BUNDLED_QT) | 253 | find_package(Qt6 ${QT6_VERSION} COMPONENTS ${YUZU_QT_COMPONENTS}) |
| 223 | find_package(Qt5 ${QT_VERSION} COMPONENTS Widgets DBus Multimedia) | 254 | endif() |
| 224 | endif() | 255 | if (Qt6_FOUND) |
| 225 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND (NOT Qt5_FOUND OR YUZU_USE_BUNDLED_QT)) | 256 | message(STATUS "yuzu/CMakeLists.txt: Qt6Widgets_VERSION ${Qt6Widgets_VERSION}, setting QT_VERSION") |
| 226 | # Check for dependencies, then enable bundled Qt download | 257 | set(QT_VERSION ${Qt6Widgets_VERSION}) |
| 227 | 258 | set(QT_MAJOR_VERSION 6) | |
| 228 | # Check that the system GLIBCXX version is compatible | 259 | # Qt6 sets cxx_std_17 and we need to undo that |
| 229 | find_program(OBJDUMP objdump) | 260 | set_target_properties(Qt6::Platform PROPERTIES INTERFACE_COMPILE_FEATURES "") |
| 230 | if ("${OBJDUMP}" STREQUAL "OBJDUMP-NOTFOUND") | 261 | else() |
| 231 | message(FATAL_ERROR "Required program `objdump` not found.") | 262 | message(STATUS "yuzu/CMakeLists.txt: Qt6 not found/not selected, trying for Qt5") |
| 232 | endif() | 263 | # When Qt6 partially found, need this set to use Qt5 when not specifying version |
| 233 | find_library(LIBSTDCXX libstdc++.so.6) | 264 | set(QT_DEFAULT_MAJOR_VERSION 5) |
| 234 | execute_process( | 265 | set(QT_MAJOR_VERSION 5) |
| 235 | COMMAND | 266 | |
| 236 | ${OBJDUMP} -T ${LIBSTDCXX} | 267 | set(YUZU_USE_QT_MULTIMEDIA ON) |
| 237 | COMMAND | 268 | # Check for system Qt on Linux, fallback to bundled Qt |
| 238 | grep GLIBCXX_3.4.28 | 269 | if (UNIX AND NOT APPLE) |
| 239 | COMMAND | 270 | if (NOT YUZU_USE_BUNDLED_QT) |
| 240 | sed "s/[0-9a-f]*.* //" | 271 | find_package(Qt5 ${QT5_VERSION} COMPONENTS Widgets DBus Multimedia) |
| 241 | COMMAND | ||
| 242 | sed "s/ .*//" | ||
| 243 | COMMAND | ||
| 244 | sort -u | ||
| 245 | OUTPUT_VARIABLE | ||
| 246 | GLIBCXX_MET | ||
| 247 | ) | ||
| 248 | if (NOT GLIBCXX_MET) | ||
| 249 | message(FATAL_ERROR "Qt too old or not found, and bundled Qt package is not \ | ||
| 250 | compatible with this system. Either install Qt ${QT_VERSION}, or provide the path \ | ||
| 251 | to Qt by setting the variable Qt5_ROOT.") | ||
| 252 | endif() | 272 | endif() |
| 273 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND (NOT Qt5_FOUND OR YUZU_USE_BUNDLED_QT)) | ||
| 274 | # Check for dependencies, then enable bundled Qt download | ||
| 253 | 275 | ||
| 254 | # Check for headers | 276 | # Check that the system GLIBCXX version is compatible |
| 255 | find_package(PkgConfig REQUIRED) | 277 | find_program(OBJDUMP objdump) |
| 256 | pkg_check_modules(QT_DEP_GLU QUIET glu>=9.0.0) | 278 | if (NOT OBJDUMP) |
| 257 | if (NOT QT_DEP_GLU_FOUND) | 279 | message(FATAL_ERROR "Required program `objdump` not found.") |
| 258 | message(FATAL_ERROR "Qt bundled pacakge dependency `glu` not found. \ | 280 | endif() |
| 259 | Perhaps `libglu1-mesa-dev` needs to be installed?") | 281 | find_library(LIBSTDCXX libstdc++.so.6) |
| 260 | endif() | 282 | execute_process( |
| 261 | pkg_check_modules(QT_DEP_MESA QUIET dri>=20.0.8) | 283 | COMMAND |
| 262 | if (NOT QT_DEP_MESA_FOUND) | 284 | ${OBJDUMP} -T ${LIBSTDCXX} |
| 263 | message(FATAL_ERROR "Qt bundled pacakge dependency `dri` not found. \ | 285 | COMMAND |
| 264 | Perhaps `mesa-common-dev` needs to be installed?") | 286 | grep GLIBCXX_3.4.28 |
| 265 | endif() | 287 | COMMAND |
| 288 | sed "s/[0-9a-f]*.* //" | ||
| 289 | COMMAND | ||
| 290 | sed "s/ .*//" | ||
| 291 | COMMAND | ||
| 292 | sort -u | ||
| 293 | OUTPUT_VARIABLE | ||
| 294 | GLIBCXX_MET | ||
| 295 | ) | ||
| 296 | if (NOT GLIBCXX_MET) | ||
| 297 | message(FATAL_ERROR "Qt too old or not found, and bundled Qt package is not \ | ||
| 298 | compatible with this system. Either install Qt ${QT_VERSION}, or provide the path \ | ||
| 299 | to Qt by setting the variable Qt5_ROOT.") | ||
| 300 | endif() | ||
| 266 | 301 | ||
| 267 | # Check for X libraries | 302 | # Check for headers |
| 268 | set(BUNDLED_QT_REQUIREMENTS | 303 | find_package(PkgConfig REQUIRED) |
| 269 | libxcb-icccm.so.4 | 304 | pkg_check_modules(QT_DEP_GLU QUIET glu>=9.0.0) |
| 270 | libxcb-image.so.0 | 305 | if (NOT QT_DEP_GLU_FOUND) |
| 271 | libxcb-keysyms.so.1 | 306 | message(FATAL_ERROR "Qt bundled pacakge dependency `glu` not found. \ |
| 272 | libxcb-randr.so.0 | 307 | Perhaps `libglu1-mesa-dev` needs to be installed?") |
| 273 | libxcb-render-util.so.0 | 308 | endif() |
| 274 | libxcb-render.so.0 | 309 | pkg_check_modules(QT_DEP_MESA QUIET dri>=20.0.8) |
| 275 | libxcb-shape.so.0 | 310 | if (NOT QT_DEP_MESA_FOUND) |
| 276 | libxcb-shm.so.0 | 311 | message(FATAL_ERROR "Qt bundled pacakge dependency `dri` not found. \ |
| 277 | libxcb-sync.so.1 | 312 | Perhaps `mesa-common-dev` needs to be installed?") |
| 278 | libxcb-xfixes.so.0 | ||
| 279 | libxcb-xinerama.so.0 | ||
| 280 | libxcb-xkb.so.1 | ||
| 281 | libxcb.so.1 | ||
| 282 | libxkbcommon-x11.so.0 | ||
| 283 | libxkbcommon.so.0 | ||
| 284 | ) | ||
| 285 | set(UNRESOLVED_QT_DEPS "") | ||
| 286 | foreach (REQUIREMENT ${BUNDLED_QT_REQUIREMENTS}) | ||
| 287 | find_library(BUNDLED_QT_${REQUIREMENT} ${REQUIREMENT}) | ||
| 288 | if ("${BUNDLED_QT_${REQUIREMENT}}" STREQUAL "BUNDLED_QT_${REQUIREMENT}-NOTFOUND") | ||
| 289 | set(UNRESOLVED_QT_DEPS ${UNRESOLVED_QT_DEPS} ${REQUIREMENT}) | ||
| 290 | endif() | 313 | endif() |
| 291 | unset(BUNDLED_QT_${REQUIREMENT}) | ||
| 292 | endforeach() | ||
| 293 | unset(BUNDLED_QT_REQUIREMENTS) | ||
| 294 | 314 | ||
| 295 | if (NOT "${UNRESOLVED_QT_DEPS}" STREQUAL "") | 315 | # Check for X libraries |
| 296 | message(FATAL_ERROR "Bundled Qt package missing required dependencies: ${UNRESOLVED_QT_DEPS}") | 316 | set(BUNDLED_QT_REQUIREMENTS |
| 297 | endif() | 317 | libxcb-icccm.so.4 |
| 318 | libxcb-image.so.0 | ||
| 319 | libxcb-keysyms.so.1 | ||
| 320 | libxcb-randr.so.0 | ||
| 321 | libxcb-render-util.so.0 | ||
| 322 | libxcb-render.so.0 | ||
| 323 | libxcb-shape.so.0 | ||
| 324 | libxcb-shm.so.0 | ||
| 325 | libxcb-sync.so.1 | ||
| 326 | libxcb-xfixes.so.0 | ||
| 327 | libxcb-xinerama.so.0 | ||
| 328 | libxcb-xkb.so.1 | ||
| 329 | libxcb.so.1 | ||
| 330 | libxkbcommon-x11.so.0 | ||
| 331 | libxkbcommon.so.0 | ||
| 332 | ) | ||
| 333 | set(UNRESOLVED_QT_DEPS "") | ||
| 334 | foreach (REQUIREMENT ${BUNDLED_QT_REQUIREMENTS}) | ||
| 335 | find_library(BUNDLED_QT_${REQUIREMENT} ${REQUIREMENT}) | ||
| 336 | if (NOT BUNDLED_QT_${REQUIREMENT}) | ||
| 337 | set(UNRESOLVED_QT_DEPS ${UNRESOLVED_QT_DEPS} ${REQUIREMENT}) | ||
| 338 | endif() | ||
| 339 | unset(BUNDLED_QT_${REQUIREMENT}) | ||
| 340 | endforeach() | ||
| 341 | unset(BUNDLED_QT_REQUIREMENTS) | ||
| 342 | |||
| 343 | if (NOT "${UNRESOLVED_QT_DEPS}" STREQUAL "") | ||
| 344 | message(FATAL_ERROR "Bundled Qt package missing required dependencies: ${UNRESOLVED_QT_DEPS}") | ||
| 345 | endif() | ||
| 298 | 346 | ||
| 299 | set(YUZU_USE_BUNDLED_QT ON CACHE BOOL "Download bundled Qt" FORCE) | 347 | set(YUZU_USE_BUNDLED_QT ON CACHE BOOL "Download bundled Qt" FORCE) |
| 300 | endif() | 348 | endif() |
| 301 | if (YUZU_USE_BUNDLED_QT) | 349 | if (YUZU_USE_BUNDLED_QT) |
| 302 | # Binary package currently does not support Qt webengine, so make sure it's disabled | 350 | # Binary package currently does not support Qt webengine, so make sure it's disabled |
| 303 | set(YUZU_USE_QT_WEB_ENGINE OFF CACHE BOOL "Use Qt Webengine" FORCE) | 351 | set(YUZU_USE_QT_WEB_ENGINE OFF CACHE BOOL "Use Qt Webengine" FORCE) |
| 352 | endif() | ||
| 304 | endif() | 353 | endif() |
| 305 | endif() | ||
| 306 | 354 | ||
| 307 | set(YUZU_QT_NO_CMAKE_SYSTEM_PATH) | 355 | set(YUZU_QT_NO_CMAKE_SYSTEM_PATH) |
| 308 | 356 | ||
| 309 | if(YUZU_USE_BUNDLED_QT) | 357 | if(YUZU_USE_BUNDLED_QT) |
| 310 | if ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND ARCHITECTURE_x86_64) | 358 | if ((MSVC_VERSION GREATER_EQUAL 1920 AND MSVC_VERSION LESS 1940) AND ARCHITECTURE_x86_64) |
| 311 | set(QT_BUILD qt-5.15.2-msvc2019_64) | 359 | set(QT_BUILD qt-5.15.2-msvc2019_64) |
| 312 | elseif ((${CMAKE_SYSTEM_NAME} STREQUAL "Linux") AND NOT MINGW AND ARCHITECTURE_x86_64) | 360 | elseif ((${CMAKE_SYSTEM_NAME} STREQUAL "Linux") AND NOT MINGW AND ARCHITECTURE_x86_64) |
| 313 | set(QT_BUILD qt5_5_15_2) | 361 | set(QT_BUILD qt5_5_15_2) |
| 314 | else() | 362 | else() |
| 315 | message(FATAL_ERROR "No bundled Qt binaries for your toolchain. Disable YUZU_USE_BUNDLED_QT and provide your own.") | 363 | message(FATAL_ERROR "No bundled Qt binaries for your toolchain. Disable YUZU_USE_BUNDLED_QT and provide your own.") |
| 316 | endif() | 364 | endif() |
| 317 | 365 | ||
| 318 | if (DEFINED QT_BUILD) | 366 | if (DEFINED QT_BUILD) |
| 319 | download_bundled_external("qt/" ${QT_BUILD} QT_PREFIX) | 367 | download_bundled_external("qt/" ${QT_BUILD} QT_PREFIX) |
| 320 | endif() | 368 | endif() |
| 321 | 369 | ||
| 322 | set(QT_PREFIX_HINT HINTS "${QT_PREFIX}") | 370 | set(QT_PREFIX_HINT HINTS "${QT_PREFIX}") |
| 323 | 371 | ||
| 324 | set(YUZU_QT_NO_CMAKE_SYSTEM_PATH "NO_CMAKE_SYSTEM_PATH") | 372 | set(YUZU_QT_NO_CMAKE_SYSTEM_PATH "NO_CMAKE_SYSTEM_PATH") |
| 325 | endif() | 373 | # Binary package for Qt5 has Qt Multimedia |
| 326 | if (UNIX AND NOT APPLE AND YUZU_USE_BUNDLED_QT) | 374 | set(YUZU_USE_QT_MULTIMEDIA ON CACHE BOOL "Use Qt Multimedia" FORCE) |
| 327 | find_package(Qt5 ${QT_VERSION} REQUIRED COMPONENTS Widgets Concurrent Multimedia DBus ${QT_PREFIX_HINT} ${YUZU_QT_NO_CMAKE_SYSTEM_PATH}) | 375 | endif() |
| 328 | else() | ||
| 329 | find_package(Qt5 ${QT_VERSION} REQUIRED COMPONENTS Widgets Concurrent Multimedia ${QT_PREFIX_HINT} ${YUZU_QT_NO_CMAKE_SYSTEM_PATH}) | ||
| 330 | endif() | ||
| 331 | if (YUZU_USE_QT_WEB_ENGINE) | ||
| 332 | find_package(Qt5 REQUIRED COMPONENTS WebEngineCore WebEngineWidgets) | ||
| 333 | endif() | ||
| 334 | 376 | ||
| 335 | if (ENABLE_QT_TRANSLATION) | 377 | set_yuzu_qt_components() |
| 336 | find_package(Qt5 REQUIRED COMPONENTS LinguistTools ${QT_PREFIX_HINT}) | 378 | find_package(Qt5 ${QT5_VERSION} COMPONENTS ${YUZU_QT_COMPONENTS} ${QT_PREFIX_HINT} ${YUZU_QT_NO_CMAKE_SYSTEM_PATH}) |
| 337 | endif() | 379 | endif() |
| 380 | |||
| 338 | endif() | 381 | endif() |
| 339 | 382 | ||
| 340 | # find SDL2 exports a bunch of variables that are needed, so its easier to do this outside of the yuzu_find_package | 383 | # find SDL2 exports a bunch of variables that are needed, so its easier to do this outside of the yuzu_find_package |
| @@ -415,22 +458,7 @@ if (UNIX AND NOT APPLE) | |||
| 415 | endif() | 458 | endif() |
| 416 | if (NOT YUZU_USE_BUNDLED_FFMPEG) | 459 | if (NOT YUZU_USE_BUNDLED_FFMPEG) |
| 417 | # Use system installed FFmpeg | 460 | # Use system installed FFmpeg |
| 418 | find_package(FFmpeg 4.3 QUIET COMPONENTS ${FFmpeg_COMPONENTS}) | 461 | find_package(FFmpeg 4.3 REQUIRED QUIET COMPONENTS ${FFmpeg_COMPONENTS}) |
| 419 | |||
| 420 | if (FFmpeg_FOUND) | ||
| 421 | # Overwrite aggregate defines from FFmpeg module to avoid over-linking libraries. | ||
| 422 | # Prevents shipping too many libraries with the AppImage. | ||
| 423 | set(FFmpeg_LIBRARIES "") | ||
| 424 | set(FFmpeg_INCLUDE_DIR "") | ||
| 425 | |||
| 426 | foreach(COMPONENT ${FFmpeg_COMPONENTS}) | ||
| 427 | set(FFmpeg_LIBRARIES ${FFmpeg_LIBRARIES} ${FFmpeg_LIBRARY_${COMPONENT}} CACHE PATH "Paths to FFmpeg libraries" FORCE) | ||
| 428 | set(FFmpeg_INCLUDE_DIR ${FFmpeg_INCLUDE_DIR} ${FFmpeg_INCLUDE_${COMPONENT}} CACHE PATH "Path to FFmpeg headers" FORCE) | ||
| 429 | endforeach() | ||
| 430 | else() | ||
| 431 | message(WARNING "FFmpeg not found or too old, falling back to externals") | ||
| 432 | set(YUZU_USE_BUNDLED_FFMPEG ON) | ||
| 433 | endif() | ||
| 434 | endif() | 462 | endif() |
| 435 | 463 | ||
| 436 | # Prefer the -pthread flag on Linux. | 464 | # Prefer the -pthread flag on Linux. |