From 152a71546fcacb1155eee4fad504252d22bc5e1f Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Sun, 22 Oct 2017 03:34:15 +0200 Subject: [PATCH 1/6] Add DPI awareness support for MSVC compiling for Win8.1 and Win10 --- CMakeLists.txt | 14 ++++++++++++++ dpimanifest.manifest | 28 ++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 dpimanifest.manifest diff --git a/CMakeLists.txt b/CMakeLists.txt index fb3cda02e..8fb0e786f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1295,3 +1295,17 @@ foreach(target ${TARGETS_DEP}) target_compile_options(${target} PRIVATE /W0) endif() endforeach() + +if(MSVC) + if(CMAKE_VERSION VERSION_LESS 3.4) + message(WARNING "CMake version 3.4 or newer is required to enable dpi awareness") + else() + add_custom_command( + TARGET ${CLIENT_EXECUTABLE} + POST_BUILD + COMMAND + "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}/dpimanifest.manifest\" -inputresource:\"${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_EXECUTABLE}.exe\"\;\#1 -outputresource:\"${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_EXECUTABLE}.exe\"\;\#1 + COMMENT "Adding DPI awareness" + ) + endif() +endif() \ No newline at end of file diff --git a/dpimanifest.manifest b/dpimanifest.manifest new file mode 100644 index 000000000..9fac79355 --- /dev/null +++ b/dpimanifest.manifest @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + True/PM + + + + \ No newline at end of file From 907622e1082749faff564c9c7d838273fb6ace34 Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Sun, 22 Oct 2017 04:10:21 +0200 Subject: [PATCH 2/6] don't read the manifest of the target --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fb0e786f..d62a0d32d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1304,7 +1304,7 @@ if(MSVC) TARGET ${CLIENT_EXECUTABLE} POST_BUILD COMMAND - "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}/dpimanifest.manifest\" -inputresource:\"${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_EXECUTABLE}.exe\"\;\#1 -outputresource:\"${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_EXECUTABLE}.exe\"\;\#1 + "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}/dpimanifest.manifest\" -outputresource:\"${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_EXECUTABLE}.exe\"\;\#1 COMMENT "Adding DPI awareness" ) endif() From 162b24c2b3a0f43e91433838f35d5590d4beb395 Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Sun, 22 Oct 2017 04:52:33 +0200 Subject: [PATCH 3/6] respect the CFG dir --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d62a0d32d..cf2380418 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1304,7 +1304,7 @@ if(MSVC) TARGET ${CLIENT_EXECUTABLE} POST_BUILD COMMAND - "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}/dpimanifest.manifest\" -outputresource:\"${CMAKE_CURRENT_BINARY_DIR}/${CLIENT_EXECUTABLE}.exe\"\;\#1 + "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}/dpimanifest.manifest\" -outputresource:\"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CLIENT_EXECUTABLE}.exe\"\;\#1 COMMENT "Adding DPI awareness" ) endif() From 9a4efe758cbce9c167db73cf4d8e601e0f6cae60 Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Sun, 22 Oct 2017 16:44:55 +0200 Subject: [PATCH 4/6] use proper CMake 3.4 support for manifest files --- CMakeLists.txt | 12 +++++++----- dpimanifest.manifest | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf2380418..4e2127f7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1297,15 +1297,17 @@ foreach(target ${TARGETS_DEP}) endforeach() if(MSVC) - if(CMAKE_VERSION VERSION_LESS 3.4) - message(WARNING "CMake version 3.4 or newer is required to enable dpi awareness") - else() + if(CMAKE_VERSION VERSION_LESS 3) + message(WARNING "CMake version 3 or newer is required to enable dpi awareness") + elseif(CMAKE_VERSION VERSION_LESS 3.4) add_custom_command( TARGET ${CLIENT_EXECUTABLE} POST_BUILD COMMAND - "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}/dpimanifest.manifest\" -outputresource:\"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CLIENT_EXECUTABLE}.exe\"\;\#1 + "mt.exe" -manifest \"${CMAKE_SOURCE_DIR}/dpimanifest.manifest\" -outputresource:\"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CLIENT_EXECUTABLE}.exe\"\;\#1 COMMENT "Adding DPI awareness" ) + else() + target_sources(${TARGET_CLIENT} PRIVATE dpimanifest.manifest) endif() -endif() \ No newline at end of file +endif() diff --git a/dpimanifest.manifest b/dpimanifest.manifest index 9fac79355..a10c25c22 100644 --- a/dpimanifest.manifest +++ b/dpimanifest.manifest @@ -25,4 +25,4 @@ - \ No newline at end of file + From 205b054026a15020c84ab5bac38b9179769ec6ee Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Sun, 22 Oct 2017 18:06:20 +0200 Subject: [PATCH 5/6] move manifest to other directory and add MinGW support --- CMakeLists.txt | 11 +++++++++-- .../manifest/dpimanifest.manifest | 0 other/manifest/dpimanifest.rc | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) rename dpimanifest.manifest => other/manifest/dpimanifest.manifest (100%) create mode 100644 other/manifest/dpimanifest.rc diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e2127f7c..80fa64ed3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -753,8 +753,14 @@ if(CLIENT) if(TARGET_OS STREQUAL "windows") set(CLIENT_ICON "other/icons/DDNet.rc") + if(MINGW) + set(CLIENT_MANIFEST "other/manifest/dpimanifest.rc") + else() + set(CLIENT_MANIFEST) + endif() else() set(CLIENT_ICON) + set(CLIENT_MANIFEST) endif() # Target @@ -762,6 +768,7 @@ if(CLIENT) add_executable(${TARGET_CLIENT} ${CLIENT_SRC} ${CLIENT_ICON} + ${CLIENT_MANIFEST} ${DEPS_CLIENT} $ $ @@ -1304,10 +1311,10 @@ if(MSVC) TARGET ${CLIENT_EXECUTABLE} POST_BUILD COMMAND - "mt.exe" -manifest \"${CMAKE_SOURCE_DIR}/dpimanifest.manifest\" -outputresource:\"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CLIENT_EXECUTABLE}.exe\"\;\#1 + "mt.exe" -manifest \"${CMAKE_SOURCE_DIR}/other/manifest/dpimanifest.manifest\" -outputresource:\"${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${CLIENT_EXECUTABLE}.exe\"\;\#1 COMMENT "Adding DPI awareness" ) else() - target_sources(${TARGET_CLIENT} PRIVATE dpimanifest.manifest) + target_sources(${TARGET_CLIENT} PRIVATE other/manifest/dpimanifest.manifest) endif() endif() diff --git a/dpimanifest.manifest b/other/manifest/dpimanifest.manifest similarity index 100% rename from dpimanifest.manifest rename to other/manifest/dpimanifest.manifest diff --git a/other/manifest/dpimanifest.rc b/other/manifest/dpimanifest.rc new file mode 100644 index 000000000..9ba70e223 --- /dev/null +++ b/other/manifest/dpimanifest.rc @@ -0,0 +1,2 @@ +#include "winuser.h" +1 RT_MANIFEST dpimanifest.manifest \ No newline at end of file From daee0a13a82db85c80b6ccffcbb003c8a597cc7e Mon Sep 17 00:00:00 2001 From: Jupeyy Date: Sun, 22 Oct 2017 18:32:04 +0200 Subject: [PATCH 6/6] use spaces --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80fa64ed3..ff6926a57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -755,9 +755,9 @@ if(CLIENT) set(CLIENT_ICON "other/icons/DDNet.rc") if(MINGW) set(CLIENT_MANIFEST "other/manifest/dpimanifest.rc") - else() + else() set(CLIENT_MANIFEST) - endif() + endif() else() set(CLIENT_ICON) set(CLIENT_MANIFEST)