Files
qt-creator/doc/qtcreatordev/examples/exampleplugin/CMakeLists.txt
Cristian Adam 36e84b1c54 Doc/Wizards: Update minimum CMake version to 3.16
Qt Creator due to the usage of CMake File-API was already requiring
CMake 3.14.

Qt 6.7 now requires CMake version 3.16, thus the version requirement
bump.

Note that Qt SDK is shipping CMake version 3.27.

Fixes: QTCREATORBUG-31079
Change-Id: Ife26d178b80949941cb808a1fbd91389d6d723bc
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
2024-06-19 08:12:41 +00:00

70 lines
1.4 KiB
CMake

cmake_minimum_required(VERSION 3.16)
#! [1]
# Remove when sharing with others.
list(APPEND CMAKE_PREFIX_PATH "/Users/example/qt-creator/build")
#! [1]
#! [2]
project(Example)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_CXX_STANDARD 17)
#! [2]
#! [3]
find_package(QtCreator COMPONENTS Core REQUIRED)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
set(QtX Qt${QT_VERSION_MAJOR})
#! [3]
#! [5]
# Add a CMake option that enables building your plugin with tests.
# You don't want your released plugin binaries to contain tests,
# so make that default to 'NO'.
# Enable tests by passing -DWITH_TESTS=ON to CMake.
option(WITH_TESTS "Builds with tests" NO)
if(WITH_TESTS)
# Look for QtTest
find_package(${QtX} REQUIRED COMPONENTS Test)
# Tell CMake functions like add_qtc_plugin about the QtTest component.
set(IMPLICIT_DEPENDS Qt::Test)
# Enable ctest for auto tests.
enable_testing()
endif()
#! [5]
#! [4]
add_qtc_plugin(Example
PLUGIN_DEPENDS
QtCreator::Core
DEPENDS
${QtX}::Widgets
QtCreator::ExtensionSystem
QtCreator::Utils
SOURCES
.github/workflows/build_cmake.yml
.github/workflows/README.md
README.md
example.cpp
example.h
example_global.h
exampleconstants.h
examplefunctions.h
)
#! [4]
#! [6]
# conditionally add auto tests
if(WITH_TESTS)
add_qtc_test(tst_mytest
SOURCES tst_mytest.cpp
DEPENDS Example
)
endif()
#! [6]