Skip to content

Commit 6f7dd7e

Browse files
authored
Merge pull request #190 from ddalcino/topic/fix-qt5_dir-env-var
[v4] Fix `Qt5_DIR` environment variable
2 parents b0a26e3 + f76dbc3 commit 6f7dd7e

5 files changed

Lines changed: 66 additions & 10 deletions

File tree

.github/workflows/test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ jobs:
127127
run: |
128128
cd tests/TestWithModules
129129
for /f "delims=" %%d in ( 'vswhere.exe -latest -property installationPath' ) do @( call "%%d\VC\Auxiliary\Build\vcvars64.bat" )
130-
IF "%QT_VERSION:~0,1%"=="5" ( dir %Qt5_DIR%\lib\cmake ) ELSE ( dir %Qt6_DIR%\lib\cmake )
130+
IF "%QT_VERSION:~0,1%"=="5" ( dir %Qt5_DIR% ) ELSE ( dir %QT_ROOT_DIR%\lib\cmake )
131131
qmake
132+
cmake -S . -B ./build
132133
shell: cmd
133134

134135
- name: Configure test project on unix
@@ -138,11 +139,12 @@ jobs:
138139
run: |
139140
cd tests/TestWithModules
140141
if [[ $QT_VERSION == 6* ]]; then
141-
ls "$Qt6_DIR/lib/cmake"
142+
ls "${QT_ROOT_DIR}/lib/cmake"
142143
else
143-
ls "$Qt5_DIR/lib/cmake"
144+
ls "${Qt5_DIR}"
144145
fi
145146
qmake
147+
cmake -S . -B ./build
146148
shell: bash
147149

148150
- name: Install source

README.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ You know what's easier than dealing with that? Just using this:
1010
1111
All done.
1212
13+
## Upgrade Guides
14+
Each new major version of this project includes changes that can break workflows written to use an older version of
15+
this project. These changes are summarized here, to help you upgrade your existing workflows.
16+
17+
[Upgrading `install-qt-action`](README_upgrade_guide.md)
18+
1319
## Options
1420

1521
### `version`
@@ -61,7 +67,8 @@ Android: `android_armv7`
6167
### `dir`
6268
This is the directory prefix that Qt will be installed to.
6369

64-
For example, if you set dir to `${{ github.workspace }}/example/`, your bin folder will be located at `$GITHUB_WORKSPACE/example/Qt/5.15.2/{arch}/bin`. When possible, access your Qt directory through the `Qt5_DIR` or `Qt6_DIR` environment variable.
70+
For example, if you set dir to `${{ github.workspace }}/example/`, your bin folder will be located at `$GITHUB_WORKSPACE/example/Qt/5.15.2/{arch}/bin`.
71+
When possible, access your Qt directory through the `QT_ROOT_DIR` environment variable; this will point to `$GITHUB_WORKSPACE/example/Qt/5.15.2/{arch}` in this case.
6572

6673
Default: `$RUNNER_WORKSPACE` (this is one folder above the starting directory)
6774

