From 2ef846a300fe39c6cec168e8af36d5bdff96ea84 Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Fri, 17 Jan 2025 17:31:04 +0100 Subject: [PATCH] Qt Creator Plugin Wizard: Add custom target to run Qt Creator This commit will add the CMake boilerplate code that will just allow the resulted plugin project to "Run". A custom CMake target named "RunQtCreator" will be created. The Qt Creator executable referenced by the Qt Creator "Devel" package will be used as command whth the '-pluginpath' of the newely created plugin. Change-Id: I503a2bc5004ab2c890032e0af0cb1f4bbfcd4326 Reviewed-by: Eike Ziller --- .../wizards/qtcreatorplugin/CMakeLists.txt | 18 ++++++++++++++++++ .../wizards/qtcreatorplugin/README.md | 17 ++++++----------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt b/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt index d933a878514..0b371647c31 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/CMakeLists.txt @@ -55,3 +55,21 @@ add_qtc_plugin(%{PluginName} %{ConstantsHdrFileName} %{TrHdrFileName} ) + +# Enable the Run button in Qt Creator +get_target_property(QtCreatorCorePath QtCreator::Core LOCATION) +find_program(QtCreatorExecutable + NAMES + qtcreator "Qt Creator" + PATHS + "${QtCreatorCorePath}/../../../bin" + "${QtCreatorCorePath}/../../../MacOS" + NO_DEFAULT_PATH +) +if (QtCreatorExecutable) + add_custom_target(RunQtCreator + COMMAND ${QtCreatorExecutable} -pluginpath $ + DEPENDS %{PluginName} + ) + set_target_properties(RunQtCreator PROPERTIES FOLDER "qtc_runnable") +endif() diff --git a/share/qtcreator/templates/wizards/qtcreatorplugin/README.md b/share/qtcreator/templates/wizards/qtcreatorplugin/README.md index 035b6c5c885..03ff02dff8e 100644 --- a/share/qtcreator/templates/wizards/qtcreatorplugin/README.md +++ b/share/qtcreator/templates/wizards/qtcreatorplugin/README.md @@ -14,7 +14,12 @@ relative or absolute path to this plugin directory. ## How to Run -Run a compatible Qt Creator with the additional command line argument +From the command line run + + cmake --build . --target RunQtCreator + +`RunQtCreator` is a custom CMake target that will use the referenced above to +start the Qt Creator executable with the following parameters -pluginpath @@ -24,13 +29,3 @@ where `` is the path to the resulting plugin library in the buil You might want to add `-temporarycleansettings` (or `-tcs`) to ensure that the opened Qt Creator instance cannot mess with your user-global Qt Creator settings. - -When building and running the plugin from Qt Creator, you can use - - -pluginpath "%{buildDir}/lib/qtcreator/plugins" -tcs - -on Windows and Linux, or - - -pluginpath "%{buildDir}/Qt Creator.app/Contents/PlugIns" -tcs - -for the `Command line arguments` field in the run settings.