qtcreatorplugin.pri 5.29 KB
Newer Older
1 2 3 4 5 6 7 8 9
depfile = $$replace(_PRO_FILE_PWD_, ([^/]+$), \\1/\\1_dependencies.pri)
exists($$depfile) {
    include($$depfile)
    isEmpty(QTC_PLUGIN_NAME): \
        error("$$basename(depfile) does not define QTC_PLUGIN_NAME.")
} else {
    isEmpty(QTC_PLUGIN_NAME): \
        error("QTC_PLUGIN_NAME is empty. Maybe you meant to create $$basename(depfile)?")
}
10
TARGET = $$QTC_PLUGIN_NAME
11

12 13 14 15 16
plugin_deps = $$QTC_PLUGIN_DEPENDS
plugin_recmds = $$QTC_PLUGIN_RECOMMENDS

include(../qtcreator.pri)

17 18
# for substitution in the .pluginspec
dependencyList = "<dependencyList>"
19
for(dep, plugin_deps) {
20 21 22 23 24 25 26 27 28 29
    dependencies_file =
    for(dir, QTC_PLUGIN_DIRS) {
        exists($$dir/$$dep/$${dep}_dependencies.pri) {
            dependencies_file = $$dir/$$dep/$${dep}_dependencies.pri
            break()
        }
    }
    isEmpty(dependencies_file): \
        error("Plugin dependency $$dep not found")
    include($$dependencies_file)
30 31
    dependencyList += "        <dependency name=\"$$QTC_PLUGIN_NAME\" version=\"$$QTCREATOR_VERSION\"/>"
}
32
for(dep, plugin_recmds) {
33 34 35 36 37 38 39 40 41 42
    dependencies_file =
    for(dir, QTC_PLUGIN_DIRS) {
        exists($$dir/$$dep/$${dep}_dependencies.pri) {
            dependencies_file = $$dir/$$dep/$${dep}_dependencies.pri
            break()
        }
    }
    isEmpty(dependencies_file): \
        error("Plugin dependency $$dep not found")
    include($$dependencies_file)
43 44 45 46 47
    dependencyList += "        <dependency name=\"$$QTC_PLUGIN_NAME\" version=\"$$QTCREATOR_VERSION\" type=\"optional\"/>"
}
dependencyList += "    </dependencyList>"
dependencyList = $$join(dependencyList, $$escape_expand(\\n))

48 49 50
# use gui precompiled header for plugins by default
isEmpty(PRECOMPILED_HEADER):PRECOMPILED_HEADER = $$PWD/shared/qtcreator_gui_pch.h

con's avatar
con committed
51
isEmpty(PROVIDER) {
52
    PROVIDER = QtProject
53
} else {
54
    LIBS += -L$$IDE_PLUGIN_PATH/QtProject
con's avatar
con committed
55 56
}

57 58 59
isEmpty(USE_USER_DESTDIR) {
    DESTDIR = $$IDE_PLUGIN_PATH/$$PROVIDER
} else {
60 61 62 63 64 65 66 67 68
    win32 {
        DESTDIRAPPNAME = "qtcreator"
        DESTDIRBASE = "$$(LOCALAPPDATA)"
        isEmpty(DESTDIRBASE):DESTDIRBASE="$$(USERPROFILE)\Local Settings\Application Data"
    } else:macx {
        DESTDIRAPPNAME = "Qt Creator"
        DESTDIRBASE = "$$(HOME)/Library/Application Support"
    } else:unix {
        DESTDIRAPPNAME = "qtcreator"
69
        DESTDIRBASE = "$$(XDG_DATA_HOME)"
70
        isEmpty(DESTDIRBASE):DESTDIRBASE = "$$(HOME)/.local/share/data"
71
        else:DESTDIRBASE = "$$DESTDIRBASE/data"
72
    }
73
    DESTDIR = "$$DESTDIRBASE/QtProject/$$DESTDIRAPPNAME/plugins/$$QTCREATOR_VERSION/$$PROVIDER"
74
}
con's avatar
con committed
75 76 77 78
LIBS += -L$$DESTDIR

# copy the plugin spec
isEmpty(TARGET) {
79
    error("qtcreatorplugin.pri: You must provide a TARGET")
con's avatar
con committed
80 81
}

82 83 84 85 86 87 88 89
isEqual(QT_MAJOR_VERSION, 5) {

defineReplace(stripOutDir) {
    return($$relative_path($$1, $$OUT_PWD))
}

} else { # qt5

90 91 92 93 94
defineReplace(stripOutDir) {
    1 ~= s|^$$re_escape($$OUT_PWD/)||$$i_flag
    return($$1)
}

95 96
} # qt5

