diff --git a/CMakeLists.txt b/CMakeLists.txt index e05678f461..caec4dc75a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,14 @@ endif() # as defined above. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries) +if (MSVC) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +endif() + # setup CCache include(CCache) @@ -361,6 +369,11 @@ if(ENABLE_VTUNE) ) endif() +if(WIN32) + message(STATUS "Building for Windows, disabling NoGUI frontend.") + set(ENABLE_NOGUI OFF) +endif() + if(ANDROID) message(STATUS "Building for Android") if(NOT ENABLE_HEADLESS) @@ -596,7 +609,7 @@ endif() message(STATUS "Using static FreeSurround from Externals") add_subdirectory(Externals/FreeSurround) -if (APPLE) +if (APPLE OR WIN32) message(STATUS "Using ed25519 from Externals") add_subdirectory(Externals/ed25519) endif() diff --git a/CMakeSettings.json b/CMakeSettings.json index e6f3349a3a..49676259a3 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -1,20 +1,38 @@ -{ +{ "configurations": [ { - "name": "x64-Debug", - "generator": "Visual Studio 15 2017 Win64", - "configurationType": "Debug", - "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", + "name": "Release", + "configurationType": "Release", + "generator": "Visual Studio 16 2019 Win64", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildCommandArgs": "-m -p:PreferredToolArchitecture=x64", + "buildRoot": "${workspaceRoot}\\build", "cmakeCommandArgs": "", - "buildCommandArgs": "-m -p:PreferredToolArchitecture=x64" + "variables": [ + { + "name": "Qt5_DIR", + "value": "${workspaceRoot}\\Externals\\Qt\\Qt5.11.1\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" + } + ] }, { - "name": "x64-Release", - "generator": "Visual Studio 15 2017 Win64", - "configurationType": "Release", - "buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}", + "name": "Debug", + "generator": "Visual Studio 16 2019 Win64", + "configurationType": "Debug", + "inheritEnvironments": [ "msvc_x64_x64" ], + "buildCommandArgs": "-m -p:PreferredToolArchitecture=x64", + "buildRoot": "${workspaceRoot}\\build", "cmakeCommandArgs": "", - "buildCommandArgs": "-m -p:PreferredToolArchitecture=x64" + "variables": [ + { + "name": "CMAKE_BUILD_TYPE", + "value": "Debug" + }, + { + "name": "Qt5_DIR", + "value": "${workspaceRoot}\\Externals\\Qt\\Qt5.11.1\\5.11.1\\msvc2017_64\\lib\\cmake\\Qt5" + } + ] } ] -} +} \ No newline at end of file diff --git a/Externals/Qt b/Externals/Qt index b344ea0961..e5b972af93 160000 --- a/Externals/Qt +++ b/Externals/Qt @@ -1 +1 @@ -Subproject commit b344ea0961dba93a1a38502ac4cc77b981cfc681 +Subproject commit e5b972af9368c8498546151a6961cd0fe87f13b2 diff --git a/Externals/libpng/CMakeLists.txt b/Externals/libpng/CMakeLists.txt index 4396e4a34c..622e65b207 100644 --- a/Externals/libpng/CMakeLists.txt +++ b/Externals/libpng/CMakeLists.txt @@ -23,6 +23,8 @@ PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ) +target_link_libraries(png PUBLIC z) + if(NOT MSVC) target_compile_options(png PRIVATE diff --git a/Externals/minizip/CMakeLists.txt b/Externals/minizip/CMakeLists.txt index 3b8d84043f..cfd1f88d59 100644 --- a/Externals/minizip/CMakeLists.txt +++ b/Externals/minizip/CMakeLists.txt @@ -13,4 +13,6 @@ endif() add_library(minizip STATIC ${SRCS}) target_include_directories(minizip PUBLIC .) +target_link_libraries(minizip PUBLIC z) + add_library(MiniZip::minizip ALIAS minizip) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 7d435e1ca2..8d6f475fe2 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -7,12 +7,47 @@ if(CMAKE_SYSTEM_NAME MATCHES "Windows") add_definitions(-D_SCL_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) endif() set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +if (MSVC) + # Set warning level to 4 + add_compile_options(/W4) + + # 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) + +endif() + # These aren't actually needed for C11/C++11 # but some dependencies require them (LLVM, libav). add_definitions(-D__STDC_LIMIT_MACROS) diff --git a/Source/Core/AudioCommon/CMakeLists.txt b/Source/Core/AudioCommon/CMakeLists.txt index 577bdb41fb..8d58daab72 100644 --- a/Source/Core/AudioCommon/CMakeLists.txt +++ b/Source/Core/AudioCommon/CMakeLists.txt @@ -57,16 +57,8 @@ if(WIN32) ) target_link_libraries(audiocommon PRIVATE audiocommon_xaudio27) - set(ENV{OPENALDIR} ${PROJECT_SOURCE_DIR}/Externals/OpenAL) # Dolphin loads openal32.dll at runtime - find_package(OpenAL) - if(OPENAL_FOUND) - message(STATUS "OpenAL found, enabling OpenAL sound backend") - target_sources(audiocommon PRIVATE OpenALStream.cpp) - target_link_libraries(audiocommon PRIVATE OpenAL::OpenAL) - else() - message(STATUS "OpenAL NOT found in Externals") - endif() + target_sources(audiocommon PRIVATE OpenALStream.cpp) endif() target_link_libraries(audiocommon PRIVATE cubeb SoundTouch FreeSurround) diff --git a/Source/Core/CMakeLists.txt b/Source/Core/CMakeLists.txt index b1a19522bf..d176fcbf25 100644 --- a/Source/Core/CMakeLists.txt +++ b/Source/Core/CMakeLists.txt @@ -15,7 +15,15 @@ if(ENABLE_QT) add_subdirectory(DolphinQt) endif() -if (APPLE) +if (APPLE OR WIN32) add_subdirectory(UpdaterCommon) +endif() + +if (APPLE) add_subdirectory(MacUpdater) endif() + + +if (WIN32) + add_subdirectory(WinUpdater) +endif() diff --git a/Source/Core/Common/CMakeLists.txt b/Source/Core/Common/CMakeLists.txt index 21f25d750e..1f544f4625 100644 --- a/Source/Core/Common/CMakeLists.txt +++ b/Source/Core/Common/CMakeLists.txt @@ -69,6 +69,14 @@ if (APPLE) ${COREFOUNDATION_LIBRARY} ${IOK_LIBRARY} ) +elseif(WIN32) + target_link_libraries(common + PRIVATE + kernel32.lib + shlwapi.lib + opengl32.lib + winmm.lib + ) endif() if(ANDROID) @@ -78,6 +86,7 @@ if(ANDROID) ) elseif(WIN32) target_sources(common PRIVATE + LdrWatcher.cpp Logging/ConsoleListenerWin.cpp ) else() diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 60c23769ef..f72a43861d 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -343,6 +343,7 @@ if(WIN32) setupapi.lib iphlpapi.lib ) + target_compile_definitions(core PRIVATE "-D_WINSOCK_DEPRECATED_NO_WARNINGS") elseif(APPLE) target_sources(core PRIVATE HW/EXI/BBA-TAP/TAP_Apple.cpp diff --git a/Source/Core/Core/IOS/FS/FileSystem.h b/Source/Core/Core/IOS/FS/FileSystem.h index 2379ebe80b..6266ba6979 100644 --- a/Source/Core/Core/IOS/FS/FileSystem.h +++ b/Source/Core/Core/IOS/FS/FileSystem.h @@ -9,6 +9,11 @@ #include #include +#ifdef _WIN32 +// TODO: Horrible hack, remove ASAP! +#include +#endif + #include "Common/CommonTypes.h" #include "Common/Result.h" diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index 27eda16cb4..a5042bfb76 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -1,3 +1,7 @@ +if (NOT Qt5_DIR AND MSVC) +set(Qt5_DIR "${CMAKE_SOURCE_DIR}/Externals/Qt5.11.1/5.11.1/msvc2017_64/lib/cmake/Qt5") +endif() + find_package(Qt5 5.9 REQUIRED COMPONENTS Gui Widgets) set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_FEATURES "") @@ -107,7 +111,6 @@ add_executable(dolphin-emu QtUtils/FlowLayout.cpp QtUtils/ModalMessageBox.cpp QtUtils/ImageConverter.cpp - QtUtils/SignalDaemon.cpp QtUtils/WindowActivationEventFilter.cpp QtUtils/WinIconHelper.cpp QtUtils/WrapInScrollArea.cpp @@ -130,6 +133,10 @@ add_executable(dolphin-emu Updater.cpp ) +if (NOT WIN32) + target_sources(dolphin-emu PRIVATE QtUtils/SignalDaemon.cpp) +endif() + target_compile_definitions(dolphin-emu PRIVATE -DQT_USE_QSTRINGBUILDER @@ -152,11 +159,71 @@ PRIVATE ) if(WIN32) - target_sources(dolphin-emu PRIVATE DolphinQt.manifest) + target_sources(dolphin-emu PRIVATE DolphinQt.manifest DolphinQt.rc) + + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + set(Dolphin_NAME "DolphinD") + else() + set(Dolphin_NAME "Dolphin") + endif() + + set_target_properties(dolphin-emu PROPERTIES + WIN32_EXECUTABLE TRUE + OUTPUT_NAME ${Dolphin_NAME} + ) + + target_compile_options(dolphin-emu PRIVATE "-D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING") + + # Copy Sys dir + set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/Data/Sys") + file(GLOB_RECURSE resources RELATIVE "${CMAKE_SOURCE_DIR}/Data" "${CMAKE_SOURCE_DIR}/Data/Sys/*") + + foreach(res ${resources}) + configure_file("${CMAKE_SOURCE_DIR}/Data/${res}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${res}" COPYONLY) + endforeach() + + # Copy qt.conf + configure_file(qt.conf.win "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf" COPYONLY) + + # Copy plugins + set (Qt5_PLUGINS_DIR "${Qt5_DIR}/../../../plugins") + file(GLOB_RECURSE plugins RELATIVE "${Qt5_PLUGINS_DIR}" "${Qt5_PLUGINS_DIR}/*.dll") + + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + list(FILTER plugins INCLUDE REGEX ".*d.dll") + else() + list(FILTER plugins EXCLUDE REGEX ".*d.dll") + endif() + + foreach(plugin ${plugins}) + configure_file("${Qt5_PLUGINS_DIR}/${plugin}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/QtPlugins/${plugin}" COPYONLY) + endforeach() + + # Copy DLLs + set (Qt5_DLL_DIR "${Qt5_DIR}/../../../bin") + + file(GLOB_RECURSE dlls RELATIVE "${Qt5_DLL_DIR}" "${Qt5_DLL_DIR}/*.dll") + + if (CMAKE_BUILD_TYPE STREQUAL "Debug") + list(FILTER dlls INCLUDE REGEX ".*d.dll") + else() + list(FILTER dlls EXCLUDE REGEX ".*d.dll") + endif() + + foreach(dll ${dlls}) + configure_file("${Qt5_DLL_DIR}/${dll}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${dll}" COPYONLY) + endforeach() + endif() # Handle localization find_package(Gettext) + +if(WIN32 AND NOT Gettext_FOUND) + message(STATUS "Using Gettext from Externals") + set(GETTEXT_MSGFMT_EXECUTABLE "${CMAKE_SOURCE_DIR}/Externals/gettext/msgfmt.exe") +endif() + if(GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE) set(pot_file "${CMAKE_SOURCE_DIR}/Languages/po/dolphin-emu.pot") file(GLOB LINGUAS ${CMAKE_SOURCE_DIR}/Languages/po/*.po) @@ -179,12 +246,21 @@ if(GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE) install(FILES ${mo} DESTINATION share/locale/${lang}/LC_MESSAGES) endif() - add_custom_command(OUTPUT ${mo} - COMMAND cmake -E make_directory ${mo_dir} - COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${po} ${pot_file} - COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo} ${po} - DEPENDS ${po} - ) + if(WIN32) + add_custom_command(OUTPUT ${mo} + COMMAND ${CMAKE_COMMAND} -E make_directory ${mo_dir} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo} ${po} + COMMAND ${CMAKE_COMMAND} -E copy ${mo} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Languages/${lang}/dolphin-emu.mo + DEPENDS ${po} + ) + else() + add_custom_command(OUTPUT ${mo} + COMMAND ${CMAKE_COMMAND} -E make_directory ${mo_dir} + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} --quiet --update --backup=none -s ${po} ${pot_file} + COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} -o ${mo} ${po} + DEPENDS ${po} + ) + endif() endforeach() endif() diff --git a/Source/Core/DolphinQt/qt.conf.win b/Source/Core/DolphinQt/qt.conf.win new file mode 100644 index 0000000000..4931bd1000 --- /dev/null +++ b/Source/Core/DolphinQt/qt.conf.win @@ -0,0 +1,2 @@ +[Paths] +Plugins = ./QtPlugins diff --git a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h index 9383ec07f0..fff118d280 100644 --- a/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h +++ b/Source/Core/InputCommon/ControllerEmu/ControlGroup/ControlGroup.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include #include diff --git a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.h b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.h index 1772b32817..419a942cb4 100644 --- a/Source/Core/InputCommon/ControllerInterface/DInput/DInput.h +++ b/Source/Core/InputCommon/ControllerInterface/DInput/DInput.h @@ -8,6 +8,7 @@ #include #include +#include #include "InputCommon/ControllerInterface/DInput/DInput8.h" diff --git a/Source/Core/InputCommon/ControllerInterface/Device.cpp b/Source/Core/InputCommon/ControllerInterface/Device.cpp index 7624b359d1..38b11a932b 100644 --- a/Source/Core/InputCommon/ControllerInterface/Device.cpp +++ b/Source/Core/InputCommon/ControllerInterface/Device.cpp @@ -4,6 +4,7 @@ #include "InputCommon/ControllerInterface/Device.h" +#include #include #include #include diff --git a/Source/Core/UICommon/VideoUtils.cpp b/Source/Core/UICommon/VideoUtils.cpp index 3a9dcbd428..73c88a743a 100644 --- a/Source/Core/UICommon/VideoUtils.cpp +++ b/Source/Core/UICommon/VideoUtils.cpp @@ -7,6 +7,10 @@ #include "Common/Assert.h" #include "VideoCommon/VideoConfig.h" +#ifdef _WIN32 +#include +#endif + #if defined(HAVE_XRANDR) && HAVE_XRANDR #include "UICommon/X11Utils.h" #endif diff --git a/Source/Core/VideoBackends/D3D/CMakeLists.txt b/Source/Core/VideoBackends/D3D/CMakeLists.txt index b80d9df818..0b4a859ec4 100644 --- a/Source/Core/VideoBackends/D3D/CMakeLists.txt +++ b/Source/Core/VideoBackends/D3D/CMakeLists.txt @@ -17,6 +17,7 @@ add_library(videod3d PerfQuery.h Render.cpp Render.h + SwapChain.cpp VertexManager.cpp VertexManager.h VideoBackend.h diff --git a/Source/Core/VideoBackends/D3DCommon/CMakeLists.txt b/Source/Core/VideoBackends/D3DCommon/CMakeLists.txt index ba24ba133f..fa624d54b7 100644 --- a/Source/Core/VideoBackends/D3DCommon/CMakeLists.txt +++ b/Source/Core/VideoBackends/D3DCommon/CMakeLists.txt @@ -11,5 +11,4 @@ target_link_libraries(videod3dcommon PUBLIC common videocommon - videod3dcommon ) diff --git a/Source/Core/WinUpdater/CMakeLists.txt b/Source/Core/WinUpdater/CMakeLists.txt new file mode 100644 index 0000000000..d31ef9bacb --- /dev/null +++ b/Source/Core/WinUpdater/CMakeLists.txt @@ -0,0 +1,14 @@ +set (MANIFEST_FILE Updater.exe.manifest) + +add_executable(winupdater WIN32 + Main.cpp + WinUI.cpp + ${MANIFEST_FILE}) + +target_link_libraries(winupdater PRIVATE + uicommon + updatercommon + Comctl32 +) + +set_target_properties(winupdater PROPERTIES OUTPUT_NAME "Updater")