diff options
author | Alexandru Croitor <[email protected]> | 2024-07-30 15:54:37 +0200 |
---|---|---|
committer | Alexandru Croitor <[email protected]> | 2024-07-30 16:12:14 +0200 |
commit | 98847d21538050201b9594d5fa5da390700fb708 (patch) | |
tree | 162789a91b598271b040f48d44f0c10644f550cb | |
parent | ce7b8fc91d82402cbed230e83c00cab3a54f9916 (diff) |
CMake: Fix project structure of calendarbackendplugin project
Before this change, installing the example with a multi-config
generator failed with
CMake Error at cmake_install.cmake:123 (include):
include could not find requested file:
<build_dir>/.qt/deploy_calendarPlugin_49e753a159-$<CONFIG>.cmake
When configuring the project, cmake mentions the following warning:
CMake Warning (dev) in CMakeLists.txt:
Policy CMP0087 is not set: Install CODE|SCRIPT allow the use of
generator expressions. Run "cmake --help-policy CMP0087" for policy
details.
This happens because the specified minimum cmake version of the project
was 3.5, so the above policy was not enabled, and the generator
expressions we use for the deployment api failed to be evaluated.
Fix the minimum version to be 3.16.
Clean up the project a bit to be in line with our other examples.
Use qt_internal_add_example, remove redundant find_package(Qt) calls,
remove redundant project() and cmake_minimum_required() calls, use
target_include_directories.
Amends f071d4ee8abf6fd0f1b6e187b4e99fa6fad7b642
Fixes: QTBUG-127616
Task-number: QTBUG-115200
Change-Id: I06ca1d38a8e5e7cb18ade205616a603db98a17be
Reviewed-by: Alexey Edelev <[email protected]>
4 files changed, 8 insertions, 23 deletions
diff --git a/examples/corelib/time/CMakeLists.txt b/examples/corelib/time/CMakeLists.txt index 32b93e9ecfa..148ae5d0148 100644 --- a/examples/corelib/time/CMakeLists.txt +++ b/examples/corelib/time/CMakeLists.txt @@ -1,4 +1,4 @@ # Copyright (C) 2024 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -add_subdirectory(calendarbackendplugin) +qt_internal_add_example(calendarbackendplugin) diff --git a/examples/corelib/time/calendarbackendplugin/CMakeLists.txt b/examples/corelib/time/calendarbackendplugin/CMakeLists.txt index 7aa4a18a1e5..4f1702c012a 100644 --- a/examples/corelib/time/calendarbackendplugin/CMakeLists.txt +++ b/examples/corelib/time/calendarbackendplugin/CMakeLists.txt @@ -1,10 +1,10 @@ # Copyright (C) 2024 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.16) project(JulianGregorianCalendar VERSION 0.1 LANGUAGES CXX) -find_package(Qt6 REQUIRED COMPONENTS Core) +find_package(Qt6 REQUIRED COMPONENTS Core Widgets) qt_standard_project_setup() diff --git a/examples/corelib/time/calendarbackendplugin/application/CMakeLists.txt b/examples/corelib/time/calendarbackendplugin/application/CMakeLists.txt index 3cd4ffe430c..da432fe2c75 100644 --- a/examples/corelib/time/calendarbackendplugin/application/CMakeLists.txt +++ b/examples/corelib/time/calendarbackendplugin/application/CMakeLists.txt @@ -1,23 +1,16 @@ # Copyright (C) 2024 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.5) -project(JulianGregorianCalendar VERSION 0.1 LANGUAGES CXX) - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Core) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core) - -qt_standard_project_setup() - -include_directories(../common/) - qt_add_executable(JulianGregorianCalendar ../common/calendarBackendInterface.h main.cpp ) +target_include_directories(JulianGregorianCalendar PRIVATE ../common) + target_link_libraries(JulianGregorianCalendar PRIVATE Qt::Widgets Qt::Core ) + diff --git a/examples/corelib/time/calendarbackendplugin/plugin/CMakeLists.txt b/examples/corelib/time/calendarbackendplugin/plugin/CMakeLists.txt index bac4118b8f5..26a13b29298 100644 --- a/examples/corelib/time/calendarbackendplugin/plugin/CMakeLists.txt +++ b/examples/corelib/time/calendarbackendplugin/plugin/CMakeLists.txt @@ -1,16 +1,6 @@ # Copyright (C) 2024 The Qt Company Ltd. # SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause -cmake_minimum_required(VERSION 3.5) -project(calendarPlugin VERSION 0.1 LANGUAGES CXX) - -find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Core) -find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Core) - -qt_standard_project_setup() - -include_directories(../common/) - qt_add_library(calendarPlugin SHARED ../common/calendarBackendInterface.h calendarplugin.h @@ -19,6 +9,8 @@ qt_add_library(calendarPlugin SHARED calendarbackend.h ) +target_include_directories(calendarPlugin PRIVATE ../common) + target_link_libraries(calendarPlugin PRIVATE Qt::Widgets |