Skip to content
Permalink
Browse files

Merge pull request #8101 from spycrab/cmake_qol

[Windows] CMake Quality of Life improvements
  • Loading branch information...
spycrab committed May 16, 2019
2 parents ec73406 + bab0008 commit dce056b7f980426f7b08f7d00dc8b2a9a5e59fd4
Showing with 34 additions and 18 deletions.
  1. +2 −2 CMakeLists.txt
  2. +6 −6 CMakeSettings.json
  3. +4 −0 Source/CMakeLists.txt
  4. +18 −10 Source/Core/DolphinQt/CMakeLists.txt
  5. +4 −0 Source/PCH/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
@@ -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": [
{
@@ -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
@@ -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)

@@ -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})

1 comment on commit dce056b

@NarryG

This comment has been minimized.

Copy link
Contributor

NarryG commented on dce056b May 19, 2019

What is gained by using the Ninja generator over MSVC?

Please sign in to comment.
You can’t perform that action at this time.