qt.prf 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. CONFIG *= thread
  2. #handle defines
  3. win32 {
  4. contains(QT_CONFIG, shared) {
  5. # this variable is read by qmake in qmake/generators/win32/msvc_vcproj.cpp
  6. # function VcprojGenerator::initDeploymentTool()
  7. QMAKE_DLL_PATHS += $$[QT_INSTALL_BINS/get]
  8. }
  9. }
  10. CONFIG(release, debug|release):DEFINES += QT_NO_DEBUG
  11. contains(QT_CONFIG, force_asserts):DEFINES += QT_FORCE_ASSERTS
  12. no_keywords:DEFINES += QT_NO_KEYWORDS
  13. plugin { #Qt plugins
  14. static:DEFINES += QT_STATICPLUGIN
  15. DEFINES += QT_PLUGIN
  16. }
  17. qtestlib {
  18. warning("CONFIG+=qtestlib is deprecated. Use QT+=testlib instead.")
  19. QT += testlib
  20. }
  21. qdbus {
  22. warning("CONFIG+=qdbus is deprecated. Use QT+=dbus instead.")
  23. QT += dbus
  24. }
  25. help {
  26. warning("CONFIG+=help is deprecated. Use QT+=help instead.")
  27. QT += help-private # sic!
  28. }
  29. designer {
  30. warning("CONFIG+=designer is deprecated. Use QT+=designer instead.")
  31. QT += designer
  32. }
  33. uitools {
  34. warning("CONFIG+=uitools is deprecated. Use QT+=uitools instead.")
  35. QT += uitools
  36. }
  37. qaxcontainer {
  38. warning("CONFIG+=qaxcontainer is deprecated. Use QT+=axcontainer instead.")
  39. QT += axcontainer
  40. }
  41. qaxserver {
  42. warning("CONFIG+=qaxserver is deprecated. Use QT+=axserver instead.")
  43. QT += axserver
  44. }
  45. # target variable, flag source variable
  46. defineTest(qtProcessModuleFlags) {
  47. for(flag, $$2) {
  48. contains(flag, ^-.*): \
  49. $$1 -= $$replace(flag, ^-, )
  50. else: \
  51. $$1 += $$flag
  52. }
  53. export($$1)
  54. }
  55. unset(using_privates)
  56. var_sfx =
  57. for(ever) {
  58. # qmake variables cannot contain dashes, so normalize the names first
  59. CLEAN_QT$$var_sfx = $$replace(QT$$var_sfx, -private$, _private)
  60. # Topological resolution of modules based on their QT.<module>.depends variable
  61. FULL_QT$$var_sfx = $$resolve_depends(CLEAN_QT$$var_sfx, "QT.")
  62. # Finally actually add the modules
  63. unset(BAD_QT)
  64. for(QTLIB, FULL_QT$$var_sfx) {
  65. MODULE_NAME = $$eval(QT.$${QTLIB}.name)
  66. MODULE_MODULE = $$eval(QT.$${QTLIB}.module)
  67. MODULE_INCLUDES = $$eval(QT.$${QTLIB}.includes)
  68. MODULE_LIBS = $$eval(QT.$${QTLIB}.libs)
  69. MODULE_FRAMEWORKS = $$eval(QT.$${QTLIB}.frameworks)
  70. MODULE_CONFIG = $$eval(QT.$${QTLIB}.module_config)
  71. isEmpty(MODULE_NAME) {
  72. BAD_QT += $$QTLIB
  73. next()
  74. }
  75. contains(MODULE_CONFIG, internal_module): \
  76. using_privates = true
  77. contains(MODULE_CONFIG, ltcg): \
  78. CONFIG += link_ltcg
  79. qtProcessModuleFlags(CONFIG, QT.$${QTLIB}.CONFIG)
  80. qtProcessModuleFlags(DEFINES, QT.$${QTLIB}.DEFINES)
  81. MODULE_INCLUDES -= $$QMAKE_DEFAULT_INCDIRS
  82. MODULE_LIBS_ADD = $$MODULE_LIBS
  83. MODULE_LIBS_ADD -= $$QMAKE_DEFAULT_LIBDIRS
  84. !contains(MODULE_CONFIG, v2) {
  85. # Backwards compatibility with pre-5.6 module .pri files
  86. contains(MODULE_CONFIG, lib_bundle) {
  87. MODULE_FRAMEWORKS = $$MODULE_LIBS
  88. inc = $$MODULE_LIBS/$${MODULE_NAME}.framework/Headers
  89. MODULE_INCLUDES = $$inc
  90. contains(MODULE_CONFIG, internal_module): \
  91. MODULE_INCLUDES += \
  92. $$inc/$$eval(QT.$${QTLIB}.VERSION) \
  93. $$inc/$$eval(QT.$${QTLIB}.VERSION)/$$MODULE_NAME
  94. } else {
  95. # Re-insert the major version in the library name (cf qt5LibraryTarget above)
  96. MODULE_NAME ~= s,^Qt,Qt$$QT_MAJOR_VERSION,
  97. }
  98. # Only link to this module if a libs directory is set, else this is just a module
  99. # to give access to sources or include files, and not for linking.
  100. !isEmpty(MODULE_LIBS):!contains(MODULE_CONFIG, no_link): \
  101. MODULE_MODULE = $${MODULE_NAME}$${QT_LIBINFIX}
  102. }
  103. # Frameworks shouldn't need include paths, but much code does not use
  104. # module-qualified #includes, so by default we add paths which point
  105. # directly into the frameworks. Private modules have somewhat convoluted
  106. # header paths, so adding them is necessary in every case.
  107. !if(contains(MODULE_CONFIG, lib_bundle):qt_no_framework_direct_includes) \
  108. |contains(MODULE_CONFIG, internal_module): \
  109. INCLUDEPATH *= $$MODULE_INCLUDES
  110. QMAKE_FRAMEWORKPATH *= $$MODULE_FRAMEWORKS
  111. !isEmpty(MODULE_MODULE) {
  112. contains(MODULE_CONFIG, lib_bundle) {
  113. LIBS$$var_sfx += -framework $$MODULE_MODULE
  114. } else {
  115. !isEmpty(MODULE_LIBS_ADD): \
  116. LIBS$$var_sfx += -L$$MODULE_LIBS_ADD
  117. lib = $$MODULE_MODULE$$qtPlatformTargetSuffix()
  118. LIBS$$var_sfx += -l$$lib
  119. contains(MODULE_CONFIG, staticlib): \
  120. PRE_TARGETDEPS *= $$MODULE_LIBS/$${QMAKE_PREFIX_STATICLIB}$${lib}.$${QMAKE_EXTENSION_STATICLIB}
  121. !isEmpty(QMAKE_LSB) {
  122. !isEmpty(MODULE_LIBS_ADD): \
  123. QMAKE_LFLAGS *= --lsb-libpath=$$MODULE_LIBS_ADD
  124. QMAKE_LFLAGS *= --lsb-shared-libs=$$lib
  125. QMAKE_LIBDIR *= /opt/lsb/lib
  126. }
  127. }
  128. }
  129. # Add capabilities as defined by modules used in the project
  130. winrt {
  131. MODULE_WINRT_CAPABILITIES = $$eval(QT.$${QTLIB}.winrt_capabilities)
  132. !isEmpty(MODULE_WINRT_CAPABILITIES): \
  133. WINRT_MANIFEST.capabilities_default += $$MODULE_WINRT_CAPABILITIES
  134. MODULE_WINRT_CAPABILITIES_DEVICE = $$eval(QT.$${QTLIB}.winrt_capabilities_device)
  135. !isEmpty(MODULE_WINRT_CAPABILITIES_DEVICE): \
  136. WINRT_MANIFEST.capabilities_device_default += $$MODULE_WINRT_CAPABILITIES_DEVICE
  137. }
  138. }
  139. !isEmpty(BAD_QT):error("Unknown module(s) in QT$$var_sfx: $$replace(BAD_QT, _private$, -private)")
  140. !isEmpty(var_sfx): break()
  141. var_sfx = _PRIVATE
  142. }
  143. !isEmpty(using_privates):!no_private_qt_headers_warning:!build_pass {
  144. message("This project is using private headers and will therefore be tied to this specific Qt module build version.")
  145. message("Running this project against other versions of the Qt modules may crash at any arbitrary point.")
  146. message("This is not a bug, but a result of using Qt internals. You have been warned!")
  147. }
  148. qt_module_deps = $$CLEAN_QT $$CLEAN_QT_PRIVATE
  149. qt_module_deps = $$resolve_depends(qt_module_deps, "QT.")
  150. !no_qt_rpath:!static:contains(QT_CONFIG, rpath):!contains(QT_CONFIG, static):\
  151. contains(qt_module_deps, core) {
  152. relative_qt_rpath:!isEmpty(QMAKE_REL_RPATH_BASE):contains(INSTALLS, target):\
  153. isEmpty(target.files):isEmpty(target.commands):isEmpty(target.extra) {
  154. # NOT the /dev property, as INSTALLS use host paths
  155. QMAKE_RPATHDIR += $$relative_path($$[QT_INSTALL_LIBS], $$qtRelativeRPathBase())
  156. } else {
  157. QMAKE_RPATHDIR += $$[QT_INSTALL_LIBS/dev]
  158. }
  159. }
  160. !isEmpty(QMAKE_LFLAGS_RPATHLINK):!contains(QT_CONFIG, static) {
  161. # -rpath-link is used by the linker to find dependencies of dynamic
  162. # libraries which were NOT specified on the command line.
  163. # This means that paths of direct dependencies (QT & QT_PRIVATE)
  164. # don't need to be listed, unlike their private dependencies' paths.
  165. privdep = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends")
  166. privdep -= $$qt_module_deps
  167. rpaths =
  168. for(dep, privdep): \
  169. rpaths += $$eval(QT.$${dep}.libs)
  170. QMAKE_RPATHLINKDIR *= $$unique(rpaths)
  171. }
  172. # static builds: link qml import plugins into the app.
  173. contains(qt_module_deps, qml): \
  174. contains(QT_CONFIG, static):contains(TEMPLATE, .*app):!host_build:!no_import_scan {
  175. !isEmpty(QTREPOS) {
  176. for (qrep, QTREPOS): \
  177. exists($$qrep/qml): \
  178. QMLPATHS += $$qrep/qml
  179. } else {
  180. QMLPATHS += $$[QT_INSTALL_QML/get]
  181. }
  182. # run qmlimportscanner
  183. qtPrepareTool(QMLIMPORTSCANNER, qmlimportscanner, , system)
  184. for (QMLPATH, QMLPATHS): \
  185. IMPORTPATHS += -importPath $$system_quote($$QMLPATH)
  186. #message(run $$QMLIMPORTSCANNER $$_PRO_FILE_PWD_ $$IMPORTPATHS)
  187. JSON = $$system($$QMLIMPORTSCANNER $$system_quote($$_PRO_FILE_PWD_) $$IMPORTPATHS)
  188. parseJson(JSON, IMPORTS)| error("Failed to parse qmlimportscanner output.")
  189. !isEmpty(IMPORTS._KEYS_) {
  190. # add import plugins to LIBS line
  191. for (key, IMPORTS._KEYS_) {
  192. PATH = $$eval(IMPORTS.$${key}.path)
  193. PLUGIN = $$eval(IMPORTS.$${key}.plugin)
  194. !isEmpty(PATH):!isEmpty(PLUGIN): LIBS *= -L$$PATH -l$${PLUGIN}$$qtPlatformTargetSuffix()
  195. }
  196. # create qml_plugin_import.cpp
  197. IMPORT_FILE_CONT = \
  198. "// This file is autogenerated by qmake. It imports static plugin classes for" \
  199. "// static plugins used by QML imports." \
  200. "$${LITERAL_HASH}include <QtPlugin>"
  201. for (key, IMPORTS._KEYS_) {
  202. PLUGIN = $$eval(IMPORTS.$${key}.plugin)
  203. CLASSNAME = $$eval(IMPORTS.$${key}.classname)
  204. !isEmpty(PLUGIN) {
  205. !isEmpty(CLASSNAME) {
  206. !contains(ADDED_IMPORTS, $$PLUGIN) {
  207. ADDED_IMPORTS += $$PLUGIN
  208. IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$CLASSNAME)"
  209. }
  210. } else {
  211. error("Plugin $$PLUGIN is missing a classname entry, please add one to the qmldir file.")
  212. }
  213. }
  214. }
  215. QML_IMPORT_CPP = $$OUT_PWD/$$lower($$basename(TARGET))_qml_plugin_import.cpp
  216. write_file($$QML_IMPORT_CPP, IMPORT_FILE_CONT)|error("Aborting.")
  217. GENERATED_SOURCES += $$QML_IMPORT_CPP
  218. QMAKE_DISTCLEAN += $$QML_IMPORT_CPP
  219. # copy qml files. this part is platform spesific.
  220. mac {
  221. osx {
  222. # Note: user can override QMAKE_BUNDLE_QML from pro file to change target bundle path
  223. isEmpty(QMAKE_QML_BUNDLE_PATH):QMAKE_QML_BUNDLE_PATH = "Resources/qt_qml"
  224. qmlTargetPath = $$OUT_PWD/$${TARGET}.app/Contents/$$QMAKE_QML_BUNDLE_PATH
  225. qtconfTargetPath = $$OUT_PWD/$${TARGET}.app/Contents/Resources/qt.conf
  226. } else {
  227. # iOS: flat bundle layout (no Contents/Resources)
  228. isEmpty(QMAKE_QML_BUNDLE_PATH):QMAKE_QML_BUNDLE_PATH = "qt_qml"
  229. qmlTargetPath = $CODESIGNING_FOLDER_PATH/$$QMAKE_QML_BUNDLE_PATH
  230. qtconfTargetPath = $CODESIGNING_FOLDER_PATH/qt.conf
  231. }
  232. # set import path in qt.conf to point to the bundeled qml:
  233. QT_CONF_CONTENTS = \
  234. "[Paths]" \
  235. "Imports = $$QMAKE_QML_BUNDLE_PATH" \
  236. "Qml2Imports = $$QMAKE_QML_BUNDLE_PATH"
  237. write_file("$$OUT_PWD/qt.conf", QT_CONF_CONTENTS)|error("Aborting.")
  238. # write qt.conf and copy each qml import dir into the bundle.
  239. # But strip away archives and other files that are not needed:
  240. !isEmpty(QMAKE_POST_LINK): QMAKE_POST_LINK += ";"
  241. QMAKE_POST_LINK += \
  242. "cp $$shell_quote($$OUT_PWD/qt.conf) \"$$qtconfTargetPath\"; " \
  243. "test -d \"$$qmlTargetPath\" && rm -r \"$$qmlTargetPath\"; " \
  244. "mkdir -p \"$$qmlTargetPath\" && " \
  245. "for p in $$QMLPATHS; do" \
  246. "rsync -r --exclude='*.a' --exclude='*.prl' --exclude='*.qmltypes' "
  247. macx-xcode: QMAKE_POST_LINK += "$p/ \"$$qmlTargetPath\"; done"
  248. else: QMAKE_POST_LINK += "\$\$p/ \"$$qmlTargetPath\"; done"
  249. }
  250. }
  251. }
  252. !import_qpa_plugin {
  253. warning("CONFIG-=import_qpa_plugin is deprecated. Use QTPLUGIN.platforms=- instead.")
  254. QTPLUGIN.platforms = -
  255. } else: qpa_minimal_plugin {
  256. warning("CONFIG+=qpa_minimal_plugin is deprecated. Use QTPLUGIN.platforms=qminimal instead.")
  257. QTPLUGIN.platforms = qminimal
  258. }
  259. contains(TEMPLATE, .*app) {
  260. autoplugs =
  261. for (qtmod, qt_module_deps) {
  262. for (ptype, QT.$${qtmod}.plugin_types) {
  263. isEmpty(QTPLUGIN.$$ptype) {
  264. for (plug, QT_PLUGINS) {
  265. equals(QT_PLUGIN.$${plug}.TYPE, $$ptype) {
  266. for (dep, QT_PLUGIN.$${plug}.EXTENDS) {
  267. !contains(qt_module_deps, $$dep) {
  268. plug =
  269. break()
  270. }
  271. }
  272. autoplugs += $$plug
  273. }
  274. }
  275. } else {
  276. plug = $$eval(QTPLUGIN.$$ptype)
  277. !equals(plug, -): \
  278. autoplugs += $$plug
  279. }
  280. }
  281. }
  282. manualplugs = $$QTPLUGIN
  283. manualplugs -= $$autoplugs
  284. QTPLUGIN -= $$manualplugs
  285. !isEmpty(QTPLUGIN): \
  286. warning("Redundant entries in QTPLUGIN: $$QTPLUGIN")
  287. QTPLUGIN = $$manualplugs $$autoplugs
  288. }
  289. contains(TEMPLATE, .*lib) {
  290. pkgconfig_prefix_replace.match = "prefix=$$[QT_SYSROOT]"
  291. pkgconfig_prefix_replace.replace = "prefix="
  292. pkgconfig_prefix_replace.CONFIG = path
  293. QMAKE_PKGCONFIG_INSTALL_REPLACE += pkgconfig_prefix_replace
  294. # drop -L/usr/lib in .prl files
  295. prl_replace.match = "-L\$${libdir}"
  296. prl_replace.replace = ""
  297. prl_replace.CONFIG = path
  298. QMAKE_PRL_INSTALL_REPLACE += prl_replace
  299. }
  300. QT_PLUGIN_VERIFY = DEPLOYMENT_PLUGIN
  301. contains(QT_CONFIG, static) {
  302. QT_PLUGIN_VERIFY += QTPLUGIN
  303. force_import_plugins|contains(TEMPLATE, .*app) {
  304. import_plugins:!isEmpty(QTPLUGIN) {
  305. IMPORT_FILE_CONT = \
  306. "// This file is autogenerated by qmake. It imports static plugin classes for" \
  307. "// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS.<plugin> variables." \
  308. "$${LITERAL_HASH}include <QtPlugin>"
  309. for(IMPORT_PLUG, $$list($$unique(QTPLUGIN))) {
  310. PLUG_CLASS = $$eval(QT_PLUGIN.$${IMPORT_PLUG}.CLASS_NAME)
  311. !isEmpty(PLUG_CLASS): \
  312. IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$PLUG_CLASS)"
  313. else: \
  314. warning("Plugin class name could not be determined for $$IMPORT_PLUG plugin.")
  315. }
  316. IMPORT_CPP = $$OUT_PWD/$$lower($$basename(TARGET))_plugin_import.cpp
  317. write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error("Aborting.")
  318. GENERATED_SOURCES += $$IMPORT_CPP
  319. QMAKE_DISTCLEAN += $$IMPORT_CPP
  320. }
  321. }
  322. }
  323. for(QT_CURRENT_VERIFY, $$list($$QT_PLUGIN_VERIFY)) {
  324. for(QTPLUG, $$list($$lower($$unique($$QT_CURRENT_VERIFY)))) {
  325. # Check if the plugin is known to Qt. We can use this to determine
  326. # the plugin path. Unknown plugins must rely on the default link path.
  327. QT_PLUGINPATH = $$eval(QT_PLUGIN.$${QTPLUG}.TYPE)
  328. # Generate the plugin linker line
  329. QT_LINKAGE = -l$${QTPLUG}$$qtPlatformTargetSuffix()
  330. # Only link against plugin in static builds
  331. isEqual(QT_CURRENT_VERIFY, QTPLUGIN) {
  332. !isEmpty(QT_PLUGINPATH) {
  333. plugpath = $$eval(QT_PLUGIN.$${QTPLUG}.PATH)
  334. isEmpty(plugpath): \
  335. plugpath = $$[QT_INSTALL_PLUGINS/get]
  336. LIBS *= -L$$plugpath/$$QT_PLUGINPATH
  337. }
  338. LIBS += $$QT_LINKAGE
  339. # if the plugin is linked statically there is no need to deploy it
  340. DEPLOYMENT_PLUGIN -= $$QT_CURRENT_VERIFY
  341. }
  342. # The following block is currently broken, because qt_plugin_XXX.prf files
  343. # are not generated for dynamic builds.
  344. false:isEqual(QT_CURRENT_VERIFY, DEPLOYMENT_PLUGIN):shared:if(wince*|winrt) {
  345. QT_ITEM =
  346. debug: QT_ITEM = $${QTPLUG}d4.dll
  347. else: QT_ITEM = $${QTPLUG}4.dll
  348. qt_additional_plugin_$${QTPLUG}.files = $$[QT_INSTALL_PLUGINS/get]/$${QT_PLUGINPATH}/$${QT_ITEM}
  349. qt_additional_plugin_$${QTPLUG}.path = $${QT_PLUGINPATH}
  350. INSTALLS *= qt_additional_plugin_$${QTPLUG}
  351. }
  352. }
  353. }