Files
eden/src/CMakeLists.txt
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

253 lines
9.6 KiB
CMake
Raw Normal View History

# SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
2025-07-30 20:59:28 +02:00
# SPDX-License-Identifier: GPL-3.0-or-later
2026-03-08 22:33:51 +01:00
2022-05-15 02:06:02 +02:00
# SPDX-FileCopyrightText: 2018 yuzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
2014-08-23 22:22:05 -03:00
# Enable modules to include each other's files
include_directories(.)
# Dynarmic
if ((ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64 OR ARCHITECTURE_riscv64) AND NOT YUZU_STATIC_ROOM)
add_subdirectory(dynarmic)
add_library(dynarmic::dynarmic ALIAS dynarmic)
endif()
# CMake seems to only define _DEBUG on Windows
set_property(DIRECTORY APPEND PROPERTY
COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:NDEBUG>)
if (YUZU_STATIC_BUILD)
add_compile_definitions(QT_STATICPLUGIN)
endif()
if (NIGHTLY_BUILD)
add_compile_definitions(NIGHTLY_BUILD)
endif()
# Set compilation flags
if (MSVC AND NOT CXX_CLANG)
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE)
# Silence "deprecation" warnings
add_compile_definitions(_CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_DEPRECATE _SCL_SECURE_NO_WARNINGS)
# Avoid windows.h junk
add_compile_definitions(NOMINMAX)
# Avoid windows.h from including some usually unused libs like winsocks.h, since this might cause some redefinition errors.
add_compile_definitions(WIN32_LEAN_AND_MEAN)
2023-11-07 02:13:15 +05:30
# Ensure that projects are built with Unicode support.
add_compile_definitions(UNICODE _UNICODE)
2023-09-02 21:45:06 +04:00
# /W4 - Level 4 warnings
# /MP - Multi-threaded compilation
# /Zm - Specifies the precompiled header memory allocation limit
# /Zo - Enhanced debug info for optimized builds
# /permissive- - Enables stricter C++ standards conformance checks
# /EHsc - C++-only exception handling semantics
# /utf-8 - Set source and execution character sets to UTF-8
2019-05-09 15:49:27 -04:00
# /volatile:iso - Use strict standards-compliant volatile semantics.
# /Zc:externConstexpr - Allow extern constexpr variables to have external linkage, like the standard mandates
# /Zc:inline - Let codegen omit inline functions in object files
# /Zc:preprocessor - Enable standards-conforming preprocessor
# /Zc:throwingNew - Let codegen assume `operator new` (without std::nothrow) will never return null
2021-10-28 20:43:46 -04:00
# /GT - Supports fiber safety for data allocated using static thread-local storage
add_compile_options(
/MP
/Zm200
/Zo
/permissive-
/EHsc
/std:c++20
/utf-8
2019-05-09 15:49:27 -04:00
/volatile:iso
/Zc:externConstexpr
/Zc:inline
/Zc:preprocessor
/Zc:throwingNew
/GT
# External headers diagnostics
/external:anglebrackets # Treats all headers included by #include <header>, where the header file is enclosed in angle brackets (< >), as external headers
2023-11-07 02:13:15 +05:30
/external:W0 # Sets the default warning level to 0 for external headers, effectively disabling warnings for them.
/we4062 # Enumerator 'identifier' in a switch of enum 'enumeration' is not handled
2021-07-03 05:51:31 -04:00
/we4189 # 'identifier': local variable is initialized but not referenced
/we4265 # 'class': class has virtual functions, but destructor is not virtual
/we4388 # 'expression': signed/unsigned mismatch
/we4389 # 'operator': signed/unsigned mismatch
2023-11-07 02:20:29 +05:30
/we4456 # Declaration of 'identifier' hides previous local declaration
/we4457 # Declaration of 'identifier' hides function parameter
/we4458 # Declaration of 'identifier' hides class member
/we4459 # Declaration of 'identifier' hides global declaration
2022-04-07 23:00:04 -04:00
/we4505 # 'function': unreferenced local function has been removed
/we4547 # 'operator': operator before comma has no effect; expected operator with side-effect
/we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'?
/we4555 # Expression has no effect; expected expression with side-effect
/we4826 # Conversion from 'type1' to 'type2' is sign-extended. This may cause unexpected runtime behavior.
/we5038 # data member 'member1' will be initialized after data member 'member2'
2022-10-21 02:34:07 -04:00
/we5233 # explicit lambda capture 'identifier' is not used
2022-04-07 23:00:04 -04:00
/we5245 # 'function': unreferenced function with internal linkage has been removed
2022-10-21 02:34:07 -04:00
/wd4100 # 'identifier': unreferenced formal parameter
/wd4324 # 'struct_name': structure was padded due to __declspec(align())
2023-11-07 02:20:29 +05:30
/wd4201 # nonstandard extension used : nameless struct/union
2023-09-11 17:25:21 -04:00
/wd4702 # unreachable code (when used with LTO)
$<$<CONFIG:Release>:/GS-> # No stack buffer overflow checks
/Gy # Enable function level linking
/GR- # Disable run time type information
)
if (NOT CXX_CLANG)
add_compile_options(
# Warnings
/W4
/WX-
)
endif()
2025-07-30 20:59:28 +02:00
if (ARCHITECTURE_x86_64)
add_compile_options(/QIntel-jcc-erratum)
endif()
2025-07-30 20:59:28 +02:00
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE)
else()
if (NOT MSVC)
add_compile_options(
$<$<COMPILE_LANGUAGE:C,CXX>:-fwrapv>
$<$<COMPILE_LANGUAGE:C,CXX>:-pipe>
# Disable RTTI (C++ only)
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>)
endif()
add_compile_options(
$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=all>
$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=extra>
$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=missing-declarations>
$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=shadow>
$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=unused>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-attributes>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-invalid-offsetof>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unused-parameter>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-missing-field-initializers>)
if (CXX_CLANG OR CXX_ICC OR CXX_APPLE) # Clang, AppleClang, or Intel C++
if (NOT MSVC)
add_compile_options(
$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=shadow-uncaptured-local>
$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=implicit-fallthrough>
$<$<COMPILE_LANGUAGE:C,CXX>:-Werror=type-limits>)
endif()
2025-07-30 20:59:28 +02:00
add_compile_options(
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-braced-scalar-init>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unused-private-field>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-nullability-completeness>)
2025-07-30 20:59:28 +02:00
endif()
2025-07-30 20:59:28 +02:00
if (ARCHITECTURE_x86_64)
add_compile_options(-mcx16)
2025-07-30 20:59:28 +02:00
endif()
2020-06-27 10:52:23 -04:00
if (APPLE AND CXX_CLANG)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-stdlib=libc++>)
2025-07-30 20:59:28 +02:00
endif()
2025-07-30 20:59:28 +02:00
# GCC bugs
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11" AND CXX_GCC)
2025-07-30 20:59:28 +02:00
# These diagnostics would be great if they worked, but are just completely broken
# and produce bogus errors on external libraries like fmt.
add_compile_options(
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-array-bounds>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-stringop-overread>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-stringop-overflow>)
2025-07-30 20:59:28 +02:00
endif()
2023-04-02 19:02:04 -04:00
2025-07-30 20:59:28 +02:00
# Set file offset size to 64 bits.
#
# On modern Unixes, this is typically already the case. The lone exception is
# glibc, which may default to 32 bits. glibc allows this to be configured
# by setting _FILE_OFFSET_BITS.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW)
add_compile_definitions(_FILE_OFFSET_BITS=64)
2025-07-30 20:59:28 +02:00
endif()
if (YUZU_STATIC_BUILD AND NOT APPLE)
add_compile_options(-static)
# yuzu-cmd requires us to explicitly link libpthread, libgcc, and libstdc++ as static
add_link_options(-Wl,-Bstatic -static -lpthread)
add_link_options(-static-libgcc -static-libstdc++)
endif()
2025-07-30 20:59:28 +02:00
if (MINGW)
add_compile_definitions(MINGW_HAS_SECURE_API)
# Only windows has this requirement
if (WIN32 AND ARCHITECTURE_x86_64)
add_compile_options("-msse4.1")
endif()
endif()
2019-06-30 13:29:52 +02:00
2025-07-30 20:59:28 +02:00
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR MINGW)
# GNU ar: Create thin archive files.
# Requires binutils-2.19 or later.
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcTP <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> qTP <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qcTP <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> qTP <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
endif()
2013-08-29 23:35:09 -04:00
add_subdirectory(common)
add_subdirectory(network)
if (YUZU_ROOM)
add_subdirectory(dedicated_room)
endif()
if (YUZU_ROOM_STANDALONE)
add_subdirectory(yuzu_room_standalone)
set_target_properties(yuzu-room PROPERTIES OUTPUT_NAME "eden-room")
endif()
if (YUZU_STATIC_ROOM)
return()
endif()
2013-08-29 23:35:09 -04:00
add_subdirectory(core)
add_subdirectory(audio_core)
2014-04-09 23:09:05 -04:00
add_subdirectory(video_core)
2024-01-04 20:37:43 -06:00
add_subdirectory(hid_core)
2017-01-21 11:53:03 +02:00
add_subdirectory(input_common)
add_subdirectory(frontend_common)
2021-01-09 03:30:07 -03:00
add_subdirectory(shader_recompiler)
2022-12-28 17:18:27 -05:00
2022-01-12 00:36:20 +01:00
if (YUZU_TESTS)
add_subdirectory(tests)
endif()
2026-02-25 02:49:47 +01:00
if (YUZU_CMD)
2018-01-11 19:21:20 -07:00
add_subdirectory(yuzu_cmd)
2025-04-01 18:35:37 +02:00
set_target_properties(yuzu-cmd PROPERTIES OUTPUT_NAME "eden-cli")
2014-08-23 22:22:05 -03:00
endif()
2014-08-23 22:22:05 -03:00
if (ENABLE_QT)
2025-09-15 17:21:18 +02:00
add_subdirectory(qt_common)
2018-01-11 19:21:20 -07:00
add_subdirectory(yuzu)
2017-07-09 17:52:18 -04:00
endif()
2018-09-16 20:05:51 +02:00
if (ENABLE_WEB_SERVICE)
add_subdirectory(web_service)
endif()
2022-12-17 23:27:18 -08:00
if (ANDROID)
add_subdirectory(android/app/src/main/jni)
target_include_directories(yuzu-android PRIVATE android/app/src/main)
endif()
include(GenerateDepHashes)