Skip to content

Building, debugging and running in Windows using Visual Studio

Mart Sõmermaa edited this page Oct 5, 2022 · 4 revisions

CMake has become more and more integrated with Visual Studio over the past few releases. When using recent Visual Studio (at least VS 2022 version 17.3.5 required), you can open the CMake project by simply opening the root folder that contains CMakeLists.txt. You need to have C++ CMake tools for Windows installed as part of the Desktop development with C++ workload. See further instructions here.

Additionally, CMake needs to know the location of the Qt installation. Proceed as described here:

  • Right click the CMakeList.txt file in Visual Studio Solution Explorer and select CMake Settings
  • Then click on Edit JSON in the top right
  • Add the CMAKE_PREFIX_PATH CMake variable to the JSON file:
      "ctestCommandArgs": "",
      "variables": [
        {
          "name": "CMAKE_PREFIX_PATH",
          "value": "C:\\Qt\\6.2.4\\msvc2019_64",
          "type": "STRING"
        }
      ]

Next, to debug or run the application, the Qt DLLs need to be copied to the output folder as described here. Open a Git Bash (or any other) shell in the out/build/x64-Debug/src/app directory and run

/c/Qt/6.2.4/msvc2019_64/bin/windeployqt.exe web-eid.exe --dir .

Finally, to specify program arguments during debugging, proceed as described here:

  • Select Debug > Debug and launch settings for web-eid from the Visual Studio main menu
  • Add the args line to the JSON file (note the double quoting of JSON-in-JSON):
      "name": "web-eid.exe (src\\app\\web-eid.exe) with arguments",
      "args": ["-c get-signing-certificate \"{\\\"origin\\\": \\\"https://web-eid.eu\\\"}\""]
    • or, to test signing:
        "args": ["-c sign \"{\\\"origin\\\": \\\"https://web-eid.eu\\\", \\\"hash\\\": \\\"eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4\\\", \\\"hashFunction\\\": \\\"SHA-384\\\", \\\"certificate\\\": \\\"<base64-encoded signing certificate>\\\"}\""]