diff --git a/libnymea/devices/plugin.pri b/libnymea/devices/plugin.pri index 1eccb4bb..ee4f8ebe 100644 --- a/libnymea/devices/plugin.pri +++ b/libnymea/devices/plugin.pri @@ -1,4 +1,4 @@ -# Copyright (C) 2018 Michael Zanetti +# Copyright (C) 2019 Michael Zanetti # Copyright (C) 2018 Simon Stürz # # This file is part of nymea. @@ -18,10 +18,10 @@ # . # This project include file is meant to be used by nymea plugins. + # Example project file for a plugin: -# include(/usr/include/nymea/plugi.pri) -# TARGET = $$qtLibraryTarget(nymea_devicepluginexample) +# include($$[QT_INSTALL_PREFIX]/include/nymea/plugi.pri) # SOURCES += devicepluginexample.cpp # HEADERS += devicepluginexample.h @@ -34,30 +34,26 @@ PKGCONFIG += nymea QMAKE_CXXFLAGS *= -Werror -std=c++11 -g QMAKE_LFLAGS *= -std=c++11 -# Check if ccache is enabled -ccache { - QMAKE_CXX = ccache g++ -} +JSONFILE=$${_PRO_FILE_PWD_}/deviceplugin"$$TARGET".json # Make the device plugin json file visible in the Qt Creator -OTHER_FILES+=deviceplugin"$$TARGET".json +OTHER_FILES += $$JSONFILE -# NOTE: if the code includes "plugininfo.h", it would fail if we only give it a compiler for $$OUT_PWD/plugininfo.h -# Let's add a dummy target with the plugininfo.h file without any path to allow the developer to just include it like that. +# Compile the plugininfo.h file +plugininfo.input = JSONFILE +plugininfo.output = plugininfo.h +plugininfo.commands = nymea-plugininfocompiler ${QMAKE_FILE_NAME} --output ${QMAKE_FILE_OUT} +plugininfo.dependency_type = TYPE_C +plugininfo.CONFIG += no_link combine +QMAKE_EXTRA_COMPILERS += plugininfo -# Create plugininfo file -plugininfo.target = $$OUT_PWD/plugininfo.h -extern-plugininfo.target = $$OUT_PWD/extern-plugininfo.h -plugininfo_dummy.target = plugininfo.h -extern-plugininfo_dummy.target = extern-plugininfo.h -plugininfo.depends = FORCE -plugininfo.commands = nymea-plugininfocompiler \ - $${_PRO_FILE_PWD_}/deviceplugin"$$TARGET".json \ - --output $$OUT_PWD/plugininfo.h \ - --extern $$OUT_PWD/extern-plugininfo.h -plugininfo_dummy.commands = $$plugininfo.commands -extern-plugininfo.depends = plugininfo -QMAKE_EXTRA_TARGETS += plugininfo plugininfo_dummy extern-plugininfo extern-plugininfo_dummy +# Compile the extern-plugininfo.h file +extern_plugininfo.input = JSONFILE +extern_plugininfo.output = extern-plugininfo.h +extern_plugininfo.commands = nymea-plugininfocompiler ${QMAKE_FILE_NAME} --extern ${QMAKE_FILE_OUT} +extern_plugininfo.dependency_type = TYPE_C +extern_plugininfo.CONFIG += no_link combine +QMAKE_EXTRA_COMPILERS += extern_plugininfo # Clean up autogenerated plugin info files plugininfo_clean.commands = rm -fv $$OUT_PWD/plugininfo.h $$OUT_PWD/extern-plugininfo.h @@ -80,10 +76,7 @@ QMAKE_EXTRA_TARGETS += lrelease translations.path = /usr/share/nymea/translations translations.files = $$[QT_SOURCE_TREE]/translations/*.qm -HEADERS += $$OUT_PWD/plugininfo.h \ - $$OUT_PWD/extern-plugininfo.h -DEPENDPATH += $$OUT_PWD - +# Redefine target to make output file suite the plugin filename schema TARGET = $$qtLibraryTarget(nymea_deviceplugin"$$TARGET") # Install plugin