Merge pull request #8101 from spycrab/cmake_qol

[Windows] CMake Quality of Life improvements
This commit is contained in:
spycrab 2019-05-16 20:55:10 +02:00 committed by GitHub
commit dce056b7f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 18 deletions

View File

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

View File

@ -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": [
{

View File

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

View File

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

View File

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