diff options
Diffstat (limited to 'share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt')
-rw-r--r-- | share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt b/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt index 48884eae644..a60e46cb7cd 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt @@ -22,6 +22,23 @@ find_package(QtCreator REQUIRED COMPONENTS Core) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets) set(QtX Qt${QT_VERSION_MAJOR}) +# 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() + add_qtc_plugin(%{PluginName} PLUGIN_DEPENDS QtCreator::Core |