Files
qelectrotech-source-mirror/tests/catch/CMakeLists.txt
T
Dieter Mayer 683eefdac1 Request the GuiPrivate component only on Qt6
Listing GuiPrivate unconditionally in QET_COMPONENTS breaks the whole
Qt5 configure: find_package(Qt5 COMPONENTS GuiPrivate) looks for a
Qt5GuiPrivateConfig.cmake that has never existed - Qt5 creates the
Qt5::GuiPrivate target implicitly together with Gui. Only Qt6 requires
(and provides) the explicit component.

Move the request into a QT_VERSION_MAJOR-guarded find_package after the
main one, both for the application and for tests/catch (whose targets
link Qt::GuiPrivate via QET_PRIVATE_LIBRARIES). Fixes the msys2/Qt5
Windows CI configure failure:
"Could not find a package configuration file provided by Qt5GuiPrivate".

Verified: Qt 6.11 configure passes and the Qt6::GuiPrivate target is
created (the private-module warning now fires from the guarded call).
The Qt5 path simply no longer requests the component, restoring the
pre-existing implicit behaviour.
2026-07-17 19:25:26 +02:00

126 lines
3.4 KiB
CMake

# Copyright 2006 The QElectroTech Team
# This file is part of QElectroTech.
#
# QElectroTech is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# QElectroTech is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.5)
message("..___________________________________________________________________")
project(C_unittests LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
SET(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
message(".. PROJECT_NAME :" ${PROJECT_NAME})
message(".. PROJECT_SOURCE_DIR :" ${PROJECT_SOURCE_DIR})
if(NOT DEFINED QET_DIR)
set(QET_DIR "../..")
message(".. QET_DIR is not set, assuming QET is ../..")
endif()
message(".. QET_DIR :" ${QET_DIR})
if(NOT DEFINED QET_COMPONENTS)
message(".. QET_COMPONENTS is not set !!! I set them up !!!")
include(../../cmake/qet_compilation_vars.cmake)
endif()
if(NOT DEFINED QT_VERSION_MAJOR)
find_package(
QT
NAMES
Qt6
Qt5
COMPONENTS
${QET_COMPONENTS}
REQUIRED
)
endif()
message(".. QT_VERSION_MAJOR :" ${QT_VERSION_MAJOR})
find_package(
Qt${QT_VERSION_MAJOR}
COMPONENTS
${QET_COMPONENTS}
REQUIRED)
# Qt6-only: the tests link ${QET_PRIVATE_LIBRARIES}, which contains
# Qt::GuiPrivate; Qt6 only creates that target when the component is
# explicitly requested (Qt5 creates it implicitly and has no such package).
if(QT_VERSION_MAJOR GREATER_EQUAL 6)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS GuiPrivate)
endif()
Include(FetchContent)
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.10)
FetchContent_MakeAvailable(Catch2)
include(../../cmake/fetch_kdeaddons.cmake)
include(../../cmake/fetch_singleapplication.cmake)
include(../../cmake/fetch_pugixml.cmake)
enable_testing()
add_executable(
${PROJECT_NAME}
tst_My_test.cpp
src/borderproperties_test.cpp
main.cpp
${QET_DIR}/sources/borderproperties.cpp
${QET_DIR}/sources/borderproperties.h
)
if(NOT BUILD_WITH_KF5)
target_sources(
${PROJECT_NAME}
PRIVATE
src/kautosavefile_test.cpp
${QET_DIR}/sources/ui/nokde/kautosavefile.cpp
)
target_include_directories(
${PROJECT_NAME}
PRIVATE
${QET_DIR}/sources/ui/nokde
)
endif()
target_link_libraries(
${PROJECT_NAME}
PUBLIC
Catch2::Catch2
PRIVATE
${KF5_PRIVATE_LIBRARIES}
${QET_PRIVATE_LIBRARIES})
if (DEFINED ENV{CATCH_INCLUDE_DIR})
set(CATCH_INCLUDE_DIR $ENV{CATCH_INCLUDE_DIR})
else ()
set(CATCH_INCLUDE_DIR "") # set by Qt Creator wizard
endif ()
if (CATCH_INCLUDE_DIR STREQUAL "")
message(".. CATCH_INCLUDE_DIR is not set,"
"assuming Catch2 can be found automatically in your system")
elseif (EXISTS ${CATCH_INCLUDE_DIR})
include_directories(${CATCH_INCLUDE_DIR})
endif ()