Handle Windows manifests ourselves and add dpi awareness option

This commit is contained in:
Mark Roszko 2020-10-10 19:08:23 +00:00
parent 6c6a3ff465
commit a8bd0a9b84
15 changed files with 191 additions and 12 deletions

View File

@ -126,6 +126,10 @@ option( KICAD_NETLIST_QA
"Run eeschema netlist QA tests (requires Python 3)" "Run eeschema netlist QA tests (requires Python 3)"
OFF ) OFF )
option( KICAD_WIN32_DPI_AWARE
"Turn on DPI awareness for Windows builds only"
OFF )
# when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled: # when option KICAD_SCRIPTING OR KICAD_SCRIPTING_MODULES is enabled:
# PYTHON_EXECUTABLE can be defined when invoking cmake # PYTHON_EXECUTABLE can be defined when invoking cmake
# ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 ) # ( use -DPYTHON_EXECUTABLE=<python path>/python.exe or python2 )
@ -226,6 +230,18 @@ if( WIN32 )
# In fully standards-compliant mode, M_PI et al. are defined only if # In fully standards-compliant mode, M_PI et al. are defined only if
# _USE_MATH_DEFINES is set. # _USE_MATH_DEFINES is set.
add_definitions( -D_USE_MATH_DEFINES ) add_definitions( -D_USE_MATH_DEFINES )
# We need the arch for the resource compiler later
if ( NOT CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( KICAD_BUILD_ARCH "x86" )
elseif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set( KICAD_BUILD_ARCH "x64" )
endif()
add_definitions( -DKICAD_BUILD_ARCH=${KICAD_BUILD_ARCH} )
if( KICAD_WIN32_DPI_AWARE )
add_definitions( -DKICAD_WIN32_DPI_AWARE=1 )
endif()
endif() endif()
@ -309,6 +325,12 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
endif() endif()
if( MINGW ) if( MINGW )
list(APPEND mingw_resource_compiler_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/resources/msw/ )
list(APPEND mingw_resource_compiler_DEFINES KICAD_BUILD_ARCH=${KICAD_BUILD_ARCH} )
if( KICAD_WIN32_DPI_AWARE )
list(APPEND mingw_resource_compiler_DEFINES KICAD_WIN32_DPI_AWARE=1 )
endif()
set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" ) set( CMAKE_EXE_LINKER_FLAGS_RELEASE "-s" )
# Since version 2.8.5, Cmake uses a response file (.rsp) to # Since version 2.8.5, Cmake uses a response file (.rsp) to
@ -355,6 +377,8 @@ if( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) endif( CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
if( MSVC ) if( MSVC )
include_directories( ${CMAKE_SOURCE_DIR}/resources/msw/ )
# Disallow implicit linking for Boost # Disallow implicit linking for Boost
add_definitions( -DBOOST_ALL_NO_LIB ) add_definitions( -DBOOST_ALL_NO_LIB )
# But allow it for the UUID so that it will link against bcrypt # But allow it for the UUID so that it will link against bcrypt
@ -375,11 +399,11 @@ if( MSVC )
string( APPEND CMAKE_CXX_FLAGS_RELEASE " /GF" ) string( APPEND CMAKE_CXX_FLAGS_RELEASE " /GF" )
foreach( type EXE SHARED MODULE) foreach( type EXE SHARED MODULE)
# /DEBUG: create PDB # /DEBUG: create PDB
string( APPEND CMAKE_${type}_LINKER_FLAGS " /DEBUG" ) string( APPEND CMAKE_${type}_LINKER_FLAGS " /DEBUG /MANIFEST:NO" )
# /OPT:REF: omit unreferenced code # /OPT:REF: omit unreferenced code
string( APPEND CMAKE_${type}_LINKER_FLAGS_RELEASE " /OPT:REF" ) string( APPEND CMAKE_${type}_LINKER_FLAGS_RELEASE " /OPT:REF /MANIFEST:NO" )
# /OPT:ICF: fold common data # /OPT:ICF: fold common data
string( APPEND CMAKE_${type}_LINKER_FLAGS_RELEASE " /OPT:ICF" ) string( APPEND CMAKE_${type}_LINKER_FLAGS_RELEASE " /OPT:ICF /MANIFEST:NO" )
endforeach() endforeach()
# Let cl.exe parallelize builds # Let cl.exe parallelize builds

View File

@ -24,10 +24,20 @@ macro(mingw_resource_compiler _NAME)
foreach(wx_include_dir ${wxWidgets_INCLUDE_DIRS}) foreach(wx_include_dir ${wxWidgets_INCLUDE_DIRS})
set(_WINDRES_INCLUDE_DIRS ${_WINDRES_INCLUDE_DIRS} -I${wx_include_dir}) set(_WINDRES_INCLUDE_DIRS ${_WINDRES_INCLUDE_DIRS} -I${wx_include_dir})
endforeach(wx_include_dir ${wxWidgets_INCLUDE_DIRS}) endforeach(wx_include_dir ${wxWidgets_INCLUDE_DIRS})
foreach(_mingw_rc_include_dir ${mingw_resource_compiler_INCLUDE_DIRS})
set(_WINDRES_INCLUDE_DIRS ${_WINDRES_INCLUDE_DIRS} -I${_mingw_rc_include_dir})
endforeach()
dbg_msg("_WINDRES_INCLUDE_DIRS: ${_WINDRES_INCLUDE_DIRS}") dbg_msg("_WINDRES_INCLUDE_DIRS: ${_WINDRES_INCLUDE_DIRS}")
foreach(_mingw_rc_define ${mingw_resource_compiler_DEFINES})
set(_WINDRES_DEFINES ${_WINDRES_DEFINES} -D${_mingw_rc_define})
endforeach()
dbg_msg("_WINDRES_DEFINES: ${_WINDRES_DEFINES}")
# windres arguments. # windres arguments.
set(_ARGS ${_WINDRES_INCLUDE_DIRS} -i${_IN} -o${_OUT}) set(_ARGS ${_WINDRES_INCLUDE_DIRS} ${_WINDRES_DEFINES} -i${_IN} -o${_OUT})
dbg_msg("_ARGS: ${_ARGS}") dbg_msg("_ARGS: ${_ARGS}")
# Compile resource file. # Compile resource file.

View File

@ -1,3 +1,3 @@
icon_bitmap2component ICON "../bitmaps_png/icons/icon_bitmap2component.ico" icon_bitmap2component ICON "../bitmaps_png/icons/icon_bitmap2component.ico"
#include "wx/msw/wx.rc" #include "kiwin32.rc"

View File

@ -1,2 +1,3 @@
icon_cvpcb ICON "../bitmaps_png/icons/icon_cvpcb.ico" icon_cvpcb ICON "../bitmaps_png/icons/icon_cvpcb.ico"
#include "wx/msw/wx.rc"
#include "kiwin32.rc"

View File

@ -1,3 +1,3 @@
icon_eeschema ICON "../bitmaps_png/icons/icon_eeschema.ico" icon_eeschema ICON "../bitmaps_png/icons/icon_eeschema.ico"
#include "wx/msw/wx.rc" #include "kiwin32.rc"

View File

@ -1,3 +1,3 @@
icon_gerbview ICON "../bitmaps_png/icons/icon_gerbview.ico" icon_gerbview ICON "../bitmaps_png/icons/icon_gerbview.ico"
#include "wx/msw/wx.rc" #include "kiwin32.rc"

View File

@ -1,3 +1,3 @@
icon_kicad ICON "../bitmaps_png/icons/icon_kicad.ico" icon_kicad ICON "../bitmaps_png/icons/icon_kicad.ico"
#include "wx/msw/wx.rc" #include "kiwin32.rc"

View File

@ -1,3 +1,3 @@
icon_pagelayout_editor ICON "../bitmaps_png/icons/icon_pagelayout_editor.ico" icon_pagelayout_editor ICON "../bitmaps_png/icons/icon_pagelayout_editor.ico"
#include "wx/msw/wx.rc" #include "kiwin32.rc"

View File

@ -1,3 +1,3 @@
icon_pcbcalculator ICON "../bitmaps_png/icons/icon_pcbcalculator.ico" icon_pcbcalculator ICON "../bitmaps_png/icons/icon_pcbcalculator.ico"
#include "wx/msw/wx.rc" #include "kiwin32.rc"

View File

@ -1,3 +1,3 @@
icon_pcbnew ICON "../bitmaps_png/icons/icon_pcbnew.ico" icon_pcbnew ICON "../bitmaps_png/icons/icon_pcbnew.ico"
#include "wx/msw/wx.rc" #include "kiwin32.rc"

32
resources/msw/kiwin32.rc Normal file
View File

@ -0,0 +1,32 @@
// Turn off wxWidgets attempting to use its own manifests
#define wxUSE_NO_MANIFEST 1
#include "wx/msw/wx.rc"
#ifdef ISOLATION_AWARE_ENABLED
#define MANIFEST_ID ISOLATIONAWARE_MANIFEST_RESOURCE_ID
#else
#define MANIFEST_ID CREATEPROCESS_MANIFEST_RESOURCE_ID
#endif
#if !defined( KICAD_WIN32_DPI_AWARE ) || KICAD_WIN32_DPI_AWARE == 0
#define MANIFEST_SUFFIX .manifest
#else
#define MANIFEST_SUFFIX _dpi_aware_pmv2.manifest
#endif
//MSYS2
#define RC_STR( text ) RC_STR2( text )
#define RC_STR2( text ) #text
//MSVC
#define RC_CONCAT( a, b, c ) RC_CONCAT2( a, b, c )
#define RC_CONCAT2( a, b, c ) a##b##c
#ifdef __GNUC__
#define MANIFEST_FILE "manifests/" RC_STR( KICAD_BUILD_ARCH ) RC_STR( MANIFEST_SUFFIX )
#else
//Do not try and quote the first part, it won't work, also make sure the IDE doesn't reformat it with spaces between slashes
#define MANIFEST_FILE RC_CONCAT( manifests/, KICAD_BUILD_ARCH, MANIFEST_SUFFIX )
#endif
MANIFEST_ID RT_MANIFEST MANIFEST_FILE
//RESOURCE FILES MUST CONTAIN A BLANK LINE AT THE END

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="0.64.1.0"
processorArchitecture="amd64"
name="Controls"
type="win32"
/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="amd64"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="amd64" publicKeyToken="6595b64144ccf1df" language="*" />
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<asmv3:application>
<asmv3:windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, system</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="0.64.1.0"
processorArchitecture="x86"
name="Controls"
type="win32"
/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="X86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*" />
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<asmv3:application>
<asmv3:windowsSettings>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, system</dpiAwareness>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
</assembly>