diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dc09a3bb6..d3d05385ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,10 @@ if (POLICY CMP0117) cmake_policy(SET CMP0117 NEW) # MSVC RTTI flag will not be added by default. endif() +if (POLICY CMP0141) + cmake_policy(SET CMP0141 NEW) # MSVC debug information format flags are selected by an abstraction. +endif() + # Minimum OS X version. # This is inserted into the Info.plist as well. set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15.0" CACHE STRING "") diff --git a/CMakeSettings.json b/CMakeSettings.json index 491c378ec8..72ac09bacc 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -9,10 +9,6 @@ "buildRoot": "${workspaceRoot}\\Build\\${name}", "cmakeCommandArgs": "", "variables": [ - { - "name": "CMAKE_PREFIX_PATH", - "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64" - } ] }, { @@ -24,10 +20,6 @@ "buildRoot": "${workspaceRoot}\\Build\\${name}", "cmakeCommandArgs": "", "variables": [ - { - "name": "CMAKE_PREFIX_PATH", - "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\x64" - } ] }, { @@ -39,10 +31,6 @@ "buildRoot": "${workspaceRoot}\\Build\\${name}", "cmakeCommandArgs": "", "variables": [ - { - "name": "CMAKE_PREFIX_PATH", - "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64" - }, { "name": "CMAKE_SYSTEM_NAME", "value": "Windows" @@ -62,10 +50,6 @@ "buildRoot": "${workspaceRoot}\\Build\\${name}", "cmakeCommandArgs": "", "variables": [ - { - "name": "CMAKE_PREFIX_PATH", - "value": "${workspaceRoot}\\Externals\\Qt\\Qt6.3.0\\ARM64" - }, { "name": "CMAKE_SYSTEM_NAME", "value": "Windows" diff --git a/Externals/mbedtls/CMakeLists.txt b/Externals/mbedtls/CMakeLists.txt index ab43a40899..6f448876cb 100644 --- a/Externals/mbedtls/CMakeLists.txt +++ b/Externals/mbedtls/CMakeLists.txt @@ -227,12 +227,14 @@ endif(CMAKE_COMPILER_IS_IAR) if(CMAKE_COMPILER_IS_MSVC) # Strictest warnings - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") + # Dolphin/MSVC: we want to disable all warnings for externals + #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3") endif(CMAKE_COMPILER_IS_MSVC) if(MBEDTLS_FATAL_WARNINGS) if(CMAKE_COMPILER_IS_MSVC) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") + # Dolphin/MSVC: we want to disable all warnings for externals + #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX") endif(CMAKE_COMPILER_IS_MSVC) if(CMAKE_COMPILER_IS_CLANG OR CMAKE_COMPILER_IS_GNU) diff --git a/Source/Core/Common/WindowsRegistry.h b/Source/Core/Common/WindowsRegistry.h index 4472a37e0e..8a4705e7fe 100644 --- a/Source/Core/Common/WindowsRegistry.h +++ b/Source/Core/Common/WindowsRegistry.h @@ -1,6 +1,9 @@ #pragma once #include +#include + +#include "Common/CommonTypes.h" namespace WindowsRegistry { diff --git a/Source/Core/Common/x64CPUDetect.cpp b/Source/Core/Common/x64CPUDetect.cpp index dedf02c05e..11dfcf0b51 100644 --- a/Source/Core/Common/x64CPUDetect.cpp +++ b/Source/Core/Common/x64CPUDetect.cpp @@ -4,9 +4,11 @@ #include "Common/CPUDetect.h" #ifdef _WIN32 +#include #include #endif +#include #include #include #include diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index a9e07afe0b..a5463c8c27 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -3,11 +3,11 @@ if(POLICY CMP0084) cmake_policy(SET CMP0084 NEW) endif() -if (NOT QT_DIR AND MSVC) +if (MSVC) if(_M_ARM_64) - set(QT_DIR "${CMAKE_SOURCE_DIR}/Externals/Qt/Qt6.3.0/ARM64/lib/cmake/Qt6") + list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/Externals/Qt/Qt6.3.0/ARM64") else() - set(QT_DIR "${CMAKE_SOURCE_DIR}/Externals/Qt/Qt6.3.0/x64/lib/cmake/Qt6") + list(APPEND CMAKE_PREFIX_PATH "${CMAKE_SOURCE_DIR}/Externals/Qt/Qt6.3.0/x64") endif() endif() diff --git a/Source/PCH/CMakeLists.txt b/Source/PCH/CMakeLists.txt index 2ee6adaa12..50f3fa234b 100644 --- a/Source/PCH/CMakeLists.txt +++ b/Source/PCH/CMakeLists.txt @@ -2,6 +2,12 @@ # 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 +# linking against this interface libary will cause targets to enable PCH +add_library(use_pch INTERFACE) + +# Uncomment this return to disable PCH +#return() + add_library(build_pch pch.h pch.cpp) # fmt/format.h is included in the PCH @@ -15,8 +21,28 @@ target_compile_options(build_pch PRIVATE /Ycpch.h) 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(build_pch PUBLIC /Z7 /Gm-) +# the binary. However MSVC gets noisy if you set both /Zi and /Z7 +if (POLICY CMP0141) + # CMake 3.25 has a policy that makes us control this somewhat sanely + set_property(TARGET build_pch PROPERTY MSVC_DEBUG_INFORMATION_FORMAT "$<$:Embedded>") + + # Unfortnually, properties don't propagate. So we also set it globally via parent scope + set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$:Embedded>" PARENT_SCOPE) +else() + if (CMAKE_CXX_FLAGS_DEBUG MATCHES "/Zi") + # Otherwise we do an ugly string replace to remove it from FLAGS_DEBUG + string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") + string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") + + # and also overwrite the version in the parent scope + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}" PARENT_SCOPE) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}" PARENT_SCOPE) + + target_compile_options(build_pch PUBLIC "$<$:/Z7>") + endif() +endif() +# Setting /Z7 also requires us to disable minimal rebuilds. +target_compile_options(build_pch PUBLIC "$<$:/Gm->") # 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 @@ -30,8 +56,7 @@ 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) +# link the pch into anything that depends on use_pch target_link_libraries(use_pch INTERFACE build_pch) # targets which use the pch need these compile options