8000 Allow Windows builds with system-installed Qt · google/orbit@44d193a · GitHub
[go: up one dir, main page]

Skip to content
This repository has been archived by the owner on Jan 31, 2025. It is now read-only.

Commit

Permalink
Allow Windows builds with system-installed Qt
Browse files Browse the repository at this point in the history
We can't provide binary packages of Qt for the public and compiling
Qt from source takes a long time and is cumbersome.

To solve that problem this introduces the possibility
to use a system-installed Qt as we support it on Linux
for a long time.

This new support is optional and we will continue building
our own Qt for the official Stadia version of Orbit. But
for external contributors that should simplify getting started
on Windows.
  • Loading branch information
beckerhe committed Dec 1, 2020
1 parent 9bf8fbc commit 44d193a
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 21 deletions.
115 changes: 95 additions & 20 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,16 @@ release from GitHub's [releases page](https://github.com/google/orbit/releases).

To build Orbit you need a compiler capable of C++17. The following ones should be fine.

* GCC 8 and above on Linux
* Clang 7 and above on Linux
* MSVC 2017, 2019 and above on Windows

## Building Orbit

Orbit relies on `conan` as its package manager. Conan is written in Python3,
so make sure you have either Conan installed or at least have Python3 installed.

The `bootstrap-orbit.{sh,ps1}` will try to install `conan` via `pip3` if not
installed and reachable via `PATH`. Afterwards it calls `build.{sh,ps1}` which
will compile Orbit for you.

On Linux, `python3` should be preinstalled anyway, but you might need to install
pip (package name: `python3-pip`).

On Windows, one option to install Python is via the Visual Studio Installer.
Alternatively you can download prebuilts from [python.org](https://www.python.org/)
(In both cases verify that `pip3.exe` is in the path, otherwise the bootstrap
script will not be able to install conan for you.)
- GCC 8 and above on Linux
- Clang 7 and above on Linux
- MSVC 2017, 2019 and above on Windows

## Dependencies

All our third-party libraries and dependencies are managed by conan.

### Qt on Linux

There are some exceptions. On Linux, we rely by default on the distribution's Qt5
and Mesa installation. This can be changed by modifying the conan package options
`system_qt` and `system_mesa`, but we recommend to go with the distribution provided
Expand All @@ -61,6 +46,96 @@ to change the default values of these two options.
Check out `conanfile.py`. There is a python dictionary called `default_options`
defined in the python class `OrbitConan`.

### Qt on Windows

On Windows you have the choice to either let Conan compile Qt from source or use
one of the prebuilt distributions from [The Qt Company](https://qt.io/). (Note that
as of writing this, you need to register to download the distribution packages.)

We recommend to use a prebuilt distribution since compiling from source can take
several hours.

If you decide to compile from source, you don't have to prepare anything.
You can skip over the next paragraph and go to "Building Orbit".

If you decide to use a prebuilt Qt distribution, please download and install it
yourself. Keep in mind the prebuilt has to match your Visual Studio version and
architecture. You also have to install the QtWebEngine component which is usually
not selected by default in the installer.

As of writing this the minimum supported Qt version is 5.12.4 but this might change.
We recommend the version which we also compile from source. It can be found by checking
`conanfile.py`. Search for `self.requires("qt/`. The version can be found after that string.

As a next step you have to tell the Orbit build system where Qt is installed by
setting an environment variable `Qt5_DIR`. It has to point to the directory
containing the CMake config file `Qt5Config.cmake`. For Qt 5.15.0 installed to
the default location the path is `C:\Qt\5.15.0\msvc2019_64\lib\cmake\Qt5`;

You don't have to set that variable globally. It's fine to set it in a local
PowerShell when starting the bootstrapping script:

```powershell
$Env:Qt5_DIR="C:\Qt\5.15.0\msvc2019_64\lib\cmake\Qt5"
.\bootstrap-orbit.ps1
```

The value of `Qt5_DIR` is persisted in the default conan profiles. You can
call `conan profile show default_relwithdebinfo` (after running bootstrap)
to see the value of `Qt5_DIR`.

If you have pre-existing `default_*`-profiles and want to switch to prebuilt
Qt distributions you have to either delete these profiles - the build script
will regenerate them - or you can manually edit them.

A default profile with Qt compiled from source is pretty much empty:

```
# default_relwithdebinfo
include(msvc2019_relwithdebinfo)
[settings]
[options]
[build_requires]
[env]
```

A default profile prepared for a prebuilt Qt package has two extra lines:

```
# default_relwithdebinfo
include(msvc2019_relwithdebinfo)
[settings]
[options]
OrbitProfiler:system_qt=True
[build_requires]
[env]
OrbitProfiler:Qt5_DIR="C:\Qt\5.15.0\msvc2019_64\lib\cmake\Qt5"
```

You can find all the conan profiles in `%USERPROFILE%\.conan\profiles`.

## Building Orbit

Orbit relies on `conan` as its package manager. Conan is written in Python3,
so make sure you have either Conan installed or at least have Python3 installed.

The `bootstrap-orbit.{sh,ps1}` will try to install `conan` via `pip3` if not
installed and reachable via `PATH`. Afterwards it calls `build.{sh,ps1}` which
will compile Orbit for you.

On Linux, `python3` should be preinstalled anyway, but you might need to install
pip (package name: `python3-pip`).

On Windows, one option to install Python is via the Visual Studio Installer.
Alternatively you can download prebuilts from [python.org](https://www.python.org/)
(In both cases verify that `pip3.exe` is in the path, otherwise the bootstrap
script will not be able to install conan for you.)

## Running Orbit

Expand Down
21 changes: 20 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,28 @@ function conan_create_profile($profile) {
$build_type = $profile -replace "default_"
$profile_path = "$conan_dir/profiles/$profile"

if (!$Env:Qt5_DIR) {
Write-Host ""
Write-Host "Compile Qt from source or use official distribution?"
Write-Host "====================================================`r`n"
Write-Host "Orbit depends on the Qt framework which can be either automatically compiled from source (can take several hours!)"
Write-Host "or can be provided by an official Qt distribution. We recommend the latter which is less cumbersome."
Write-Host "Check out DEVELOPMENT.md for more details on how to use an official Qt distribution.`r`n"
Write-Host "Press Ctrl+C to stop here and install Qt first. Press Enter to continue with compiling Qt from source."
Write-Host "Google-internal devs: Please press Enter!`r`n"
Read-Host "Answer"
}

"include(${compiler_version}_${build_type})`r`n" | Set-Content -Path $profile_path
"[settings]`r`n[options]" | Add-Content -Path $profile_path
"[build_requires]`r`n[env]" | Add-Content -Path $profile_path

if ($Env:Qt5_DIR) {
Write-Host "Found Qt5_DIR environment variable. Using system provided Qt distribution."
"OrbitProfiler:system_qt=True`r`n[build_requires]`r`n[env]" | Add-Content -Path $profile_path
"OrbitProfiler:Qt5_DIR=`"$Env:Qt5_DIR`"" | Add-Content -Path $profile_path
} else {
"[build_requires]`r`n[env]" | Add-Content -Path $profile_path
}
}

$profiles = if ($args.Count) { $args } else { @("default_relwithdebinfo") }
Expand Down

0 comments on commit 44d193a

Please sign in to comment.
0