diff --git a/app_templates/CMakeLists.txt b/app_templates/CMakeLists.txt --- a/app_templates/CMakeLists.txt +++ b/app_templates/CMakeLists.txt @@ -4,6 +4,7 @@ cpp/CMake/cmake_qt4core_qtest cpp/CMake/cmake_qt4gui cpp/CMake/cmake_qt5guiapp + cpp/CMake/cmake_kdevplugin cpp/QMake/qmake_qt4guiapp cpp/QMake/qt5-qml2 empty diff --git a/app_templates/cpp/CMake/cmake_kdevplugin/%{PROJECTDIRNAME}.kdev4 b/app_templates/cpp/CMake/cmake_kdevplugin/%{PROJECTDIRNAME}.kdev4 new file mode 100644 --- /dev/null +++ b/app_templates/cpp/CMake/cmake_kdevplugin/%{PROJECTDIRNAME}.kdev4 @@ -0,0 +1,4 @@ +[Project] +Name=%{APPNAME} +Manager=KDevCMakeManager +VersionControl=%{VERSIONCONTROLPLUGIN} diff --git a/app_templates/cpp/CMake/cmake_kdevplugin/CMakeLists.txt b/app_templates/cpp/CMake/cmake_kdevplugin/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/app_templates/cpp/CMake/cmake_kdevplugin/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 2.8.12) + +project(%{APPNAME}) + +find_package(ECM 1.0.0 REQUIRED NO_MODULE) +set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) + +include(KDEInstallDirs) +include(KDECMakeSettings) +include(KDECompilerSettings NO_POLICY_SCOPE) + +find_package(KDevPlatform 5.0 REQUIRED) + +add_subdirectory(src) diff --git a/app_templates/cpp/CMake/cmake_kdevplugin/README.md b/app_templates/cpp/CMake/cmake_kdevplugin/README.md new file mode 100644 --- /dev/null +++ b/app_templates/cpp/CMake/cmake_kdevplugin/README.md @@ -0,0 +1,35 @@ +# Simple KDevelop Plugin + +## Installation instructions + +Make sure the project is configured to install to the directory of your choice: + +In KDevelop, select the menu entry "Project" > "Open Configuration...", +then in the dialog choose the tab "CMake", +there select in the "Cache Values" list the entry with the name `CMAKE_INSTALL_PREFIX` +and ensure the correct path is set. + +If you install to a custom directory, you need to extend the `QT_PLUGIN_PATH` +environment variable that KDevelop sees when it is started. The path to be added +is the "plugins" subdir, whose exact path depends on the operating system and +if that is a 64 bit or 32 bit one. +On Debian, Ubuntu & similar with a 64 bit system add: + $my_install_prefix/lib/x86_64-linux-gnu/plugins +On openSUSE & similar with a 64 bit system add: + $my_install_prefix/lib64/plugins +(where `$my_install_prefix` is the directory `CMAKE_INSTALL_PREFIX` is set to) + +If you are unsure, check in the installation log the path to which the plugin is installed. + + +Example: +When CMAKE_INSTALL_PREFIX is set to "/home/userX/projects/mykdevplugin/" and +this is a Debian 64-bit system, open a console and enter: + + export QT_PLUGIN_PATH=$QT_PLUGIN_PATH:/home/userX/projects/mykdevplugin/lib/x86_64-linux-gnu/plugins + +Then start KDevelop from that console: + + kdevelop + +If everything went well, you should see "Hello world, my plugin is loaded!" printed in the console and find the plugin also listed in the dialog opened by the menu entry "Help" > "Loaded Plugins". diff --git a/app_templates/cpp/CMake/cmake_kdevplugin/cmake_kdevplugin.kdevtemplate b/app_templates/cpp/CMake/cmake_kdevplugin/cmake_kdevplugin.kdevtemplate new file mode 100644 --- /dev/null +++ b/app_templates/cpp/CMake/cmake_kdevplugin/cmake_kdevplugin.kdevtemplate @@ -0,0 +1,7 @@ +# KDE Config File +[General] +Name=Simple KDevelop Plugin +Comment=Generate a general KDevelop plugin, using CMake and C++ +ShowFilesAfterGeneration=%{PROJECTDIR}/src/%{APPNAMELC}.cpp +Category=KDevelop/Plugin +ValidProjectName=^[a-zA-Z_][a-zA-Z0-9_]+$ diff --git a/app_templates/cpp/CMake/cmake_kdevplugin/src/%{APPNAMELC}.h b/app_templates/cpp/CMake/cmake_kdevplugin/src/%{APPNAMELC}.h new file mode 100644 --- /dev/null +++ b/app_templates/cpp/CMake/cmake_kdevplugin/src/%{APPNAMELC}.h @@ -0,0 +1,15 @@ +#ifndef %{APPNAMEUC}_H +#define %{APPNAMEUC}_H + +#include + +class %{APPNAME} : public KDevelop::IPlugin +{ + Q_OBJECT + +public: + // KPluginFactory-based plugin wants constructor with this signature + %{APPNAME}(QObject* parent, const QVariantList& args); +}; + +#endif // %{APPNAMEUC}_H diff --git a/app_templates/cpp/CMake/cmake_kdevplugin/src/%{APPNAMELC}.cpp b/app_templates/cpp/CMake/cmake_kdevplugin/src/%{APPNAMELC}.cpp new file mode 100644 --- /dev/null +++ b/app_templates/cpp/CMake/cmake_kdevplugin/src/%{APPNAMELC}.cpp @@ -0,0 +1,18 @@ +#include "%{APPNAMELC}.h" + +#include + +#include + +K_PLUGIN_FACTORY_WITH_JSON(%{APPNAME}Factory, "%{APPNAMELC}.json", registerPlugin<%{APPNAME}>(); ) + +%{APPNAME}::%{APPNAME}(QObject *parent, const QVariantList& args) + : KDevelop::IPlugin(QStringLiteral("%{APPNAMELC}"), parent) +{ + Q_UNUSED(args); + + qDebug() << "Hello world, my plugin is loaded!"; +} + +// needed for QObject class created from K_PLUGIN_FACTORY_WITH_JSON +#include "%{APPNAMELC}.moc" diff --git a/app_templates/cpp/CMake/cmake_kdevplugin/src/%{APPNAMELC}.json b/app_templates/cpp/CMake/cmake_kdevplugin/src/%{APPNAMELC}.json new file mode 100644 --- /dev/null +++ b/app_templates/cpp/CMake/cmake_kdevplugin/src/%{APPNAMELC}.json @@ -0,0 +1,12 @@ +{ + "KPlugin": { + "Id": "%{APPNAMELC}", + "Name": "%{APPNAME}", + "Description": "%{APPNAME}", + "ServiceTypes": [ + "KDevelop/Plugin" + ] + }, + "X-KDevelop-Category": "Global", + "X-KDevelop-Mode": "GUI" +} diff --git a/app_templates/cpp/CMake/cmake_kdevplugin/src/CMakeLists.txt b/app_templates/cpp/CMake/cmake_kdevplugin/src/CMakeLists.txt new file mode 100644 --- /dev/null +++ b/app_templates/cpp/CMake/cmake_kdevplugin/src/CMakeLists.txt @@ -0,0 +1,8 @@ +kdevplatform_add_plugin(%{APPNAMELC} + JSON %{APPNAMELC}.json + SOURCES %{APPNAMELC}.cpp +) + +target_link_libraries(%{APPNAMELC} + KDev::Interfaces +)