VERY experimental Nintendo Switch 2 emulator
C++
CMake: Use precompiled headers
ameerjbbf3e7f313e9
diff --git a/CMakeLists.txt b/CMakeLists.txtindex 2d2761ec19..901a04857c 100644--- a/CMakeLists.txt+++ b/CMakeLists.txt@@ -43,6 +43,8 @@ option(YUZU_USE_BUNDLED_OPUS "Compile bundled opus" ON)option(YUZU_TESTS "Compile tests" ON)+option(YUZU_USE_PRECOMPILED_HEADERS "Use precompiled headers" ON)+CMAKE_DEPENDENT_OPTION(YUZU_CRASH_DUMPS "Compile Windows crash dump (Minidump) support" OFF "WIN32" OFF)option(YUZU_USE_BUNDLED_VCPKG "Use vcpkg for yuzu dependencies" "${MSVC}")diff --git a/src/CMakeLists.txt b/src/CMakeLists.txtindex 0ac3d254e5..25703e9d50 100644--- a/src/CMakeLists.txt+++ b/src/CMakeLists.txt@@ -82,8 +82,9 @@ if (MSVC)/wd4324 # 'struct_name': structure was padded due to __declspec(align()))- if (USE_CCACHE)+ if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS)# when caching, we need to use /Z7 to downgrade debug info to use an older but more cachable format+ # Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21add_compile_options(/Z7)else()add_compile_options(/Zi)@@ -151,6 +152,10 @@ else()endif()endif()+if (YUZU_USE_PRECOMPILED_HEADERS)+ set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON)+endif()+add_subdirectory(common)add_subdirectory(core)add_subdirectory(audio_core)diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txtindex 8e3a8f5a8c..0a8c4280ce 100644--- a/src/audio_core/CMakeLists.txt+++ b/src/audio_core/CMakeLists.txt@@ -31,6 +31,7 @@ add_library(audio_core STATICout/audio_out.hout/audio_out_system.cppout/audio_out_system.h+ precompiled_headers.hrenderer/adsp/adsp.cpprenderer/adsp/adsp.hrenderer/adsp/audio_renderer.cpp@@ -229,3 +230,7 @@ if(ENABLE_SDL2)target_link_libraries(audio_core PRIVATE SDL2)target_compile_definitions(audio_core PRIVATE HAVE_SDL2)endif()++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(audio_core PRIVATE precompiled_headers.h)+endif()diff --git a/src/audio_core/precompiled_headers.h b/src/audio_core/precompiled_headers.hnew file mode 100644index 0000000000..5f81bef98c--- /dev/null+++ b/src/audio_core/precompiled_headers.h@@ -0,0 +1,12 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <fmt/format.h>++#include "common/assert.h"diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txtindex b7c15c1919..25fe5f56fa 100644--- a/src/common/CMakeLists.txt+++ b/src/common/CMakeLists.txt@@ -95,6 +95,7 @@ add_library(common STATICparam_package.hparent_of_member.hpoint.h+ precompiled_headers.hquaternion.hreader_writer_queue.hring_buffer.h@@ -183,3 +184,8 @@ else()target_link_libraries(common PRIVATE$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>)endif()++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(common PRIVATE precompiled_headers.h)+ set(CMAKE_PCH_INSTANTIATE_TEMPLATES ON)+endif()diff --git a/src/common/precompiled_headers.h b/src/common/precompiled_headers.hnew file mode 100644index 0000000000..5f81bef98c--- /dev/null+++ b/src/common/precompiled_headers.h@@ -0,0 +1,12 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <fmt/format.h>++#include "common/assert.h"diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex 5629980d99..6530d3c602 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -771,6 +771,7 @@ add_library(core STATICmemory.hperf_stats.cppperf_stats.h+ precompiled_headers.hreporter.cppreporter.htelemetry_session.cpp@@ -825,3 +826,7 @@ if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64))target_link_libraries(core PRIVATE dynarmic)endif()++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(core PRIVATE precompiled_headers.h)+endif()diff --git a/src/core/precompiled_headers.h b/src/core/precompiled_headers.hnew file mode 100644index 0000000000..d224877ea9--- /dev/null+++ b/src/core/precompiled_headers.h@@ -0,0 +1,14 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <boost/container/flat_map.hpp> // used by service.h which is heavily included+#include <boost/intrusive/rbtree.hpp> // used by k_auto_object.h which is heavily included+#include <fmt/format.h>++#include "common/assert.h"diff --git a/src/dedicated_room/CMakeLists.txt b/src/dedicated_room/CMakeLists.txtindex 2d9731f193..5bbe1d4b5d 100644--- a/src/dedicated_room/CMakeLists.txt+++ b/src/dedicated_room/CMakeLists.txt@@ -4,6 +4,7 @@set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)add_executable(yuzu-room+ precompiled_headers.hyuzu_room.cppyuzu_room.rc)@@ -25,3 +26,7 @@ target_link_libraries(yuzu-room PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)if(UNIX AND NOT APPLE)install(TARGETS yuzu-room)endif()++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(yuzu-room PRIVATE precompiled_headers.h)+endif()diff --git a/src/dedicated_room/precompiled_headers.h b/src/dedicated_room/precompiled_headers.hnew file mode 100644index 0000000000..5f81bef98c--- /dev/null+++ b/src/dedicated_room/precompiled_headers.h@@ -0,0 +1,12 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <fmt/format.h>++#include "common/assert.h"diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txtindex cc6f0ffc0c..77bfe4b581 100644--- a/src/input_common/CMakeLists.txt+++ b/src/input_common/CMakeLists.txt@@ -34,6 +34,7 @@ add_library(input_common STATICinput_poller.hmain.cppmain.h+ precompiled_headers.h)if (MSVC)@@ -63,3 +64,7 @@ target_link_libraries(input_common PRIVATE usb)create_target_directory_groups(input_common)target_link_libraries(input_common PUBLIC core PRIVATE common Boost::boost)++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(input_common PRIVATE precompiled_headers.h)+endif()diff --git a/src/input_common/precompiled_headers.h b/src/input_common/precompiled_headers.hnew file mode 100644index 0000000000..5f81bef98c--- /dev/null+++ b/src/input_common/precompiled_headers.h@@ -0,0 +1,12 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <fmt/format.h>++#include "common/assert.h"diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txtindex 6f8ca4b90c..c85c308de8 100644--- a/src/network/CMakeLists.txt+++ b/src/network/CMakeLists.txt@@ -8,6 +8,7 @@ add_library(network STATICnetwork.hpacket.cpppacket.h+ precompiled_headers.hroom.cpproom.hroom_member.cpp@@ -23,3 +24,7 @@ if (ENABLE_WEB_SERVICE)target_compile_definitions(network PRIVATE -DENABLE_WEB_SERVICE)target_link_libraries(network PRIVATE web_service)endif()++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(network PRIVATE precompiled_headers.h)+endif()diff --git a/src/network/precompiled_headers.h b/src/network/precompiled_headers.hnew file mode 100644index 0000000000..5f81bef98c--- /dev/null+++ b/src/network/precompiled_headers.h@@ -0,0 +1,12 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <fmt/format.h>++#include "common/assert.h"diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txtindex 545d69c7e5..967ec9ba7f 100644--- a/src/shader_recompiler/CMakeLists.txt+++ b/src/shader_recompiler/CMakeLists.txt@@ -230,6 +230,7 @@ add_library(shader_recompiler STATICir_opt/texture_pass.cppir_opt/verification_pass.cppobject_pool.h+ precompiled_headers.hprofile.hprogram_header.hruntime_info.h@@ -258,3 +259,7 @@ else()endif()create_target_directory_groups(shader_recompiler)++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(shader_recompiler PRIVATE precompiled_headers.h)+endif()diff --git a/src/shader_recompiler/precompiled_headers.h b/src/shader_recompiler/precompiled_headers.hnew file mode 100644index 0000000000..bd8f64a2e3--- /dev/null+++ b/src/shader_recompiler/precompiled_headers.h@@ -0,0 +1,13 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <fmt/format.h>++#include "common/assert.h"+#include "frontend/maxwell/translate/impl/impl.h"diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txtindex 43ad2c7ff4..348d1edf40 100644--- a/src/tests/CMakeLists.txt+++ b/src/tests/CMakeLists.txt@@ -11,6 +11,7 @@ add_executable(testscommon/unique_function.cppcore/core_timing.cppcore/internal_network/network.cpp+ precompiled_headers.htests.cppvideo_core/buffer_base.cppinput_common/calibration_configuration_job.cpp@@ -22,3 +23,7 @@ target_link_libraries(tests PRIVATE common core input_common)target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} Catch2::Catch2 Threads::Threads)add_test(NAME tests COMMAND tests)++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(tests PRIVATE precompiled_headers.h)+endif()diff --git a/src/tests/precompiled_headers.h b/src/tests/precompiled_headers.hnew file mode 100644index 0000000000..5f81bef98c--- /dev/null+++ b/src/tests/precompiled_headers.h@@ -0,0 +1,12 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <fmt/format.h>++#include "common/assert.h"diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txtindex b03a309921..97609ded48 100644--- a/src/video_core/CMakeLists.txt+++ b/src/video_core/CMakeLists.txt@@ -84,6 +84,7 @@ add_library(video_core STATICgpu_thread.hmemory_manager.cppmemory_manager.h+ precompiled_headers.hpte_kind.hquery_cache.hrasterizer_accelerated.cpp@@ -300,3 +301,7 @@ endif()if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)target_link_libraries(video_core PRIVATE dynarmic)endif()++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(video_core PRIVATE precompiled_headers.h)+endif()diff --git a/src/video_core/precompiled_headers.h b/src/video_core/precompiled_headers.hnew file mode 100644index 0000000000..5f81bef98c--- /dev/null+++ b/src/video_core/precompiled_headers.h@@ -0,0 +1,12 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <fmt/format.h>++#include "common/assert.h"diff --git a/src/web_service/CMakeLists.txt b/src/web_service/CMakeLists.txtindex 3f75d97d17..19534b9e42 100644--- a/src/web_service/CMakeLists.txt+++ b/src/web_service/CMakeLists.txt@@ -4,6 +4,7 @@add_library(web_service STATICannounce_room_json.cppannounce_room_json.h+ precompiled_headers.htelemetry_json.cpptelemetry_json.hverify_login.cpp@@ -17,3 +18,7 @@ add_library(web_service STATICcreate_target_directory_groups(web_service)target_link_libraries(web_service PRIVATE common network nlohmann_json::nlohmann_json httplib cpp-jwt)++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(web_service PRIVATE precompiled_headers.h)+endif()diff --git a/src/web_service/precompiled_headers.h b/src/web_service/precompiled_headers.hnew file mode 100644index 0000000000..5f81bef98c--- /dev/null+++ b/src/web_service/precompiled_headers.h@@ -0,0 +1,12 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <fmt/format.h>++#include "common/assert.h"diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txtindex 0aa109dd34..4de45c9ba0 100644--- a/src/yuzu/CMakeLists.txt+++ b/src/yuzu/CMakeLists.txt@@ -186,6 +186,7 @@ add_executable(yuzumultiplayer/state.cppmultiplayer/state.hmultiplayer/validation.h+ precompiled_headers.hstartup_checks.cppstartup_checks.huisettings.cpp@@ -405,3 +406,7 @@ endif()if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)target_link_libraries(yuzu PRIVATE dynarmic)endif()++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(yuzu PRIVATE precompiled_headers.h)+endif()diff --git a/src/yuzu/precompiled_headers.h b/src/yuzu/precompiled_headers.hnew file mode 100644index 0000000000..5f81bef98c--- /dev/null+++ b/src/yuzu/precompiled_headers.h@@ -0,0 +1,12 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <fmt/format.h>++#include "common/assert.h"diff --git a/src/yuzu_cmd/CMakeLists.txt b/src/yuzu_cmd/CMakeLists.txtindex 7d8ca3d8a0..daabf608de 100644--- a/src/yuzu_cmd/CMakeLists.txt+++ b/src/yuzu_cmd/CMakeLists.txt@@ -24,6 +24,7 @@ add_executable(yuzu-cmdemu_window/emu_window_sdl2_gl.hemu_window/emu_window_sdl2_vk.cppemu_window/emu_window_sdl2_vk.h+ precompiled_headers.hyuzu.cppyuzu.rc)@@ -55,3 +56,7 @@ if (MSVC)include(CopyYuzuSDLDeps)copy_yuzu_SDL_deps(yuzu-cmd)endif()++if (YUZU_USE_PRECOMPILED_HEADERS)+ target_precompile_headers(yuzu-cmd PRIVATE precompiled_headers.h)+endif()diff --git a/src/yuzu_cmd/precompiled_headers.h b/src/yuzu_cmd/precompiled_headers.hnew file mode 100644index 0000000000..5f81bef98c--- /dev/null+++ b/src/yuzu_cmd/precompiled_headers.h@@ -0,0 +1,12 @@+// SPDX-FileCopyrightText: 2022 yuzu Emulator Project+// SPDX-License-Identifier: GPL-2.0-or-later++#pragma once++#include <algorithm>+#include <chrono>+#include <memory>++#include <fmt/format.h>++#include "common/assert.h"