@@ -254,9 +261,13 @@ Example value: `--external 7z`
254261
## More info
255262
For more in-depth and certifiably up-to-date documentation, check the documentation for aqtinstall [here](https://aqtinstall.readthedocs.io/en/latest/getting_started.html).
256263

257-
The Qt bin directory is appended to your `path` environment variable. `Qt5_DIR`/`Qt6_DIR` is also set appropriately for CMake.
264+
The Qt bin directory is appended to your `path` environment variable.
265+
`Qt5_DIR` is also set appropriately for CMake if you are using Qt 5.
258266
In addition, `QT_PLUGIN_PATH`, `QML2_IMPORT_PATH`, `PKG_CONFIG_PATH` and `LD_LIBRARY_PATH` are set accordingly. `IQTA_TOOLS` is set to the "Tools" directory if tools are installed as well.
259267

268+
Since the Qt bin directory is in your `path`, you will not need to set the `CMAKE_PREFIX_PATH` CMake variable.
269+
If you wish to do so, you can set it to either `${QT_ROOT_DIR}` or to `${QT_ROOT_DIR}/lib/cmake`.
270+
260271
Big thanks to the [aqtinstall](https://github.com/miurahr/aqtinstall/) developer for making this easy. Please go support [miurahr](https://github.com/miurahr/aqtinstall), he did all of the hard work here ([his liberapay](https://liberapay.com/miurahr)).
261272

262273
This action is distributed under the [MIT license](LICENSE).

README_upgrade_guide.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Upgrading `install-qt-action`
2+
3+
## Unreleased
4+
* Added the `QT_ROOT_DIR` environment variable that points to the root of the Qt installation.
5+
This variable points to the same directory as the old `Qt5_DIR` and `Qt6_DIR` variables.
6+
* Changed `Qt5_DIR` environment variable, so that it points to `${QT_ROOT_DIR}/lib/cmake`, as required by CMake.
7+
If your action uses this variable for any other purpose, you should update it to use `QT_ROOT_DIR` instead.
8+
* Removed the `Qt5_Dir` and `Qt6_DIR` environment variables, because they are not used by CMake.
9+
If your action uses these variables, you should update them to use `QT_ROOT_DIR` instead.
10+
11+
## v3
12+
* Updated `aqtinstall` to version 2.1.* by default.
13+
See [changelog entry](https://github.com/miurahr/aqtinstall/blob/master/docs/CHANGELOG.rst#v210-14-apr-2022) for details.
14+
* `aqtinstall` v 2.1.0 now checks that the SHA256 checksums reported at https://download.qt.io matches the 7z archives
15+
that it downloads [aqtinstall#493](https://github.com/miurahr/aqtinstall/pull/493).
16+
This change was necessary because the old checksum algorithm, SHA1, is no longer safe to use for this purpose.
17+
Unfortunately, SHA256 checksums are often not available for up to 24 hours after new 7z archives are made available at
18+
https://download.qt.io, and workflows that use `aqtinstall` v 2.1.0 will fail to install Qt properly during that window.
19+
See [aqtinstall#578](https://github.com/miurahr/aqtinstall/issues/578) for further discussion.

action/src/main.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,11 @@ const run = async (): Promise<void> => {
393393
if (process.platform !== "win32") {
394394
setOrAppendEnvVar("PKG_CONFIG_PATH", nativePath(`${qtPath}/lib/pkgconfig`));
395395
}
396-
// If less than qt6, set qt5_dir variable, otherwise set qt6_dir variable
396+
// If less than qt6, set Qt5_DIR variable
397397
if (compareVersions(inputs.version, "<", "6.0.0")) {
398-
core.exportVariable("Qt5_Dir", qtPath); // Incorrect name that was fixed, but kept around so it doesn't break anything
399-
core.exportVariable("Qt5_DIR", qtPath);
400-
} else {
401-
core.exportVariable("Qt6_DIR", qtPath);
398+
core.exportVariable("Qt5_DIR", nativePath(`${qtPath}/lib/cmake`));
402399
}
400+
core.exportVariable("QT_ROOT_DIR", qtPath);
403401
core.exportVariable("QT_PLUGIN_PATH", nativePath(`${qtPath}/plugins`));
404402
core.exportVariable("QML2_IMPORT_PATH", nativePath(`${qtPath}/qml`));
405403
core.addPath(nativePath(`${qtPath}/bin`));
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cmake_minimum_required(VERSION 3.1.0)
2+
3+
project(whatspoppin VERSION 1.0.0 LANGUAGES CXX)
4+
5+
set(CMAKE_CXX_STANDARD 11)
6+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
7+
8+
set(CMAKE_AUTOMOC ON)
9+
set(CMAKE_AUTORCC ON)
10+
set(CMAKE_AUTOUIC ON)
11+
12+
if(CMAKE_VERSION VERSION_LESS "3.7.0")
13+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
14+
endif()
15+
16+
if(DEFINED ENV{Qt5_DIR})
17+
find_package(Qt5 COMPONENTS WebEngineWidgets REQUIRED)
18+
add_executable(whatspoppin main.cpp)
19+
target_link_libraries(whatspoppin Qt5::WebEngineWidgets)
20+
else()
21+
find_package(Qt6 REQUIRED COMPONENTS Core WebEngineWidgets)
22+
qt_standard_project_setup()
23+
add_executable(whatspoppin main.cpp)
24+
target_link_libraries(whatspoppin PRIVATE Qt::WebEngineWidgets Qt6::Core)
25+
endif()
26+

0 commit comments

Comments
 (0)