Example that uses CMake, Clang, and Qt to cross compile a simple application for Windows with MSVC compatibility.
 
 
Go to file
Martin Felis fc16eab7dd Fixed Qt version, extended documentation. 2021-01-31 21:33:30 +01:00
.gitignore Bare bones working example and documentation 2021-01-31 21:23:42 +01:00
CMakeLists.txt Bare bones working example and documentation 2021-01-31 21:23:42 +01:00
LICENSE Initial commit 2021-01-31 20:59:39 +01:00
README.md Fixed Qt version, extended documentation. 2021-01-31 21:33:30 +01:00
clang_windows_toolchain.cmake Fixed Qt version, extended documentation. 2021-01-31 21:33:30 +01:00
main.cpp Bare bones working example and documentation 2021-01-31 21:23:42 +01:00

README.md

Cross Compiling a Qt5 App using Clang and CMake

Example that uses CMake, Clang, and Qt to cross compile a simple application for Windows with MSVC compatibility.

Parts of it based on: https://gist.github.com/HiImJulien/3eb47d7d874fe5483810bd77940e74c0

Requirements

Instructions Linux

Requirements:

  • Qt5 development packages
  • Clang 10

Steps

  • Copy MSVC build tools into the project directory:
    • Copy C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/<MSVC Version> to msvc_build_tools/MSVC
  • Copy Windows SDK into the project directory:
    • From C:/Program Files (x86)/Windows Kits/10 copy the folders
      • Include to msvc_build_tools/Kit
        • Lib to msvc_build_tools/Kit
    • Both directories have sub directories with the Windows SDK Version as name.
    • Adjust clang_windows_toolchain.cmake to use the proper Windows SDK Version in variable WINSDK_VER
  • Copy the Qt5 msvc development files into the project directory:
    • Copy C:/Qt/Qt5.12.10/5.12.10/msvc2017_64 to qt5_msvc2017_64
  • Configure project using: cmake -DCMAKE_TOOLCHAIN_FILE=clang_windows_toolchain.cmake <project dir>

Instructions Windows with JetBrains CLion

Requirements:

Steps (VS Toolchain)

  • Open project
  • Adjust Toolchain
    • Choose Visual Studio Toolchain
  • Set CMake Options to: -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=C:/llvm/bin/clang-cl.exe -DCMAKE_CXX_COMPILER=C:/llvm/bin/clang-cl.exe -DCMAKE_C_FLAGS=-m64 -DCMAKE_CXX_FLAGS=-m64 -DCMAKE_LINKER=c:/llvm/bin/lld-link.exe

Steps (MinGW Toolchain)

  • Open project
  • Adjust Toolchain
    • Go to Toolchain Settings
    • Remove existing Visual Studio Toolchain
    • Add MinGW Toolchain
  • Adjust CMake Profiles
    • Add -DCMAKE_TOOLCHAIN_FILE=clang_windows_toolchain.cmake as CMake parameters

TODO: How to set up debugger?