From 8e2e2c44bbd2b6b2a47b4c344a2114534c5b669c Mon Sep 17 00:00:00 2001 From: Exzap <13877693+Exzap@users.noreply.github.com> Date: Thu, 5 Mar 2026 17:43:55 +0100 Subject: [PATCH] build: Generate precompiled header only once (msvc only) --- src/CMakeLists.txt | 2 ++ src/Cafe/CMakeLists.txt | 2 ++ src/Cemu/CMakeLists.txt | 2 ++ src/Common/CMakeLists.txt | 14 ++++++++------ src/audio/CMakeLists.txt | 2 ++ src/config/CMakeLists.txt | 2 ++ src/gui/wxgui/CMakeLists.txt | 2 ++ src/imgui/CMakeLists.txt | 2 ++ src/input/CMakeLists.txt | 2 ++ src/resource/CMakeLists.txt | 2 ++ src/util/CMakeLists.txt | 2 ++ 11 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a4f0d19e..81d432ec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,6 +55,8 @@ add_executable(CemuBin mainLLE.cpp ) +target_precompile_headers(CemuBin REUSE_FROM CemuCommon) + if(MSVC AND MSVC_VERSION EQUAL 1940) # workaround for an msvc issue on VS 17.10 where generated ILK files are too large # see https://developercommunity.visualstudio.com/t/After-updating-to-VS-1710-the-size-of-/10665511 diff --git a/src/Cafe/CMakeLists.txt b/src/Cafe/CMakeLists.txt index 1835a860..653dea6e 100644 --- a/src/Cafe/CMakeLists.txt +++ b/src/Cafe/CMakeLists.txt @@ -614,6 +614,8 @@ endif() set_property(TARGET CemuCafe PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +target_precompile_headers(CemuCafe REUSE_FROM CemuCommon) + target_include_directories(CemuCafe PUBLIC "../") if (glslang_VERSION VERSION_LESS "15.0.0") diff --git a/src/Cemu/CMakeLists.txt b/src/Cemu/CMakeLists.txt index 83ab0af6..eb658d29 100644 --- a/src/Cemu/CMakeLists.txt +++ b/src/Cemu/CMakeLists.txt @@ -40,6 +40,8 @@ endif() set_property(TARGET CemuComponents PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +target_precompile_headers(CemuComponents REUSE_FROM CemuCommon) + target_include_directories(CemuComponents PUBLIC "../") target_link_libraries(CemuComponents PRIVATE diff --git a/src/Common/CMakeLists.txt b/src/Common/CMakeLists.txt index 971dfd80..8b0a456c 100644 --- a/src/Common/CMakeLists.txt +++ b/src/Common/CMakeLists.txt @@ -53,14 +53,11 @@ if(LINUX) ) endif() -# All the targets wanting to use the precompiled.h header -# have to link to CemuCommon -target_precompile_headers(CemuCommon PUBLIC precompiled.h) +# the precompiled header is produced by CemuCommon and reused by all the other targets +target_precompile_headers(CemuCommon PRIVATE precompiled.h) target_include_directories(CemuCommon PUBLIC "../") target_link_libraries(CemuCommon PRIVATE - Boost::nowide - Boost::filesystem glm::glm ) @@ -69,6 +66,11 @@ if (UNIX AND NOT APPLE) endif() # PUBLIC because: +# - boost/nowide/convert.hpp is included in precompiled.h # - boost/predef/os.h is included in platform.h # - fmt/core.h is included in precompiled.h -target_link_libraries(CemuCommon PUBLIC Boost::headers fmt::fmt) +target_link_libraries(CemuCommon PUBLIC + Boost::nowide + Boost::headers + fmt::fmt +) diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index 8d01499e..40c4ee22 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -7,6 +7,8 @@ add_library(CemuAudio set_property(TARGET CemuAudio PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +target_precompile_headers(CemuAudio REUSE_FROM CemuCommon) + if(WIN32) target_sources(CemuAudio PRIVATE DirectSoundAPI.cpp diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index 183f124a..1c1f8cbc 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -13,6 +13,8 @@ add_library(CemuConfig set_property(TARGET CemuConfig PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +target_precompile_headers(CemuConfig REUSE_FROM CemuCommon) + target_include_directories(CemuConfig PUBLIC "../") target_link_libraries(CemuConfig PRIVATE diff --git a/src/gui/wxgui/CMakeLists.txt b/src/gui/wxgui/CMakeLists.txt index 7db02c20..f625f614 100644 --- a/src/gui/wxgui/CMakeLists.txt +++ b/src/gui/wxgui/CMakeLists.txt @@ -132,6 +132,8 @@ endif() set_property(TARGET CemuWxGui PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +target_precompile_headers(CemuWxGui REUSE_FROM CemuCommon) + target_include_directories(CemuWxGui PUBLIC "../") # PUBLIC because rapidjson/document.h is included in ChecksumTool.h diff --git a/src/imgui/CMakeLists.txt b/src/imgui/CMakeLists.txt index 57526c18..a77b807b 100644 --- a/src/imgui/CMakeLists.txt +++ b/src/imgui/CMakeLists.txt @@ -18,6 +18,8 @@ endif () set_property(TARGET imguiImpl PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +target_precompile_headers(imguiImpl REUSE_FROM CemuCommon) + target_include_directories(imguiImpl PUBLIC "../") # imgui source files diff --git a/src/input/CMakeLists.txt b/src/input/CMakeLists.txt index cdf9cbba..7953c26b 100644 --- a/src/input/CMakeLists.txt +++ b/src/input/CMakeLists.txt @@ -43,6 +43,8 @@ add_library(CemuInput set_property(TARGET CemuInput PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +target_precompile_headers(CemuInput REUSE_FROM CemuCommon) + if(WIN32) # XInput target_sources(CemuInput PRIVATE diff --git a/src/resource/CMakeLists.txt b/src/resource/CMakeLists.txt index c8833d01..f946a528 100644 --- a/src/resource/CMakeLists.txt +++ b/src/resource/CMakeLists.txt @@ -2,6 +2,8 @@ add_library(CemuResource) set_property(TARGET CemuResource PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +target_precompile_headers(CemuResource REUSE_FROM CemuCommon) + enable_language(ASM) # icon resources diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index c0c45eba..e8e45ff9 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -89,6 +89,8 @@ endif() set_property(TARGET CemuUtil PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") +target_precompile_headers(CemuUtil REUSE_FROM CemuCommon) + target_include_directories(CemuUtil PUBLIC "../") target_link_libraries(CemuUtil PRIVATE