diff --git a/CMakeLists.txt b/CMakeLists.txt index caec4dc75a..ff9064b989 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,12 +107,12 @@ endif() # as defined above. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Binaries) -if (MSVC) +if (WIN32) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Binary) 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 diff --git a/CMakeSettings.json b/CMakeSettings.json index 49676259a3..0157a0940b 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -3,10 +3,10 @@ { "name": "Release", "configurationType": "Release", - "generator": "Visual Studio 16 2019 Win64", + "generator": "Ninja", "inheritEnvironments": [ "msvc_x64_x64" ], - "buildCommandArgs": "-m -p:PreferredToolArchitecture=x64", - "buildRoot": "${workspaceRoot}\\build", + "buildCommandArgs": "", + "buildRoot": "${workspaceRoot}\\Build\\${name}", "cmakeCommandArgs": "", "variables": [ { @@ -17,11 +17,11 @@ }, { "name": "Debug", - "generator": "Visual Studio 16 2019 Win64", "configurationType": "Debug", + "generator": "Ninja", "inheritEnvironments": [ "msvc_x64_x64" ], - "buildCommandArgs": "-m -p:PreferredToolArchitecture=x64", - "buildRoot": "${workspaceRoot}\\build", + "buildCommandArgs": "", + "buildRoot": "${workspaceRoot}\\Build\\${name}", "cmakeCommandArgs": "", "variables": [ { diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8d6f475fe2..69ca995ecc 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -46,6 +46,10 @@ if (MSVC) # All files are encoded as UTF-8 add_compile_options(/utf-8) + # Use PCH + add_subdirectory(PCH) + add_definitions(/I${PCH_DIRECTORY}) + add_definitions(/Yu${PCH_PATH}) endif() # These aren't actually needed for C11/C++11 diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index a5042bfb76..0072753db9 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -175,15 +175,19 @@ if(WIN32) 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() + add_custom_command(TARGET dolphin-emu POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_SOURCE_DIR}/Data/Sys" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Sys" + ) # Copy qt.conf - configure_file(qt.conf.win "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf" COPYONLY) + add_custom_command(TARGET dolphin-emu POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/qt.conf.win" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qt.conf" + ) + + # Create QtPlugins directory + add_custom_command(TARGET dolphin-emu POST_BUILD + COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/QtPlugins" + ) # Copy plugins set (Qt5_PLUGINS_DIR "${Qt5_DIR}/../../../plugins") @@ -196,7 +200,9 @@ if(WIN32) endif() foreach(plugin ${plugins}) - configure_file("${Qt5_PLUGINS_DIR}/${plugin}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/QtPlugins/${plugin}" COPYONLY) + add_custom_command(TARGET dolphin-emu POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${Qt5_PLUGINS_DIR}/${plugin}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/QtPlugins/${plugin}" + ) endforeach() # Copy DLLs @@ -211,7 +217,9 @@ if(WIN32) endif() foreach(dll ${dlls}) - configure_file("${Qt5_DLL_DIR}/${dll}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${dll}" COPYONLY) + add_custom_command(TARGET dolphin-emu POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different "${Qt5_DLL_DIR}/${dll}" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" + ) endforeach() endif() @@ -224,7 +232,7 @@ if(WIN32 AND NOT Gettext_FOUND) set(GETTEXT_MSGFMT_EXECUTABLE "${CMAKE_SOURCE_DIR}/Externals/gettext/msgfmt.exe") endif() -if(GETTEXT_MSGMERGE_EXECUTABLE AND GETTEXT_MSGFMT_EXECUTABLE) +if(GETTEXT_MSGFMT_EXECUTABLE) set(pot_file "${CMAKE_SOURCE_DIR}/Languages/po/dolphin-emu.pot") file(GLOB LINGUAS ${CMAKE_SOURCE_DIR}/Languages/po/*.po) diff --git a/Source/PCH/CMakeLists.txt b/Source/PCH/CMakeLists.txt new file mode 100644 index 0000000000..0e214789ad --- /dev/null +++ b/Source/PCH/CMakeLists.txt @@ -0,0 +1,4 @@ +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}) \ No newline at end of file