From d2df9afda263acf37e07137f1d364737c97799c6 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Wed, 27 Apr 2022 18:10:04 +1200 Subject: [PATCH 01/16] cmake: Fix libusb on windows --- Externals/libusb/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Externals/libusb/CMakeLists.txt b/Externals/libusb/CMakeLists.txt index a3c5e73e4f..cd3e2e943f 100644 --- a/Externals/libusb/CMakeLists.txt +++ b/Externals/libusb/CMakeLists.txt @@ -26,6 +26,7 @@ if(WIN32 OR CYGWIN) libusb/libusb/os/windows_common.c libusb/libusb/os/windows_usbdk.c libusb/libusb/os/windows_winusb.c + libusb/libusb/os/events_windows.c ) set(PLATFORM_WINDOWS TRUE) elseif(APPLE) From 54d89b955acea8080924c7f59fbd8310896b283e Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Wed, 27 Apr 2022 18:11:50 +1200 Subject: [PATCH 02/16] cmake: add missing FFmpeg dependency on windows --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0bc248e00..337877cb38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -502,6 +502,12 @@ if(ENCODE_FRAMEDUMPS) endif() message(STATUS "libav/ffmpeg found, enabling AVI frame dumps") add_definitions(-DHAVE_FFMPEG) + if(WIN32) + # Our prebuilt binaries depend on Bcrypt + set_property(TARGET FFmpeg::avutil APPEND PROPERTY + INTERFACE_LINK_LIBRARIES "Bcrypt.lib" + ) + endif() else() message(STATUS "libav/ffmpeg not found, disabling AVI frame dumps") endif() From 987f2700832de979cc767cbe9846fd6984392d05 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Wed, 27 Apr 2022 18:22:02 +1200 Subject: [PATCH 03/16] cmake: fix buggy target sources on windows I have no idea why cmake supports PUBLIC on target_sources, but it does. It causes all targets that depend on this target to try and include the files in their sources. Except it doesn't take paths into account, so it breaks. Mabye it would work if you used an abolute source? But I'm not sure there is a sane usecase. --- Source/Core/Common/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 3ede46e870..e7cc3d88d8 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -287,7 +287,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") endif() if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - target_sources(common PUBLIC HRWrap.h HRWrap.cpp) + target_sources(common PRIVATE HRWrap.h HRWrap.cpp) endif() if(USE_UPNP) From 2348017ee8ad11e7d12795f11353e989b25c1cb0 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Wed, 27 Apr 2022 18:31:27 +1200 Subject: [PATCH 04/16] cmake: ignore external warnings in MSVC Since we also treat all warnings as errors, we need to ignore these to successfully build. --- Source/CMakeLists.txt | 6 +++++- Source/Core/DolphinQt/CMakeLists.txt | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9aa5ff1bdc..d68acaca4f 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -67,7 +67,11 @@ if (MSVC) # All files are encoded as UTF-8 add_compile_options(/utf-8) - # Use PCH + # Ignore warnings in external headers + add_compile_options(/external:anglebrackets) + add_compile_options(/external:W0) + add_compile_options(/external:templates-) + add_subdirectory(PCH) add_definitions(/I${PCH_DIRECTORY}) add_definitions(/Yu${PCH_PATH}) diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 000e5767a4..7f65c62179 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -382,9 +382,6 @@ if (WIN32) endif() if (MSVC) - # Don't propogate warnings in qt headers to Dolphin - target_compile_options(dolphin-emu PRIVATE /experimental:external) - target_compile_options(dolphin-emu PRIVATE /external:W0) set(qtGui "") set(qtGuiPriv "") set(qtWidgetsPriv "") From 0909e0011748dcb47503a5a4e25c609aa11ceae8 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Wed, 27 Apr 2022 18:57:13 +1200 Subject: [PATCH 05/16] cmake: fix MSVC PCH support I'm not sure if the previous implementation ever worked. --- Externals/imgui/CMakeLists.txt | 1 - Source/CMakeLists.txt | 3 +-- Source/Core/Common/CMakeLists.txt | 11 +++++++++++ Source/PCH/CMakeLists.txt | 24 +++++++++++++++++++++--- Source/PCH/nopch/pch.h | 4 ++++ 5 files changed, 37 insertions(+), 6 deletions(-) create mode 100644 Source/PCH/nopch/pch.h diff --git a/Externals/imgui/CMakeLists.txt b/Externals/imgui/CMakeLists.txt index b3d48432a1..2b805f7725 100644 --- a/Externals/imgui/CMakeLists.txt +++ b/Externals/imgui/CMakeLists.txt @@ -14,6 +14,5 @@ target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") target_link_libraries(imgui PRIVATE - common fmt::fmt ) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index d68acaca4f..3017a2abd8 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -72,9 +72,8 @@ if (MSVC) add_compile_options(/external:W0) add_compile_options(/external:templates-) + # Compile PCH add_subdirectory(PCH) - add_definitions(/I${PCH_DIRECTORY}) - add_definitions(/Yu${PCH_PATH}) # Don't include timestamps in binaries add_link_options(/Brepro) diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index e7cc3d88d8..984a143ce9 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -308,3 +308,14 @@ if(UNIX) elseif(WIN32) target_link_libraries(common PRIVATE "-INCLUDE:enableCompatPatches") endif() + +if(MSVC) + # Add precompiled header + # it will propergate down to everything that depends on common + target_link_libraries(common PUBLIC pch) + + # We need to disable PCH for this one file, because it's C and our PCH is C++ + set_source_files_properties( + ${CMAKE_CURRENT_SOURCE_DIR}/ImageC.c + PROPERTIES COMPILE_FLAGS "/Y- /I${CMAKE_SOURCE_DIR}/Source/PCH/nopch") +endif() diff --git a/Source/PCH/CMakeLists.txt b/Source/PCH/CMakeLists.txt index 7346b24dff..aeddfa52f5 100644 --- a/Source/PCH/CMakeLists.txt +++ b/Source/PCH/CMakeLists.txt @@ -1,6 +1,24 @@ +# The PCH that dolphin uses for MSVC is non-standard; +# Instead of having one PCH per module, dolphin has one PCH shared between all modules. +# So we need to implement PCH manually, rather than using the PCH support built into cmake + add_library(pch pch.h pch.cpp) -set(PCH_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -set(PCH_NAME ${PCH.pch}) -target_compile_options(pch PUBLIC /Ycpch.h /Fp${PCH_DIRECTORY}/${PCH_NAME}) + +# pch.cpp should be compiled with the /Yc command, which creates the precompiled header +target_compile_options(pch PRIVATE /Yc"pch.h" /Fo$) + +# /Fp sets the location of the PCH. By forcing it to a fixed location, all modules +# will share this one PCH +target_compile_options(pch PUBLIC /Fp$) + +# Sharing a PCH breaks pdb files. So we use the /Z7 option to inline the pdb into +# the binary. That also requires us to disable minimal rebuilds. +target_compile_options(pch PUBLIC /Z7 /Gm-) + +# targets which include pch need these compile options +# /Yu - Use precompiled header named "pch.h" +# /FI - Force include "pch.h" at top of every source file +target_compile_options(pch INTERFACE /Yu"pch.h" /FI"pch.h") + # fmt/format.h is included in the PCH target_link_libraries(pch PUBLIC fmt::fmt) diff --git a/Source/PCH/nopch/pch.h b/Source/PCH/nopch/pch.h new file mode 100644 index 0000000000..6b7c4c5b31 --- /dev/null +++ b/Source/PCH/nopch/pch.h @@ -0,0 +1,4 @@ +// dummy include to help with disabling pch for a single file +// cmake doesn't provide a clean way to disable MSVC's force include option + +// So we can just point it at an empty file instead. From 89fda54820744848d19686b21221a86f6917e24b Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Thu, 28 Apr 2022 17:15:30 +1200 Subject: [PATCH 06/16] cmake: fix ninja/msvc builds If you don't set this policy, then cmake doesn't even try to select a runtime library --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 337877cb38..148872fc82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,9 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14.0" CACHE STRING "") set(CMAKE_USER_MAKE_RULES_OVERRIDE "CMake/FlagsOverride.cmake") +# Required for cmake to select the correct runtime library in MSVC builds. +cmake_policy(SET CMP0091 NEW) + project(dolphin-emu) # Name of the Dolphin distributor. If you redistribute Dolphin builds (forks, From 876f6651b45e7c4e014571ce1c4d53f70ac68813 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Thu, 28 Apr 2022 17:18:07 +1200 Subject: [PATCH 07/16] cmake: fix PCH to work with msvc/ninja Ninja puts way more effort into compiling targets in parallel, and ignores dependenceis until link time. So we need to jump though hoops to force ninja to compile pch.cpp before any targets which depend on the PCH. --- Source/Core/Common/CMakeLists.txt | 2 +- Source/PCH/CMakeLists.txt | 37 +++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 984a143ce9..287680aeea 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -312,7 +312,7 @@ endif() if(MSVC) # Add precompiled header # it will propergate down to everything that depends on common - target_link_libraries(common PUBLIC pch) + target_link_libraries(common PUBLIC use_pch) # We need to disable PCH for this one file, because it's C and our PCH is C++ set_source_files_properties( diff --git a/Source/PCH/CMakeLists.txt b/Source/PCH/CMakeLists.txt index aeddfa52f5..2ee6adaa12 100644 --- a/Source/PCH/CMakeLists.txt +++ b/Source/PCH/CMakeLists.txt @@ -2,23 +2,42 @@ # Instead of having one PCH per module, dolphin has one PCH shared between all modules. # So we need to implement PCH manually, rather than using the PCH support built into cmake -add_library(pch pch.h pch.cpp) +add_library(build_pch pch.h pch.cpp) + +# fmt/format.h is included in the PCH +target_link_libraries(build_pch PUBLIC fmt::fmt) # pch.cpp should be compiled with the /Yc command, which creates the precompiled header -target_compile_options(pch PRIVATE /Yc"pch.h" /Fo$) +target_compile_options(build_pch PRIVATE /Ycpch.h) # /Fp sets the location of the PCH. By forcing it to a fixed location, all modules -# will share this one PCH -target_compile_options(pch PUBLIC /Fp$) +# will share this one PCH. We give it a fixed name so we can depend on it later +target_compile_options(build_pch PUBLIC /Fp$/dolphin.pch ) # Sharing a PCH breaks pdb files. So we use the /Z7 option to inline the pdb into # the binary. That also requires us to disable minimal rebuilds. -target_compile_options(pch PUBLIC /Z7 /Gm-) +target_compile_options(build_pch PUBLIC /Z7 /Gm-) -# targets which include pch need these compile options +# To get this working with ninja, we need to tell it that compiling pch.cpp generates an extra output +set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/pch.cpp PROPERTIES + OBJECT_OUTPUTS $/dolphin.pch +) + +# and then create a custom target that depends on the pch output +# so that ninja won't start building anything that depends on this +# target before the pch is built +add_custom_target(force_build_pch + DEPENDS $/dolphin.pch +) + +# linking against this interface libary will cause targets to enable PCH +add_library(use_pch INTERFACE) +target_link_libraries(use_pch INTERFACE build_pch) + +# targets which use the pch need these compile options # /Yu - Use precompiled header named "pch.h" # /FI - Force include "pch.h" at top of every source file -target_compile_options(pch INTERFACE /Yu"pch.h" /FI"pch.h") +target_compile_options(use_pch INTERFACE /Yupch.h /FIpch.h) -# fmt/format.h is included in the PCH -target_link_libraries(pch PUBLIC fmt::fmt) +# For ninja, we need to depend on force_build_pch +add_dependencies(use_pch force_build_pch) From 4db181636804603153ab372247d9a6ff377e8d52 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Fri, 29 Apr 2022 05:20:16 +1200 Subject: [PATCH 08/16] cmake: Require cmake 3.15 for MSVC We need these policies, but we kind of want to avoid requiring cmake 3.15 for all platforms --- CMakeLists.txt | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 148872fc82..23bab93618 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,15 +9,19 @@ cmake_minimum_required(VERSION 3.10) # MacOS prior to 10.14 did not support aligned alloc which is used to implement # std::unique_ptr in the arm64 C++ standard library. x86_64 builds can override # this to 10.13.0 using -DCMAKE_OSX_DEPLOYMENT_TARGET="10.13.0" without issue. -# This is done in the universal binary building script to build a binary that +# This is done in the universal binary building script to build a binary that # runs on 10.13 on x86_64 computers, while still containing an arm64 slice. set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14.0" CACHE STRING "") set(CMAKE_USER_MAKE_RULES_OVERRIDE "CMake/FlagsOverride.cmake") -# Required for cmake to select the correct runtime library in MSVC builds. -cmake_policy(SET CMP0091 NEW) +# Optionally enable these polcies so older versions of cmake don't break. +# we only need them for MSVC +if(POLICY CMP0091) + cmake_policy(SET CMP0091 NEW) # MSVC runtime library flags are selected by an abstraction. + cmake_policy(SET CMP0092 NEW) # MSVC warning flags are not in CMAKE_{C,CXX}_FLAGS by default. +endif() project(dolphin-emu) @@ -81,7 +85,7 @@ endif() if(APPLE) option(MACOS_USE_DEFAULT_SEARCH_PATH "Don't prioritize system library paths" OFF) - option(SKIP_POSTPROCESS_BUNDLE "Skip postprocessing bundle for redistributability" OFF) + option(SKIP_POSTPROCESS_BUNDLE "Skip postprocessing bundle for redistributability" OFF) # Enable adhoc code signing by default (otherwise makefile builds on ARM will not work) option(MACOS_CODE_SIGNING "Enable codesigning" ON) set(MACOS_CODE_SIGNING_IDENTITY "-" CACHE STRING "The identity used for codesigning.") @@ -247,7 +251,14 @@ elseif(CMAKE_GENERATOR MATCHES "Visual Studio") add_compile_options("/MP") endif() -if(CMAKE_C_COMPILER_ID MATCHES "MSVC") +if(MSVC) + if(POLICY CMP0091) + # cmake is a weird language. You can't do if(not POLICY) + else() + # We really kind of want this policy + message(FATAL_ERROR "please update cmake to at least 3.15") + endif() + check_and_add_flag(EXCEPTIONS /EHsc) dolphin_compile_definitions(_DEBUG DEBUG_ONLY) @@ -497,7 +508,7 @@ if(ENCODE_FRAMEDUMPS) endif() find_package(FFmpeg COMPONENTS avcodec avformat avutil swresample swscale) if(FFmpeg_FOUND) - if(APPLE) + if(APPLE) find_library(COREMEDIA_LIBRARY CoreMedia) find_library(VIDEOTOOLBOX_LIBRARY VideoToolbox) find_library(COREVIDEO_LIBRARY CoreVideo) From 96e2f1f95e7fdcd1fcb1577fe0b4f3124069a7ac Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 20 May 2022 17:13:41 +0200 Subject: [PATCH 09/16] Externals: Update prebuilt Qt submodule to include mkspecs -- the CMake build process wants them. --- Externals/Qt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Externals/Qt b/Externals/Qt index 9498dbe942..376baafde6 160000 --- a/Externals/Qt +++ b/Externals/Qt @@ -1 +1 @@ -Subproject commit 9498dbe9421a80da674212fee0bf745883464992 +Subproject commit 376baafde6cce2f8892c34c17ed397afa6c46d08 From dbee810a04ab6ed207af4038202ee05a1a8b900c Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Fri, 20 May 2022 17:14:05 +0200 Subject: [PATCH 10/16] cmake: Fixes for Qt6 on Windows. --- CMakeSettings.json | 16 ++++++++-------- Source/Core/DolphinQt/CMakeLists.txt | 9 ++++++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CMakeSettings.json b/CMakeSettings.json index 94812b270f..491c378ec8 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -10,8 +10,8 @@ "cmakeCommandArgs": "", "variables": [ { - "name": "QT_DIR", - "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64\\lib\\cmake\\Qt6" + "name": "CMAKE_PREFIX_PATH", + "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64" } ] }, @@ -25,8 +25,8 @@ "cmakeCommandArgs": "", "variables": [ { - "name": "QT_DIR", - "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64\\lib\\cmake\\Qt6" + "name": "CMAKE_PREFIX_PATH", + "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64" } ] }, @@ -40,8 +40,8 @@ "cmakeCommandArgs": "", "variables": [ { - "name": "QT_DIR", - "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64\\lib\\cmake\\Qt6" + "name": "CMAKE_PREFIX_PATH", + "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64" }, { "name": "CMAKE_SYSTEM_NAME", @@ -63,8 +63,8 @@ "cmakeCommandArgs": "", "variables": [ { - "name": "QT_DIR", - "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64\\lib\\cmake\\Qt6" + "name": "CMAKE_PREFIX_PATH", + "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64" }, { "name": "CMAKE_SYSTEM_NAME", diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 7f65c62179..d594b323fb 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -427,6 +427,13 @@ if(WIN32) get_filename_component(QT_BINARY_DIRECTORY "${MOC_EXECUTABLE_LOCATION}" DIRECTORY) find_program(WINDEPLOYQT_EXE windeployqt HINTS "${QT_BINARY_DIRECTORY}") + if ("${QT_VERSION_MAJOR}" LESS 6) + set(NO_ANGLE_PARAM "--no-angle") + else() + # parameter no longer exists in Qt6 + set(NO_ANGLE_PARAM "") + endif() + # Note: We set the PATH for the duration of this command so that the # deployment application is able to locate the Qt libraries to copy. # if the necessary paths aren't already set beforehand. @@ -449,7 +456,7 @@ if(WIN32) --no-translations --no-compiler-runtime --no-system-d3d-compiler - --no-angle + "${NO_ANGLE_PARAM}" --no-opengl-sw "$" ) From 89fadd26a6ad01bd4ded9eea986283a67321ef80 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 21 May 2022 03:31:41 +0200 Subject: [PATCH 11/16] cmake: Use C++latest everywhere on MSVC. --- CMakeLists.txt | 8 ++++++++ Externals/FreeSurround/CMakeLists.txt | 8 +++++--- Externals/WIL/tests/cpplatest/CMakeLists.txt | 4 +++- Externals/cubeb/CMakeLists.txt | 9 ++++++--- Externals/discord-rpc/src/CMakeLists.txt | 4 +++- Externals/imgui/CMakeLists.txt | 8 +++++--- Source/CMakeLists.txt | 9 +++------ 7 files changed, 33 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23bab93618..7cd79ca081 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,14 @@ endif() project(dolphin-emu) +if (MSVC) + set(CMAKE_C_STANDARD 99) + set(CMAKE_CXX_STANDARD 20) + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std:c++latest") + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +endif() + # Name of the Dolphin distributor. If you redistribute Dolphin builds (forks, # unofficial builds) please consider identifying your distribution with a # unique name here. diff --git a/Externals/FreeSurround/CMakeLists.txt b/Externals/FreeSurround/CMakeLists.txt index 6d488f155e..9a17fff2fd 100644 --- a/Externals/FreeSurround/CMakeLists.txt +++ b/Externals/FreeSurround/CMakeLists.txt @@ -1,6 +1,8 @@ -set(CMAKE_CXX_STANDARD 14) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) +if (NOT MSVC) + set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +endif() set(SRCS source/ChannelMaps.cpp diff --git a/Externals/WIL/tests/cpplatest/CMakeLists.txt b/Externals/WIL/tests/cpplatest/CMakeLists.txt index 22e45cc940..7255c97ef3 100644 --- a/Externals/WIL/tests/cpplatest/CMakeLists.txt +++ b/Externals/WIL/tests/cpplatest/CMakeLists.txt @@ -1,7 +1,9 @@ # Compilers often don't use the latest C++ standard as the default. Periodically update this value (possibly conditioned # on compiler) as new standards are ratified/support is available -set(CMAKE_CXX_STANDARD 17) +if (NOT MSVC) + set(CMAKE_CXX_STANDARD 17) +endif() project(witest.cpplatest) add_executable(witest.cpplatest) diff --git a/Externals/cubeb/CMakeLists.txt b/Externals/cubeb/CMakeLists.txt index 3604041d7d..65fda6c181 100644 --- a/Externals/cubeb/CMakeLists.txt +++ b/Externals/cubeb/CMakeLists.txt @@ -15,9 +15,12 @@ endif() if(POLICY CMP0063) cmake_policy(SET CMP0063 NEW) endif() -set(CMAKE_C_STANDARD 99) -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) + +if (NOT MSVC) + set(CMAKE_C_STANDARD 99) + set(CMAKE_CXX_STANDARD 11) + set(CMAKE_CXX_STANDARD_REQUIRED ON) +endif() if(NOT COMMAND add_sanitizers) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake") diff --git a/Externals/discord-rpc/src/CMakeLists.txt b/Externals/discord-rpc/src/CMakeLists.txt index 8e20faac86..c49b26faf6 100644 --- a/Externals/discord-rpc/src/CMakeLists.txt +++ b/Externals/discord-rpc/src/CMakeLists.txt @@ -4,7 +4,9 @@ option(ENABLE_IO_THREAD "Start up a separate I/O thread, otherwise I'd need to c option(USE_STATIC_CRT "Use /MT[d] for dynamic library" OFF) option(WARNINGS_AS_ERRORS "When enabled, compiles with `-Werror` (on *nix platforms)." OFF) -set(CMAKE_CXX_STANDARD 14) +if (NOT MSVC) + set(CMAKE_CXX_STANDARD 14) +endif() set(BASE_RPC_SRC ${PROJECT_SOURCE_DIR}/include/discord_rpc.h diff --git a/Externals/imgui/CMakeLists.txt b/Externals/imgui/CMakeLists.txt index 2b805f7725..3b6be85f50 100644 --- a/Externals/imgui/CMakeLists.txt +++ b/Externals/imgui/CMakeLists.txt @@ -1,6 +1,8 @@ -set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) +if (NOT MSVC) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) +endif() set(SRCS imgui.cpp diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 3017a2abd8..9815023369 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -18,15 +18,12 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows") add_definitions(-D_SILENCE_CXX20_OLD_SHARED_PTR_ATOMIC_SUPPORT_DEPRECATION_WARNING) endif() -if (MSVC) - set(CMAKE_CXX_STANDARD 20) - set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std:c++latest") -else() +if (NOT MSVC) set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) endif() -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if (MSVC) From 9908219dc6b489e7ae85ee5247359072140dd68c Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 21 May 2022 04:37:28 +0200 Subject: [PATCH 12/16] cmake: Add a few missing settings from the Visual Studio project files on MSVC. --- CMakeLists.txt | 54 ++++++++++++++++++++++++++-- Source/CMakeLists.txt | 45 ----------------------- Source/Core/DolphinQt/CMakeLists.txt | 7 ++++ 3 files changed, 59 insertions(+), 47 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cd79ca081..886c6513e5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -270,12 +270,59 @@ if(MSVC) check_and_add_flag(EXCEPTIONS /EHsc) dolphin_compile_definitions(_DEBUG DEBUG_ONLY) + # Disable RTTI + # Unfortunately /GR is in the default compile flags for MSVC so we have to find and replace it. + foreach (flag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + string(REGEX REPLACE " /GR " " /GR- " ${flag} "${${flag}}") + endforeach() + + # Set warning level 4 (the highest) + add_compile_options(/W4) + + # Treat all warnings as errors + add_compile_options(/WX) + + # Disable some warnings + add_compile_options( + /wd4201 # nonstandard extension used : nameless struct/union + /wd4127 # conditional expression is constant + /wd4100 # 'identifier' : unreferenced formal parameter + /wd4200 # InputCommon fix temp. + /wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data + /wd4121 # 'symbol' : alignment of a member was sensitive to packing + /wd4324 # Padding was added at the end of a structure because you specified a __declspec(align) value. + /wd4714 # function 'function' marked as __forceinline not inlined + /wd4351 # new behavior: elements of array 'array' will be default initialized + # TODO: Enable this warning once possible + /wd4245 # conversion from 'type1' to 'type2', signed/unsigned mismatch + # Currently jits use some annoying code patterns which makes this common + ) + + # Additional warnings + add_compile_options( + /w44263 # Non-virtual member function hides base class virtual function + /w44265 # Class has virtual functions, but destructor is not virtual + /w44946 # Reinterpret cast between related types + ) + + # All files are encoded as UTF-8 + add_compile_options(/utf-8) + + # Ignore warnings in external headers + add_compile_options(/external:anglebrackets) + add_compile_options(/external:W0) + add_compile_options(/external:templates-) + + # Request deterministic builds + add_compile_options(/experimental:deterministic) + add_link_options(/experimental:deterministic) + # Enable function-level linking add_compile_options(/Gy) # Generate intrinsic functions add_compile_options(/Oi) - # Disable buffer security check - add_compile_options(/GS-) + # Enable buffer security check on Debug, disable otherwise + add_compile_options($,/GS,/GS->) # Enforce C++ standard conforming conversion rules to catch possible bugs add_compile_options(/permissive-) # Remove unreferenced inline functions/data to reduce link time and catch bugs @@ -294,6 +341,9 @@ if(MSVC) /wd5105 # macro expansion producing 'defined' has undefined behavior ) + # Use 'precise' floating point model + add_compile_options(/fp:precise) + string(APPEND CMAKE_EXE_LINKER_FLAGS " /NXCOMPAT") # Generate debug data string(APPEND CMAKE_EXE_LINKER_FLAGS " /DEBUG") diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 9815023369..c9d2edb516 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -27,53 +27,8 @@ endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) if (MSVC) - # TODO: Use https://cmake.org/cmake/help/latest/policy/CMP0092.html instead (once we can require CMake >= 3.15) - # Taken from http://www.cmake.org/Wiki/CMake_FAQ#Dynamic_Replace. - foreach(flag_var - CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE - MAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - # Replaces /W3 with /W4 in defaults (add_compile_options would cause very annoying warnings here) - string(REPLACE "/W3" "/W4" ${flag_var} "${${flag_var}}") - endforeach() - - # Disable some warnings - add_compile_options( - /wd4201 # nonstandard extension used : nameless struct/union - /wd4127 # conditional expression is constant - /wd4100 # 'identifier' : unreferenced formal parameter - /wd4200 # InputCommon fix temp. - /wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data - /wd4121 # 'symbol' : alignment of a member was sensitive to packing - /wd4324 # Padding was added at the end of a structure because you specified a __declspec(align) value. - /wd4714 # function 'function' marked as __forceinline not inlined - /wd4351 # new behavior: elements of array 'array' will be default initialized - # TODO: Enable this warning once possible - /wd4245 # conversion from 'type1' to 'type2', signed/unsigned mismatch - # Currently jits use some annoying code patterns which makes this common - ) - - # Additional warnings - add_compile_options( - /w44263 # Non-virtual member function hides base class virtual function - /w44265 # Class has virtual functions, but destructor is not virtual - ) - - # Treat all warnings as errors - add_compile_options(/WX) - - # All files are encoded as UTF-8 - add_compile_options(/utf-8) - - # Ignore warnings in external headers - add_compile_options(/external:anglebrackets) - add_compile_options(/external:W0) - add_compile_options(/external:templates-) - # Compile PCH add_subdirectory(PCH) - - # Don't include timestamps in binaries - add_link_options(/Brepro) else() check_and_add_flag(HAVE_WALL -Wall) # TODO: would like these but they produce overwhelming amounts of warnings diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index d594b323fb..3398bb2695 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -391,6 +391,13 @@ if (MSVC) target_compile_options(dolphin-emu PRIVATE "${qtGui}") target_compile_options(dolphin-emu PRIVATE "${qtGuiPriv}") target_compile_options(dolphin-emu PRIVATE "${qtWidgets}") + + if ("${QT_VERSION_MAJOR}" GREATER_EQUAL 6) + # Qt6 requires RTTI + foreach (flag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + string(REGEX REPLACE " /GR- " " /GR " ${flag} "${${flag}}") + endforeach() + endif() endif() if(WIN32) From 7f2ea688d2b6881a071d3db86efb8825fafd3014 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 21 May 2022 04:40:13 +0200 Subject: [PATCH 13/16] cmake: On MSVC, set c++latest by requesting a C++23 feature set. --- CMakeLists.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 886c6513e5..0bbb6d3b69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,10 +27,8 @@ project(dolphin-emu) if (MSVC) set(CMAKE_C_STANDARD 99) - set(CMAKE_CXX_STANDARD 20) - set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std:c++latest") + set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) - set(CMAKE_CXX_EXTENSIONS OFF) endif() # Name of the Dolphin distributor. If you redistribute Dolphin builds (forks, From a5e85627b04ed8d05ccccfaf0aac5f83ec6ace0c Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 21 May 2022 14:26:39 +0200 Subject: [PATCH 14/16] cmake: Use Policy CMP0117 for more sensible RTTI flag configuration on MSVC. --- CMake/RemoveCompileFlag.cmake | 16 +++++++++++++ CMakeLists.txt | 34 +++++++++++++--------------- Source/Core/DolphinQt/CMakeLists.txt | 5 ++-- 3 files changed, 34 insertions(+), 21 deletions(-) create mode 100644 CMake/RemoveCompileFlag.cmake diff --git a/CMake/RemoveCompileFlag.cmake b/CMake/RemoveCompileFlag.cmake new file mode 100644 index 0000000000..1bb9c167be --- /dev/null +++ b/CMake/RemoveCompileFlag.cmake @@ -0,0 +1,16 @@ +# from https://stackoverflow.com/a/49216539 +# The linked answer does some weird preconfiguring by manually splitting the CMAKE_CXX_FLAGS variable and applying it to a target, +# but as far as I can tell none of that is necessary, this works just fine as-is. + +# +# Removes the specified compile flag from the specified target. +# _target - The target to remove the compile flag from +# _flag - The compile flag to remove +# +macro(remove_cxx_flag_from_target _target _flag) + get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS) + if(_target_cxx_flags) + list(REMOVE_ITEM _target_cxx_flags ${_flag}) + set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${_target_cxx_flags}") + endif() +endmacro() diff --git a/CMakeLists.txt b/CMakeLists.txt index 0bbb6d3b69..2428a093b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,14 @@ # cmake_minimum_required(VERSION 3.10) +# Weird chicken-and-egg problem: We can't check the compiler before the project() call, but we have to set the policies before it. +# So we do this in two steps: Set the policies if they exist, then error out afterwards if we end up being MSVC and they don't exist. +if (POLICY CMP0117) + cmake_policy(SET CMP0091 NEW) # MSVC runtime library flags are selected by an abstraction. + cmake_policy(SET CMP0092 NEW) # MSVC warning flags are not in CMAKE_{C,CXX}_FLAGS by default. + cmake_policy(SET CMP0117 NEW) # MSVC RTTI flag will not be added by default. +endif() + # Minimum OS X version. # This is inserted into the Info.plist as well. @@ -16,16 +24,15 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.14.0" CACHE STRING "") set(CMAKE_USER_MAKE_RULES_OVERRIDE "CMake/FlagsOverride.cmake") -# Optionally enable these polcies so older versions of cmake don't break. -# we only need them for MSVC -if(POLICY CMP0091) - cmake_policy(SET CMP0091 NEW) # MSVC runtime library flags are selected by an abstraction. - cmake_policy(SET CMP0092 NEW) # MSVC warning flags are not in CMAKE_{C,CXX}_FLAGS by default. -endif() - project(dolphin-emu) if (MSVC) + if (POLICY CMP0117) + # cmake is a weird language. You can't do if(not POLICY) + else() + message(FATAL_ERROR "Please update to CMake 3.20 or higher.") + endif() + set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -121,6 +128,7 @@ include(CheckAndAddFlag) include(CheckCCompilerFlag) include(CheckVendoringApproved) include(DolphinCompileDefinitions) +include(RemoveCompileFlag) # Enable folders for IDE set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -258,21 +266,11 @@ elseif(CMAKE_GENERATOR MATCHES "Visual Studio") endif() if(MSVC) - if(POLICY CMP0091) - # cmake is a weird language. You can't do if(not POLICY) - else() - # We really kind of want this policy - message(FATAL_ERROR "please update cmake to at least 3.15") - endif() - check_and_add_flag(EXCEPTIONS /EHsc) dolphin_compile_definitions(_DEBUG DEBUG_ONLY) # Disable RTTI - # Unfortunately /GR is in the default compile flags for MSVC so we have to find and replace it. - foreach (flag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - string(REGEX REPLACE " /GR " " /GR- " ${flag} "${${flag}}") - endforeach() + add_compile_options(/GR-) # Set warning level 4 (the highest) add_compile_options(/W4) diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 3398bb2695..3e19006952 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -394,9 +394,8 @@ if (MSVC) if ("${QT_VERSION_MAJOR}" GREATER_EQUAL 6) # Qt6 requires RTTI - foreach (flag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) - string(REGEX REPLACE " /GR- " " /GR " ${flag} "${${flag}}") - endforeach() + remove_cxx_flag_from_target(dolphin-emu "/GR-") + target_compile_options(dolphin-emu PRIVATE "/GR") endif() endif() From 6ea7af13e87bcde9301507de5ca071d4532a6d8d Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sat, 21 May 2022 15:09:05 +0200 Subject: [PATCH 15/16] cmake: Disable warnings for most externals on MSVC, like we do in the VS project files. --- CMake/DolphinDisableWarningsMSVC.cmake | 18 ++++++++++++++++++ CMakeLists.txt | 1 + Externals/Bochs_disasm/CMakeLists.txt | 1 + Externals/FreeSurround/CMakeLists.txt | 1 + Externals/LZO/CMakeLists.txt | 1 + Externals/SFML/CMakeLists.txt | 2 ++ Externals/bzip2/CMakeLists.txt | 1 + Externals/cpp-optparse/CMakeLists.txt | 1 + Externals/cubeb/CMakeLists.txt | 2 ++ Externals/curl/lib/CMakeLists.txt | 1 + Externals/discord-rpc/src/CMakeLists.txt | 1 + Externals/ed25519/CMakeLists.txt | 1 + Externals/enet/CMakeLists.txt | 1 + Externals/fmt/CMakeLists.txt | 1 + Externals/glslang/CMakeLists.txt | 1 + Externals/hidapi/CMakeLists.txt | 1 + Externals/imgui/CMakeLists.txt | 1 + Externals/libiconv-1.14/CMakeLists.txt | 1 + Externals/liblzma/CMakeLists.txt | 1 + Externals/libpng/CMakeLists.txt | 2 ++ Externals/libusb/CMakeLists.txt | 2 ++ Externals/mGBA/CMakeLists.txt | 1 + Externals/mbedtls/library/CMakeLists.txt | 6 ++++++ Externals/miniupnpc/CMakeLists.txt | 1 + Externals/minizip/CMakeLists.txt | 1 + Externals/pugixml/CMakeLists.txt | 1 + Externals/soundtouch/CMakeLists.txt | 1 + Externals/xxhash/CMakeLists.txt | 1 + Externals/zlib/CMakeLists.txt | 1 + Externals/zstd/CMakeLists.txt | 1 + 30 files changed, 56 insertions(+) create mode 100644 CMake/DolphinDisableWarningsMSVC.cmake diff --git a/CMake/DolphinDisableWarningsMSVC.cmake b/CMake/DolphinDisableWarningsMSVC.cmake new file mode 100644 index 0000000000..43823a0ea4 --- /dev/null +++ b/CMake/DolphinDisableWarningsMSVC.cmake @@ -0,0 +1,18 @@ +include(RemoveCompileFlag) + +macro(dolphin_disable_warnings_msvc _target) + if (MSVC) + get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS) + if (_target_cxx_flags) + set(new_flags "") + foreach(flag IN LISTS _target_cxx_flags) + # all warning flags start with "/W" or "/w" or "-W" or "-w" + if (NOT "${flag}" MATCHES "^[-/][Ww]") + list(APPEND new_flags "${flag}") + endif() + endforeach() + set_target_properties(${_target} PROPERTIES COMPILE_OPTIONS "${new_flags}") + endif() + target_compile_options(${_target} PRIVATE "/W0") + endif() +endmacro() diff --git a/CMakeLists.txt b/CMakeLists.txt index 2428a093b1..1085d51c92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,6 +128,7 @@ include(CheckAndAddFlag) include(CheckCCompilerFlag) include(CheckVendoringApproved) include(DolphinCompileDefinitions) +include(DolphinDisableWarningsMSVC) include(RemoveCompileFlag) # Enable folders for IDE diff --git a/Externals/Bochs_disasm/CMakeLists.txt b/Externals/Bochs_disasm/CMakeLists.txt index 84326842cb..2a643113e3 100644 --- a/Externals/Bochs_disasm/CMakeLists.txt +++ b/Externals/Bochs_disasm/CMakeLists.txt @@ -4,6 +4,7 @@ add_library(bdisasm STATIC resolve.cc syntax.cc ) +dolphin_disable_warnings_msvc(bdisasm) if (WIN32) target_sources(bdisasm diff --git a/Externals/FreeSurround/CMakeLists.txt b/Externals/FreeSurround/CMakeLists.txt index 9a17fff2fd..d7f8bc3ea2 100644 --- a/Externals/FreeSurround/CMakeLists.txt +++ b/Externals/FreeSurround/CMakeLists.txt @@ -12,5 +12,6 @@ set(SRCS ) add_library(FreeSurround STATIC ${SRCS}) +dolphin_disable_warnings_msvc(FreeSurround) target_include_directories(FreeSurround PUBLIC include) target_compile_options(FreeSurround PRIVATE -w) diff --git a/Externals/LZO/CMakeLists.txt b/Externals/LZO/CMakeLists.txt index 48d1af1b1e..3bb91ee5c5 100644 --- a/Externals/LZO/CMakeLists.txt +++ b/Externals/LZO/CMakeLists.txt @@ -1,6 +1,7 @@ add_library(lzo2 STATIC minilzo.c ) +dolphin_disable_warnings_msvc(lzo2) target_include_directories(lzo2 PUBLIC diff --git a/Externals/SFML/CMakeLists.txt b/Externals/SFML/CMakeLists.txt index 0e82eae1ec..aac2192cad 100644 --- a/Externals/SFML/CMakeLists.txt +++ b/Externals/SFML/CMakeLists.txt @@ -25,3 +25,5 @@ set(SRC_SYSTEM add_library(sfml-network ${SRC_NETWORK}) add_library(sfml-system ${SRC_SYSTEM}) +dolphin_disable_warnings_msvc(sfml-network) +dolphin_disable_warnings_msvc(sfml-system) diff --git a/Externals/bzip2/CMakeLists.txt b/Externals/bzip2/CMakeLists.txt index 32ad4882d3..f19d532e1b 100644 --- a/Externals/bzip2/CMakeLists.txt +++ b/Externals/bzip2/CMakeLists.txt @@ -70,6 +70,7 @@ set(BZIP2_SRCS add_library(bzip2 STATIC ${BZIP2_SRCS} ${BZIP2_PUBLIC_HDRS} ${BZIP2_PRIVATE_HDRS}) add_library(BZip2::BZip2 ALIAS bzip2) +dolphin_disable_warnings_msvc(bzip2) target_include_directories(bzip2 PUBLIC diff --git a/Externals/cpp-optparse/CMakeLists.txt b/Externals/cpp-optparse/CMakeLists.txt index f5d05fa2f3..0f92f22bfd 100644 --- a/Externals/cpp-optparse/CMakeLists.txt +++ b/Externals/cpp-optparse/CMakeLists.txt @@ -3,4 +3,5 @@ check_and_add_flag(CXX11 -std=c++11) set(SRCS OptionParser.cpp OptionParser.h) add_library(cpp-optparse STATIC ${SRCS}) +dolphin_disable_warnings_msvc(cpp-optparse) target_include_directories(cpp-optparse PUBLIC .) diff --git a/Externals/cubeb/CMakeLists.txt b/Externals/cubeb/CMakeLists.txt index 65fda6c181..7cd84dee8b 100644 --- a/Externals/cubeb/CMakeLists.txt +++ b/Externals/cubeb/CMakeLists.txt @@ -48,6 +48,7 @@ add_library(cubeb src/cubeb_log.cpp src/cubeb_strings.c $) +dolphin_disable_warnings_msvc(cubeb) target_include_directories(cubeb PUBLIC $ $ ) @@ -100,6 +101,7 @@ install( add_library(speex OBJECT src/speex/resample.c) +dolphin_disable_warnings_msvc(speex) set_target_properties(speex PROPERTIES POSITION_INDEPENDENT_CODE TRUE) target_compile_definitions(speex PRIVATE OUTSIDE_SPEEX) target_compile_definitions(speex PRIVATE FLOATING_POINT) diff --git a/Externals/curl/lib/CMakeLists.txt b/Externals/curl/lib/CMakeLists.txt index a4be4013ef..d2900d22d0 100644 --- a/Externals/curl/lib/CMakeLists.txt +++ b/Externals/curl/lib/CMakeLists.txt @@ -12,6 +12,7 @@ add_library( STATIC ${SRCS} ) +dolphin_disable_warnings_msvc(curl) target_link_libraries(curl ${MBEDTLS_LIBRARIES} z) target_compile_definitions(curl PUBLIC CURL_STATICLIB PRIVATE CURL_DISABLE_LDAP) diff --git a/Externals/discord-rpc/src/CMakeLists.txt b/Externals/discord-rpc/src/CMakeLists.txt index c49b26faf6..e3296173e0 100644 --- a/Externals/discord-rpc/src/CMakeLists.txt +++ b/Externals/discord-rpc/src/CMakeLists.txt @@ -31,6 +31,7 @@ if(WIN32) add_definitions(-DDISCORD_WINDOWS) set(BASE_RPC_SRC ${BASE_RPC_SRC} connection_win.cpp discord_register_win.cpp) add_library(discord-rpc ${BASE_RPC_SRC}) + dolphin_disable_warnings_msvc(discord-rpc) if (MSVC) if(USE_STATIC_CRT) foreach(CompilerFlag diff --git a/Externals/ed25519/CMakeLists.txt b/Externals/ed25519/CMakeLists.txt index a3a68d536f..1e0080b12b 100644 --- a/Externals/ed25519/CMakeLists.txt +++ b/Externals/ed25519/CMakeLists.txt @@ -11,3 +11,4 @@ add_library(ed25519 sc.c sha512.c verify.c) +dolphin_disable_warnings_msvc(ed25519) diff --git a/Externals/enet/CMakeLists.txt b/Externals/enet/CMakeLists.txt index f364ff7f5b..7f9a2473df 100644 --- a/Externals/enet/CMakeLists.txt +++ b/Externals/enet/CMakeLists.txt @@ -72,6 +72,7 @@ add_library(enet STATIC unix.c win32.c ) +dolphin_disable_warnings_msvc(enet) if(HAIKU) target_link_libraries(enet network) endif(HAIKU) diff --git a/Externals/fmt/CMakeLists.txt b/Externals/fmt/CMakeLists.txt index 1d07bb4adf..f6d8bd50db 100755 --- a/Externals/fmt/CMakeLists.txt +++ b/Externals/fmt/CMakeLists.txt @@ -229,6 +229,7 @@ else() endif () add_library(fmt ${FMT_SOURCES} ${FMT_HEADERS} README.rst ChangeLog.rst) +dolphin_disable_warnings_msvc(fmt) add_library(fmt::fmt ALIAS fmt) if (FMT_WERROR) diff --git a/Externals/glslang/CMakeLists.txt b/Externals/glslang/CMakeLists.txt index e6d171d8d8..df5dfa0408 100644 --- a/Externals/glslang/CMakeLists.txt +++ b/Externals/glslang/CMakeLists.txt @@ -73,6 +73,7 @@ endif() endif() add_library(glslang STATIC ${SRCS}) +dolphin_disable_warnings_msvc(glslang) target_include_directories(glslang PRIVATE diff --git a/Externals/hidapi/CMakeLists.txt b/Externals/hidapi/CMakeLists.txt index 42b16d9f01..1cf77404f0 100644 --- a/Externals/hidapi/CMakeLists.txt +++ b/Externals/hidapi/CMakeLists.txt @@ -1,6 +1,7 @@ project(hidapi) add_library(hidapi STATIC hidapi/hidapi.h) +dolphin_disable_warnings_msvc(hidapi) target_include_directories(hidapi PUBLIC hidapi) if(APPLE) diff --git a/Externals/imgui/CMakeLists.txt b/Externals/imgui/CMakeLists.txt index 3b6be85f50..16e5ee486f 100644 --- a/Externals/imgui/CMakeLists.txt +++ b/Externals/imgui/CMakeLists.txt @@ -12,6 +12,7 @@ set(SRCS ) add_library(imgui STATIC ${SRCS}) +dolphin_disable_warnings_msvc(imgui) target_include_directories(imgui PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}") target_link_libraries(imgui diff --git a/Externals/libiconv-1.14/CMakeLists.txt b/Externals/libiconv-1.14/CMakeLists.txt index 9a0660b254..571a6f791c 100644 --- a/Externals/libiconv-1.14/CMakeLists.txt +++ b/Externals/libiconv-1.14/CMakeLists.txt @@ -7,3 +7,4 @@ set(SRCS lib/iconv.c ) add_library(iconv STATIC ${SRCS}) +dolphin_disable_warnings_msvc(iconv) diff --git a/Externals/liblzma/CMakeLists.txt b/Externals/liblzma/CMakeLists.txt index 11d6c77035..dd979c5b68 100644 --- a/Externals/liblzma/CMakeLists.txt +++ b/Externals/liblzma/CMakeLists.txt @@ -207,6 +207,7 @@ set(LZMA_SRCS add_library(lzma STATIC ${LZMA_SRCS} ${LZMA_PUBLIC_HDRS}) add_library(LibLZMA::LibLZMA ALIAS lzma) +dolphin_disable_warnings_msvc(lzma) target_compile_definitions(lzma PUBLIC LZMA_API_STATIC) diff --git a/Externals/libpng/CMakeLists.txt b/Externals/libpng/CMakeLists.txt index d0da8580a6..dabe91af1d 100644 --- a/Externals/libpng/CMakeLists.txt +++ b/Externals/libpng/CMakeLists.txt @@ -39,6 +39,8 @@ add_library(png STATIC pngwutil.c ) +dolphin_disable_warnings_msvc(png) + option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations for libpng" OFF) if(PNG_HARDWARE_OPTIMIZATIONS) diff --git a/Externals/libusb/CMakeLists.txt b/Externals/libusb/CMakeLists.txt index cd3e2e943f..f3bed0d1f0 100644 --- a/Externals/libusb/CMakeLists.txt +++ b/Externals/libusb/CMakeLists.txt @@ -6,6 +6,8 @@ add_library(usb STATIC EXCLUDE_FROM_ALL libusb/libusb/strerror.c libusb/libusb/sync.c ) +dolphin_disable_warnings_msvc(usb) + set_target_properties(usb PROPERTIES VERSION 1.0.26) if(WIN32) target_include_directories(usb BEFORE PUBLIC libusb/libusb PRIVATE libusb/msvc) diff --git a/Externals/mGBA/CMakeLists.txt b/Externals/mGBA/CMakeLists.txt index 4a87c7b58c..edeea5438a 100644 --- a/Externals/mGBA/CMakeLists.txt +++ b/Externals/mGBA/CMakeLists.txt @@ -1,6 +1,7 @@ set(LIBMGBA_ONLY ON) set(USE_LZMA ON) add_subdirectory(mgba EXCLUDE_FROM_ALL) +dolphin_disable_warnings_msvc(mgba) if(NOT MSVC) target_compile_options(mgba PRIVATE -Wno-unused-parameter -Wno-unused-result -Wno-unused-variable) diff --git a/Externals/mbedtls/library/CMakeLists.txt b/Externals/mbedtls/library/CMakeLists.txt index 0a600674db..ba0b337ea1 100644 --- a/Externals/mbedtls/library/CMakeLists.txt +++ b/Externals/mbedtls/library/CMakeLists.txt @@ -189,28 +189,34 @@ endif() if(USE_STATIC_MBEDTLS_LIBRARY) add_library(${mbedcrypto_static_target} STATIC ${src_crypto}) + dolphin_disable_warnings_msvc(${mbedcrypto_static_target}) set_target_properties(${mbedcrypto_static_target} PROPERTIES OUTPUT_NAME mbedcrypto) target_link_libraries(${mbedcrypto_static_target} PUBLIC ${libs}) add_library(${mbedx509_static_target} STATIC ${src_x509}) + dolphin_disable_warnings_msvc(${mbedx509_static_target}) set_target_properties(${mbedx509_static_target} PROPERTIES OUTPUT_NAME mbedx509) target_link_libraries(${mbedx509_static_target} PUBLIC ${libs} ${mbedcrypto_static_target}) add_library(${mbedtls_static_target} STATIC ${src_tls}) + dolphin_disable_warnings_msvc(${mbedtls_static_target}) set_target_properties(${mbedtls_static_target} PROPERTIES OUTPUT_NAME mbedtls) target_link_libraries(${mbedtls_static_target} PUBLIC ${libs} ${mbedx509_static_target}) endif(USE_STATIC_MBEDTLS_LIBRARY) if(USE_SHARED_MBEDTLS_LIBRARY) add_library(${mbedcrypto_target} SHARED ${src_crypto}) + dolphin_disable_warnings_msvc(${mbedcrypto_target}) set_target_properties(${mbedcrypto_target} PROPERTIES VERSION 2.28.0 SOVERSION 7) target_link_libraries(${mbedcrypto_target} PUBLIC ${libs}) add_library(${mbedx509_target} SHARED ${src_x509}) + dolphin_disable_warnings_msvc(${mbedx509_target}) set_target_properties(${mbedx509_target} PROPERTIES VERSION 2.28.0 SOVERSION 1) target_link_libraries(${mbedx509_target} PUBLIC ${libs} ${mbedcrypto_target}) add_library(${mbedtls_target} SHARED ${src_tls}) + dolphin_disable_warnings_msvc(${mbedtls_target}) set_target_properties(${mbedtls_target} PROPERTIES VERSION 2.28.0 SOVERSION 14) target_link_libraries(${mbedtls_target} PUBLIC ${libs} ${mbedx509_target}) endif(USE_SHARED_MBEDTLS_LIBRARY) diff --git a/Externals/miniupnpc/CMakeLists.txt b/Externals/miniupnpc/CMakeLists.txt index f5d3f2e3ad..602de41c55 100644 --- a/Externals/miniupnpc/CMakeLists.txt +++ b/Externals/miniupnpc/CMakeLists.txt @@ -33,6 +33,7 @@ set(SRCS src/igd_desc_parse.c src/receivedata.c) add_library(miniupnpc STATIC ${SRCS}) +dolphin_disable_warnings_msvc(miniupnpc) target_include_directories(miniupnpc PUBLIC src) add_library(Miniupnpc::miniupnpc ALIAS miniupnpc) diff --git a/Externals/minizip/CMakeLists.txt b/Externals/minizip/CMakeLists.txt index b28e136681..4068cd85bc 100644 --- a/Externals/minizip/CMakeLists.txt +++ b/Externals/minizip/CMakeLists.txt @@ -26,6 +26,7 @@ add_library(minizip STATIC unzip.h zip.h ) +dolphin_disable_warnings_msvc(minizip) if (UNIX) target_sources(minizip PRIVATE diff --git a/Externals/pugixml/CMakeLists.txt b/Externals/pugixml/CMakeLists.txt index 30f06ae21d..11c0990658 100644 --- a/Externals/pugixml/CMakeLists.txt +++ b/Externals/pugixml/CMakeLists.txt @@ -35,6 +35,7 @@ if(BUILD_SHARED_LIBS) else() add_library(pugixml STATIC ${SOURCES}) endif() +dolphin_disable_warnings_msvc(pugixml) set_target_properties(pugixml PROPERTIES VERSION 1.8 SOVERSION 1) get_target_property(PUGIXML_VERSION_STRING pugixml VERSION) diff --git a/Externals/soundtouch/CMakeLists.txt b/Externals/soundtouch/CMakeLists.txt index 74acedfb4f..eefc3a8bba 100644 --- a/Externals/soundtouch/CMakeLists.txt +++ b/Externals/soundtouch/CMakeLists.txt @@ -16,4 +16,5 @@ set(SRCS ) add_library(SoundTouch STATIC ${SRCS}) +dolphin_disable_warnings_msvc(SoundTouch) add_definitions(-w) diff --git a/Externals/xxhash/CMakeLists.txt b/Externals/xxhash/CMakeLists.txt index 8218f801d8..1a3d637387 100644 --- a/Externals/xxhash/CMakeLists.txt +++ b/Externals/xxhash/CMakeLists.txt @@ -1,6 +1,7 @@ project(xxhash C) add_library(xxhash STATIC xxhash.c) +dolphin_disable_warnings_msvc(xxhash) target_include_directories(xxhash PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/Externals/zlib/CMakeLists.txt b/Externals/zlib/CMakeLists.txt index 6f865141a5..da707ea76d 100644 --- a/Externals/zlib/CMakeLists.txt +++ b/Externals/zlib/CMakeLists.txt @@ -86,6 +86,7 @@ set(ZLIB_SRCS ) add_library(z STATIC ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +dolphin_disable_warnings_msvc(z) add_library(ZLIB::ZLIB ALIAS z) target_include_directories(z diff --git a/Externals/zstd/CMakeLists.txt b/Externals/zstd/CMakeLists.txt index 7d9cb1baaf..77932c74e7 100644 --- a/Externals/zstd/CMakeLists.txt +++ b/Externals/zstd/CMakeLists.txt @@ -115,6 +115,7 @@ set(ZSTD_SRCS ) add_library(zstd STATIC ${ZSTD_SRCS} ${ZSTD_PUBLIC_HDRS} ${ZSTD_PRIVATE_HDRS}) +dolphin_disable_warnings_msvc(zstd) add_library(zstd::zstd ALIAS zstd) target_include_directories(zstd From 580c721c8252a6c6657e68f67bfe2cd37b9ba61b Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sun, 22 May 2022 01:19:44 +0200 Subject: [PATCH 16/16] cmake: Don't use PCH with Qt6. --- Source/Core/AudioCommon/CMakeLists.txt | 5 +++++ Source/Core/Common/CMakeLists.txt | 3 +-- Source/Core/Core/CMakeLists.txt | 5 +++++ Source/Core/DiscIO/CMakeLists.txt | 5 +++++ Source/Core/DolphinNoGUI/CMakeLists.txt | 5 +++++ Source/Core/DolphinQt/CMakeLists.txt | 3 +++ Source/Core/DolphinTool/CMakeLists.txt | 5 +++++ Source/Core/InputCommon/CMakeLists.txt | 5 +++++ Source/Core/UICommon/CMakeLists.txt | 5 +++++ Source/Core/UpdaterCommon/CMakeLists.txt | 7 ++++++- Source/Core/VideoBackends/D3D/CMakeLists.txt | 5 +++++ Source/Core/VideoBackends/D3D12/CMakeLists.txt | 5 +++++ Source/Core/VideoBackends/D3DCommon/CMakeLists.txt | 5 +++++ Source/Core/VideoBackends/Null/CMakeLists.txt | 5 +++++ Source/Core/VideoBackends/OGL/CMakeLists.txt | 5 +++++ Source/Core/VideoBackends/Software/CMakeLists.txt | 5 +++++ Source/Core/VideoBackends/Vulkan/CMakeLists.txt | 5 +++++ Source/Core/VideoCommon/CMakeLists.txt | 5 +++++ Source/Core/WinUpdater/CMakeLists.txt | 5 +++++ 19 files changed, 90 insertions(+), 3 deletions(-) diff --git a/Source/Core/AudioCommon/CMakeLists.txt b/Source/Core/AudioCommon/CMakeLists.txt index dfa20f6194..b3a9c57b42 100644 --- a/Source/Core/AudioCommon/CMakeLists.txt +++ b/Source/Core/AudioCommon/CMakeLists.txt @@ -83,3 +83,8 @@ PRIVATE cubeb SoundTouch FreeSurround) + +if(MSVC) + # Add precompiled header + target_link_libraries(audiocommon PRIVATE use_pch) +endif() diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 287680aeea..52448c9ea9 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -311,8 +311,7 @@ endif() if(MSVC) # Add precompiled header - # it will propergate down to everything that depends on common - target_link_libraries(common PUBLIC use_pch) + target_link_libraries(common PRIVATE use_pch) # We need to disable PCH for this one file, because it's C and our PCH is C++ set_source_files_properties( diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 4063e01562..e9ac274a06 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -702,3 +702,8 @@ if(UNIX) MemoryWatcher.h ) endif() + +if(MSVC) + # Add precompiled header + target_link_libraries(core PRIVATE use_pch) +endif() diff --git a/Source/Core/DiscIO/CMakeLists.txt b/Source/Core/DiscIO/CMakeLists.txt index e9627d0156..68028dbcfc 100644 --- a/Source/Core/DiscIO/CMakeLists.txt +++ b/Source/Core/DiscIO/CMakeLists.txt @@ -77,3 +77,8 @@ PRIVATE pugixml ZLIB::ZLIB ) + +if(MSVC) + # Add precompiled header + target_link_libraries(discio PRIVATE use_pch) +endif() diff --git a/Source/Core/DolphinNoGUI/CMakeLists.txt b/Source/Core/DolphinNoGUI/CMakeLists.txt index 3943582ad2..f21955d809 100644 --- a/Source/Core/DolphinNoGUI/CMakeLists.txt +++ b/Source/Core/DolphinNoGUI/CMakeLists.txt @@ -26,6 +26,11 @@ PRIVATE cpp-optparse ) +if(MSVC) + # Add precompiled header + target_link_libraries(dolphin-nogui PRIVATE use_pch) +endif() + if(USE_DISCORD_PRESENCE) target_compile_definitions(dolphin-nogui PRIVATE -DUSE_DISCORD_PRESENCE) endif() diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 3e19006952..4867d30e9d 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -396,6 +396,9 @@ if (MSVC) # Qt6 requires RTTI remove_cxx_flag_from_target(dolphin-emu "/GR-") target_compile_options(dolphin-emu PRIVATE "/GR") + else() + # Add precompiled header + target_link_libraries(audiocommon PRIVATE use_pch) endif() endif() diff --git a/Source/Core/DolphinTool/CMakeLists.txt b/Source/Core/DolphinTool/CMakeLists.txt index cba3b0218a..5e545225ec 100644 --- a/Source/Core/DolphinTool/CMakeLists.txt +++ b/Source/Core/DolphinTool/CMakeLists.txt @@ -19,5 +19,10 @@ PRIVATE cpp-optparse ) +if(MSVC) + # Add precompiled header + target_link_libraries(dolphin-tool PRIVATE use_pch) +endif() + set(CPACK_PACKAGE_EXECUTABLES ${CPACK_PACKAGE_EXECUTABLES} dolphin-tool) install(TARGETS dolphin-tool RUNTIME DESTINATION ${bindir}) diff --git a/Source/Core/InputCommon/CMakeLists.txt b/Source/Core/InputCommon/CMakeLists.txt index 4f9510d7a5..910d64d8d4 100644 --- a/Source/Core/InputCommon/CMakeLists.txt +++ b/Source/Core/InputCommon/CMakeLists.txt @@ -205,3 +205,8 @@ if(ENABLE_SDL) message(STATUS "SDL NOT found, disabling SDL input") endif() endif() + +if(MSVC) + # Add precompiled header + target_link_libraries(inputcommon PRIVATE use_pch) +endif() diff --git a/Source/Core/UICommon/CMakeLists.txt b/Source/Core/UICommon/CMakeLists.txt index 73cce4941c..2b7d5bd2a6 100644 --- a/Source/Core/UICommon/CMakeLists.txt +++ b/Source/Core/UICommon/CMakeLists.txt @@ -68,3 +68,8 @@ if(USE_DISCORD_PRESENCE) target_compile_definitions(uicommon PRIVATE -DUSE_DISCORD_PRESENCE) target_link_libraries(uicommon PRIVATE discord-rpc) endif() + +if(MSVC) + # Add precompiled header + target_link_libraries(uicommon PRIVATE use_pch) +endif() diff --git a/Source/Core/UpdaterCommon/CMakeLists.txt b/Source/Core/UpdaterCommon/CMakeLists.txt index e32907da71..c026cd577d 100644 --- a/Source/Core/UpdaterCommon/CMakeLists.txt +++ b/Source/Core/UpdaterCommon/CMakeLists.txt @@ -10,4 +10,9 @@ target_link_libraries(updatercommon PRIVATE ZLIB::ZLIB ed25519 cpp-optparse -) \ No newline at end of file +) + +if(MSVC) + # Add precompiled header + target_link_libraries(updatercommon PRIVATE use_pch) +endif() diff --git a/Source/Core/VideoBackends/D3D/CMakeLists.txt b/Source/Core/VideoBackends/D3D/CMakeLists.txt index b8ebb509b9..f296040526 100644 --- a/Source/Core/VideoBackends/D3D/CMakeLists.txt +++ b/Source/Core/VideoBackends/D3D/CMakeLists.txt @@ -29,3 +29,8 @@ PUBLIC videocommon videod3dcommon ) + +if(MSVC) + # Add precompiled header + target_link_libraries(videod3d PRIVATE use_pch) +endif() diff --git a/Source/Core/VideoBackends/D3D12/CMakeLists.txt b/Source/Core/VideoBackends/D3D12/CMakeLists.txt index 5b440775c0..16f458e2e9 100644 --- a/Source/Core/VideoBackends/D3D12/CMakeLists.txt +++ b/Source/Core/VideoBackends/D3D12/CMakeLists.txt @@ -35,3 +35,8 @@ PUBLIC videocommon videod3dcommon ) + +if(MSVC) + # Add precompiled header + target_link_libraries(videod3d12 PRIVATE use_pch) +endif() diff --git a/Source/Core/VideoBackends/D3DCommon/CMakeLists.txt b/Source/Core/VideoBackends/D3DCommon/CMakeLists.txt index c3eb521252..e4e586e47a 100644 --- a/Source/Core/VideoBackends/D3DCommon/CMakeLists.txt +++ b/Source/Core/VideoBackends/D3DCommon/CMakeLists.txt @@ -12,3 +12,8 @@ PUBLIC common videocommon ) + +if(MSVC) + # Add precompiled header + target_link_libraries(videod3dcommon PRIVATE use_pch) +endif() diff --git a/Source/Core/VideoBackends/Null/CMakeLists.txt b/Source/Core/VideoBackends/Null/CMakeLists.txt index 24ff04aaf0..e95877323f 100644 --- a/Source/Core/VideoBackends/Null/CMakeLists.txt +++ b/Source/Core/VideoBackends/Null/CMakeLists.txt @@ -17,3 +17,8 @@ PUBLIC common videocommon ) + +if(MSVC) + # Add precompiled header + target_link_libraries(videonull PRIVATE use_pch) +endif() diff --git a/Source/Core/VideoBackends/OGL/CMakeLists.txt b/Source/Core/VideoBackends/OGL/CMakeLists.txt index 8b4b27a571..9a9d9caf2d 100644 --- a/Source/Core/VideoBackends/OGL/CMakeLists.txt +++ b/Source/Core/VideoBackends/OGL/CMakeLists.txt @@ -33,3 +33,8 @@ PUBLIC PRIVATE ${X11_LIBRARIES} ) + +if(MSVC) + # Add precompiled header + target_link_libraries(videoogl PRIVATE use_pch) +endif() diff --git a/Source/Core/VideoBackends/Software/CMakeLists.txt b/Source/Core/VideoBackends/Software/CMakeLists.txt index 983cd3df3f..752fac48cc 100644 --- a/Source/Core/VideoBackends/Software/CMakeLists.txt +++ b/Source/Core/VideoBackends/Software/CMakeLists.txt @@ -41,3 +41,8 @@ PUBLIC common videocommon ) + +if(MSVC) + # Add precompiled header + target_link_libraries(videosoftware PRIVATE use_pch) +endif() diff --git a/Source/Core/VideoBackends/Vulkan/CMakeLists.txt b/Source/Core/VideoBackends/Vulkan/CMakeLists.txt index 74127f3aba..110733e613 100644 --- a/Source/Core/VideoBackends/Vulkan/CMakeLists.txt +++ b/Source/Core/VideoBackends/Vulkan/CMakeLists.txt @@ -62,3 +62,8 @@ SYSTEM PRIVATE ${CMAKE_SOURCE_DIR}/Externals/glslang/SPIRV ${CMAKE_SOURCE_DIR}/Externals/glslang ) + +if(MSVC) + # Add precompiled header + target_link_libraries(videovulkan PRIVATE use_pch) +endif() diff --git a/Source/Core/VideoCommon/CMakeLists.txt b/Source/Core/VideoCommon/CMakeLists.txt index 3504bc63d1..ec8f89c829 100644 --- a/Source/Core/VideoCommon/CMakeLists.txt +++ b/Source/Core/VideoCommon/CMakeLists.txt @@ -180,3 +180,8 @@ if(FFmpeg_FOUND) ) endif() endif() + +if(MSVC) + # Add precompiled header + target_link_libraries(videocommon PRIVATE use_pch) +endif() diff --git a/Source/Core/WinUpdater/CMakeLists.txt b/Source/Core/WinUpdater/CMakeLists.txt index d31ef9bacb..a57d039209 100644 --- a/Source/Core/WinUpdater/CMakeLists.txt +++ b/Source/Core/WinUpdater/CMakeLists.txt @@ -12,3 +12,8 @@ target_link_libraries(winupdater PRIVATE ) set_target_properties(winupdater PROPERTIES OUTPUT_NAME "Updater") + +if(MSVC) + # Add precompiled header + target_link_libraries(winupdater PRIVATE use_pch) +endif()