I'm using Qt 5.12.11 in my project. As I wanted to use the software both on linux and win, I selected gcc compiler (I use MSYS2, so gcc is 10.3.0). The local build is ok both for linux and win, but the build via GitHub Actions fails on finding the qt (no matter if I set CMAKE_PREFIX_PATH or Qt5_DIR or not).
So this is where I'm stuck for a while. Has anyone encountered such problems or have any ideas on it?
github action looks like
name: Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
env:
BUILD_TYPE: Release
jobs:
build:
runs-on: windows-latest
defaults:
run:
shell: msys2 {0}
steps:
- uses: msys2/setup-msys2@v2
with:
install: mingw-w64-x86_64-toolchain
msystem: mingw64
release: false
- name: Install Qt
uses: jurplel/install-qt-action@v2
with:
version: '5.12.11'
host: 'windows'
target: 'desktop'
arch: 'win64_mingw73'
dir: '${{github.workspace}}/qt/'
install-deps: 'true'
- name: List files in Qt
run: find ${{env.Qt5_Dir}}
- uses: actions/checkout@v2
- name: Configure CMake
run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DCMAKE_PREFIX_PATH="${{env.Qt5_Dir}}/lib/cmake/" -DQt5_DIR=${{env.Qt5_Dir}}/lib/cmake/Qt5/ -G "CodeBlocks - MinGW Makefiles" -B '${{github.workspace}}'/build
- name: Build
run: cmake --build '${{github.workspace}}'/build --target RePr
I've also tried -DCMAKE_PREFIX_PATH="${{env.Qt5_Dir}}/lib/cmake/Qt5/"
but it didn't help. :( if I set the CMAKE_PREFIX_PATH directly from the cmakelists I observe the same behavior.
CMakeLists on which it fails is quite simple and usual (it's a nested package that uses qt, so don't be confused about different cmakelists project and build target)
cmake_minimum_required(VERSION 3.14)
project(RePr_controller)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(QT_VERSION 5)
set(REQUIRED_LIBS Core Gui Widgets)
set(REQUIRED_LIBS_QUALIFIED Qt5::Core Qt5::Gui Qt5::Widgets)
add_library(${PROJECT_NAME} main_window.cpp main_window.h main_window.ui resources/resources.qrc)
add_dependencies(${PROJECT_NAME} FacadeLib)
target_link_libraries(${PROJECT_NAME} FacadeLib Utils)
find_package(Qt${QT_VERSION} COMPONENTS ${REQUIRED_LIBS} REQUIRED)
target_link_libraries(${PROJECT_NAME} ${REQUIRED_LIBS_QUALIFIED})
Messaging the CMAKE_PREFIX_PATH directly from the cmakelists returns
D:/a/RePr/RePr/qt/Qt/5.12.11/mingw73_64/lib/cmake/
qt5 is here
D:/a/RePr/RePr/qt/Qt/5.12.11/mingw73_64/lib/cmake/Qt5/Qt5Config.cmake
finally, I got this message from configuring step
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="D:/a/RePr/RePr/qt/Qt/5.12.11/mingw73_64/lib/cmake/" -DQt5_DIR=D:/a/RePr/RePr/qt/Qt/5.12.11/mingw73_64/lib/cmake/Qt5/ -G "CodeBlocks - MinGW Makefiles" -B 'D:\a\RePr\RePr'/build
shell: D:\a\_temp\msys\msys2.CMD {0}
env:
BUILD_TYPE: Release
MSYSTEM: MINGW64
pythonLocation: C:\hostedtoolcache\windows\Python\3.9.6\x64
Qt5_Dir: D:/a/RePr/RePr/qt/Qt/5.12.11/mingw73_64
QT_PLUGIN_PATH: D:/a/RePr/RePr/qt/Qt/5.12.11/mingw73_64/plugins
QML2_IMPORT_PATH: D:/a/RePr/RePr/qt/Qt/5.12.11/mingw73_64/qml
-- The C compiler identification is GNU 10.3.0
-- The CXX compiler identification is GNU 10.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/msys64/mingw64/bin/gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/msys64/mingw64/bin/g .exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at Controller/CMakeLists.txt:17 (find_package):
By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5", but
-- Configuring incomplete, errors occurred!
See also "D:/a/RePr/RePr/build/CMakeFiles/CMakeOutput.log".
CMake did not find one.
Could not find a package configuration file provided by "Qt5" with any of
the following names:
Qt5Config.cmake
qt5-config.cmake
Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
to a directory containing one of the above files. If "Qt5" provides a
separate development package or SDK, be sure it has been installed.
Error: Process completed with exit code 1.
CodePudding user response:
Set CMAKE_PREFIX_PATH to Qt5_Dir:
- name: Configure CMake
env:
CMAKE_PREFIX_PATH: ${{env.Qt5_Dir}}
run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -G "CodeBlocks - MinGW Makefiles" -B '${{github.workspace}}'/build