DPI Aware Windows app with CMake

Building Windows apps with CMake by default results in blurry views because by default apps are not considered DPI aware. Fixing this in CMake is actually very easy, just took some time to find.

  1. Add a new file dpi-aware.manifest to the sources of your app. It should look like the following:
<?xml version="1.0"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <application xmlns="urn:schemas-microsoft-com:asm.v3">
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
  1. In CMakeLists.txt add the following:
target_sources(myapp PRIVATE dpi-aware.manifest)

And voila, the app will be super crisp!

Thanks! You can always email me or use contact form for more questions/comments etc.