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 <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2024-07-30 15:54:37 +02:00
parent ce7b8fc91d
commit 98847d2153
4 changed files with 8 additions and 23 deletions

View File

@ -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)

View File

@ -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()

View File

@ -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
)

View File

@ -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