2021-01-31 21:23:42 +01:00
|
|
|
# Cross Compiling a Qt5 App using Clang and CMake
|
2021-01-31 20:59:39 +01:00
|
|
|
|
2021-01-31 21:23:42 +01:00
|
|
|
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
|
|
|
|
|
2021-01-31 21:33:30 +01:00
|
|
|
- Clang Version >= 10
|
2021-01-31 21:23:42 +01:00
|
|
|
- Visual Studio Build Tools: https://visualstudio.microsoft.com/downloads/
|
2021-01-31 21:33:30 +01:00
|
|
|
- The following components are sufficient:
|
|
|
|
* MSVC v142 - VS 2019 C++-x64/x86-Buildtools (v14.28)
|
|
|
|
+ Windows 10 SDK (10.0.19041.0)
|
2021-01-31 21:23:42 +01:00
|
|
|
- Qt5: https://download.qt.io/official_releases/qt
|
2021-01-31 21:33:30 +01:00
|
|
|
- again when installing it is sufficient to install msvc version of Qt5
|
2021-01-31 21:23:42 +01:00
|
|
|
|
|
|
|
## 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:
|
|
|
|
|
|
|
|
- Download and Install Qt5 (MinGW libraries not needed)
|
|
|
|
- Clang 10 (https://releases.llvm.org/download.html)
|
|
|
|
- Install JetBrains CLion (https://jetbrains.com/clion)
|
|
|
|
|
2021-01-31 21:46:11 +01:00
|
|
|
### Steps
|
2021-01-31 21:23:42 +01:00
|
|
|
|
2021-01-31 21:46:11 +01:00
|
|
|
- Open project with CLion
|
2021-01-31 21:23:42 +01:00
|
|
|
- Adjust Toolchain
|
2021-01-31 21:33:30 +01:00
|
|
|
- Choose Visual Studio Toolchain
|
2021-01-31 21:46:11 +01:00
|
|
|
- Add to the CMake Options:
|
|
|
|
- `-DCMAKE_TOOLCHAIN_FILE=clang_windows_toolchain.cmake`
|