0

Is it possible to configure DPI Awareness value using cmake or some script? https://i.stack.imgur.com/ySWvE.png

Henrique Jung
  • 1,408
  • 1
  • 15
  • 23
  • Possible duplicate of [How can I set the dpiAware property in a Windows application manifest to "per monitor" in Visual Studio?](https://stackoverflow.com/questions/23551112/how-can-i-set-the-dpiaware-property-in-a-windows-application-manifest-to-per-mo) – Ľubomír Carik Apr 24 '18 at 22:54
  • why is it duplicate? – Oleksii Hordiienko Apr 30 '18 at 07:59

4 Answers4

4

Create a manifest file (.manifest is important) with the following content:

<?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">
  <asmv3:application>
    <asmv3:windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>

see https://learn.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process

Then add it to your binary target in CMake using:

target_sources(your-binary PRIVATE path-to-the-file-above.manifest)

You'll need CMake 3.4 or newer, see https://cmake.org/cmake/help/v3.4/release/3.4.html#other

jhasse
  • 2,379
  • 1
  • 30
  • 40
0

There is no internal manifest support in CMake, but you can use it, there are couple of hints on this site (e.g. people using manifest e.g. because of UAC etc.).

About DPI, search other topic on SO e.g. here

Ľubomír Carik
  • 387
  • 5
  • 11
0

I found this helpful. Applying manifest using cmake.

https://gist.github.com/bjornblissing/6fc452fe7ec1fdfe3419

0

We can set the Manifest Tool -> Input and Output -> DPI Awareness in the Visual Studio target project properties:

VS_DPI_AWARE in CMakeLists.txt

add_executable(myproject myproject.cpp)
set_property(TARGET myproject PROPERTY VS_DPI_AWARE "PerMonitor")

Valid values are PerMonitor, ON, or OFF.

Start in version 3.16.