97 98 99 100
PLUGINSPEC = $$_PRO_FILE_PWD_/$${TARGET}.pluginspec
PLUGINSPEC_IN = $${PLUGINSPEC}.in
exists($$PLUGINSPEC_IN) {
    OTHER_FILES += $$PLUGINSPEC_IN
101
    QMAKE_SUBSTITUTES += $$PLUGINSPEC_IN
102 103 104 105 106 107 108 109
    PLUGINSPEC = $$OUT_PWD/$${TARGET}.pluginspec
    copy2build.output = $$DESTDIR/${QMAKE_FUNC_FILE_IN_stripOutDir}
} else {
    # need to support that for external plugins
    OTHER_FILES += $$PLUGINSPEC
    copy2build.output = $$DESTDIR/${QMAKE_FUNC_FILE_IN_stripSrcDir}
}
copy2build.input = PLUGINSPEC
110
isEmpty(vcproj):copy2build.variable_out = PRE_TARGETDEPS
111
copy2build.commands = $$QMAKE_COPY ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
112
copy2build.name = COPY ${QMAKE_FILE_IN}
113
copy2build.CONFIG += no_link no_clean
114
QMAKE_EXTRA_COMPILERS += copy2build
con's avatar
con committed
115

116 117 118 119 120 121 122 123 124 125
greaterThan(QT_MAJOR_VERSION, 4) {
#   Create a Json file containing the plugin information required by
#   Qt 5's plugin system by running a XSLT sheet on the
#   pluginspec file before moc runs.
    XMLPATTERNS = $$targetPath($$[QT_INSTALL_BINS]/xmlpatterns)

    pluginspec2json.name = Create Qt 5 plugin json file
    pluginspec2json.input = PLUGINSPEC
    pluginspec2json.variable_out = GENERATED_FILES
    pluginspec2json.output = $${TARGET}.json
126
    pluginspec2json.commands = $$XMLPATTERNS -no-format -output $$pluginspec2json.output $$PWD/qtcreatorplugin2json.xsl $$PLUGINSPEC
127 128 129 130 131
    pluginspec2json.CONFIG += no_link
    moc_header.depends += $$pluginspec2json.output
    QMAKE_EXTRA_COMPILERS += pluginspec2json
}

con's avatar
con committed
132
macx {
133 134
    QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/PlugIns/$${PROVIDER}/
    QMAKE_LFLAGS += -Wl,-rpath,@loader_path/../../,-rpath,@executable_path/../
con's avatar
con committed
135 136
} else:linux-* {
    #do the rpath by hand since it's not possible to use ORIGIN in QMAKE_RPATHDIR
Daniel Molkentin's avatar
Daniel Molkentin committed
137
    QMAKE_RPATHDIR += \$\$ORIGIN
con's avatar
con committed
138
    QMAKE_RPATHDIR += \$\$ORIGIN/..
Daniel Molkentin's avatar
Daniel Molkentin committed
139
    QMAKE_RPATHDIR += \$\$ORIGIN/../..
con's avatar
con committed
140 141 142 143 144 145
    IDE_PLUGIN_RPATH = $$join(QMAKE_RPATHDIR, ":")
    QMAKE_LFLAGS += -Wl,-z,origin \'-Wl,-rpath,$${IDE_PLUGIN_RPATH}\'
    QMAKE_RPATHDIR =
}

contains(QT_CONFIG, reduce_exports):CONFIG += hide_symbols
146

147
TEMPLATE = lib
con's avatar
con committed
148
CONFIG += plugin plugin_with_soname
149
linux*:QMAKE_LFLAGS += $$QMAKE_LFLAGS_NOUNDEF
150

151
!macx {
Daniel Molkentin's avatar
Daniel Molkentin committed
152
    target.path = $$QTC_PREFIX/$$IDE_LIBRARY_BASENAME/qtcreator/plugins/$$PROVIDER
Daniel Molkentin's avatar
Daniel Molkentin committed
153
    pluginspec.files += $${TARGET}.pluginspec
Daniel Molkentin's avatar
Daniel Molkentin committed
154
    pluginspec.path = $$QTC_PREFIX/$$IDE_LIBRARY_BASENAME/qtcreator/plugins/$$PROVIDER
Daniel Molkentin's avatar
Daniel Molkentin committed
155
    INSTALLS += target pluginspec
156
}
dt's avatar
dt committed
157

158 159 160
MIMETYPES = $$_PRO_FILE_PWD_/$${TARGET}.mimetypes.xml
exists($$MIMETYPES):OTHER_FILES += $$MIMETYPES

161
TARGET = $$qtLibraryName($$TARGET)
dt's avatar
dt committed
162