Project with QT6 + cmake fails to build on OBS

I have a small project on OBS wich build with QT5.
I Ported this to QT6 + cmake on my local server and it build without problem.
If I try to build it in obs https://build.opensuse.org/package/show/home:phil524/pdftk-qt6gui I receive this error

 -- Found Threads: TRUE  
[   19s] QT_VERSION: 6
[   19s] -- Found OpenGL: /usr/lib64/libOpenGL.so   
[   19s] -- Found WrapOpenGL: TRUE  
[   19s] -- Found XKB: /usr/lib64/libxkbcommon.so (found suitable version "1.5.0", minimum required is "0.5.0") 
[   19s] -- Found WrapVulkanHeaders: /usr/include  
[   19s] -- Performing Test HAVE_STDATOMIC
[   19s] -- Performing Test HAVE_STDATOMIC - Success
[   19s] -- Found WrapAtomic: TRUE  
[   19s] -- Could NOT find Qt6WebEngineWidgets (missing: Qt6WebEngineWidgets_DIR)
[   19s] CMake Debug Log at /usr/lib64/cmake/Qt6/Qt6Config.cmake:167 (find_package):
[   19s]   The internally managed CMAKE_FIND_PACKAGE_REDIRECTS_DIR.
[   19s] 
[   19s]     /home/abuild/rpmbuild/BUILD/pdftk-q6gui_src/CMakeFiles/pkgRedirects
[   19s] 
[   19s]   Paths specified by the find_package HINTS option.
[   19s]     none
[   19s]   Paths specified by the find_package PATHS option.
[   19s]    /usr/lib64/cmake
[   19s] 
[   19s]   find_package considered the following locations for Qt6WebEngineWidgets's
[   19s]   Config module:
[   19s] 
[   19s]     /home/abuild/rpmbuild/BUILD/pdftk-q6gui_src/CMakeFiles/pkgRedirects/Qt6WebEngineWidgetsConfig.cmake
[   19s]     /home/abuild/rpmbuild/BUILD/pdftk-q6gui_src/CMakeFiles/pkgRedirects/qt6webenginewidgets-config.cmake
[   19s]     /usr/lib64/cmake/Qt6WebEngineWidgetsConfig.cmake
[   19s]     /usr/lib64/cmake/qt6webenginewidgets-config.cmake
[   19s] 
[   19s]   The file was not found.
[   19s] 
[   19s] Call Stack (most recent call first):
[   19s]   CMakeLists.txt:9 (find_package)
[   19s] 
[   19s] CMake Error at CMakeLists.txt:9 (find_package):
[   19s]   Found package configuration file:
[   19s] 
[   19s]     /usr/lib64/cmake/Qt6/Qt6Config.cmake
[   19s] 
[   19s]   but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
[   19s]   FOUND.  Reason given by package:
[   19s] 
[   19s]   Failed to find required Qt component "WebEngineWidgets".
[   19s] 
[   19s]   Expected Config file at
[   19s]   "/usr/lib64/cmake/Qt6WebEngineWidgets/Qt6WebEngineWidgetsConfig.cmake" does
[   19s]   NOT exist

I think that I forgot something in the CMakeLists.txt
here the start with the line giving the error

cmake_minimum_required(VERSION 3.16)
project(bin/pdftk-q6gui VERSION 1.0 LANGUAGES C CXX)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Core)
message("QT_VERSION: ${QT_VERSION_MAJOR}")
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Gui WebEngineWidgets)

On my server the path ```
/usr/lib64/cmake/Qt6WebEngineWidgets/Qt6WebEngineWidgetsConfig.cmake

exists.
Any hint on what I'm missing?
Many thanks in advance

So check which package owns this path and add this package as BuildRequires.

rpm -qf /usr/lib64/cmake/Qt6WebEngineWidgets/Qt6WebEngineWidgetsConfig.cmake

Many thanks,
It solved the cmake problem.
I didn’t found the correct package when I updated the specs and I commented it. I now added the correct package and this solved the problem. It remains a problem with

[  222s] ... running 50-check-filelist
[  222s] ... checking filelist
[  222s] pdftk-q6gui-0.3.0-11.1.x86_64.rpm: directories not owned by a package:
[  222s]  - /usr/share/pdftk-q6gui/docs
[  222s] ### VM INTERACTION START ###
[  222s] [  209.411946][    T1] sysrq: Power Off
[  222s] [  209.433331][   T18] reboot: Power down
[  222s] ### VM INTERACTION END ###
[  222s] 
[  222s] lamb15 failed "build pdftk-q6gui.spec" at Sat Jul  8 15:22:28 UTC 2023.

Regards
Philippe

Either delete this directory or add it to the package file list.