1# 2# W A R N I N G 3# ------------- 4# 5# This file is not part of the Qt API. It exists purely as an 6# implementation detail. It may change from version to version 7# without notice, or even be removed. 8# 9# We mean it. 10# 11 12defineTest(addInstallFiles) { 13 for(sf, 2) { 14 sf = $$relative_path($$sf, $$_PRO_FILE_PWD_) 15 contains(sf, \\..*) { 16 check_examples: message("Notice: $$_PRO_FILE_ refers to $$sf") 17 } else { 18 sfp = $$replace(sf, /.*, ) 19 !equals(sfp, $$sf): \ 20 $$1 *= $$sfp 21 else: \ 22 $$1 += $$sf 23 } 24 } 25 export($$1) 26} 27 28moduleRoot = $$dirname(_QMAKE_CONF_) 29probase = $$relative_path($$_PRO_FILE_PWD_, $$moduleRoot/examples) 30isEmpty(probase)|contains(probase, ^\\..*): \ 31 return() 32 33isEmpty(_QMAKE_CACHE_) { 34 moduleRootRelativeToBuildDir = $$relative_path($$moduleRoot, $$OUT_PWD) 35 # Check if OUT_PWD is inside module root 36 equals(moduleRootRelativeToBuildDir, .)|contains(moduleRootRelativeToBuildDir, \(\.\./\)+\(\.\.\)?): \ 37 error("You cannot build examples inside the Qt source tree, except as part of a proper Qt build.") 38} 39 40contains(TEMPLATE, "vc.*"): \ 41 return() 42 43contains(TEMPLATE, .*app): \ 44 qtSetQmlPath() 45 46for(ex, EXAMPLE_FILES): \ 47 sourcefiles += $$files($$absolute_path($$ex, $$_PRO_FILE_PWD_)) 48for(res, RESOURCES) { 49 !contains(res, .*\\.qrc): \ 50 next() 51 rfile = $$absolute_path($$res, $$_PRO_FILE_PWD_) 52 rpath = $$dirname(rfile) 53 rcont = $$cat($$rfile, lines) 54 for (rline, rcont) { 55 resrc = $$replace(rline, ^[ \\t]*<file[^>]*>([^<]+)</file>[ \\t]*$, \\1) 56 !equals(resrc, $$rline): \ 57 sourcefiles += $$absolute_path($$resrc, $$rpath) 58 } 59} 60for(res, RC_FILE) { 61 rfile = $$absolute_path($$res, $$_PRO_FILE_PWD_) 62 rpath = $$dirname(rfile) 63 rcont = $$cat($$rfile, lines) 64 for (rline, rcont) { 65 resrc = $$replace(rline, "^\\d+\\s+ICON\\s+[^\"]*\"([^\"]+)\"\$", \\1) 66 !equals(resrc, $$rline): \ 67 sourcefiles += $$absolute_path($$resrc, $$rpath) 68 } 69} 70sourcefiles += \ 71 $$ANDROID_PACKAGE_SOURCE_DIR \ 72 $$QMAKE_INFO_PLIST \ 73 $$DISTFILES 74extras = \ 75 $$_PRO_FILE_PWD_/README \ 76 $$_PRO_FILE_PWD_/README.TXT \ 77 $$_PRO_FILE_PWD_/qmldir \ 78 $$files($$_PRO_FILE_PWD_/*.pri) \ 79 $$replace(_PRO_FILE_, \\.pro$, .qmlproject) \ 80 $$replace(_PRO_FILE_, \\.pro$, .json) \ 81 $$replace(_PRO_FILE_, \\.pro$, .inf) 82for(extra, extras): \ 83 exists($$extra): \ 84 sourcefiles += $$extra 85 86# Just for Qt Creator 87OTHER_FILES += $$sourcefiles 88 89sourcefiles += \ 90 $$_PRO_FILE_ $$RC_FILE $$DEF_FILE \ 91 $$SOURCES $$HEADERS $$FORMS $$RESOURCES $$TRANSLATIONS \ 92 $$DBUS_ADAPTORS $$DBUS_INTERFACES 93addInstallFiles(sources.files, $$sourcefiles) 94sources.path = $$[QT_INSTALL_EXAMPLES]/$$probase 95INSTALLS += sources 96 97check_examples { 98 srcfiles = $$sources.files 99 for(inst, INSTALLS): \ 100 !equals(inst, target):!contains($${inst}.CONFIG, no_check_exist): \ 101 for(file, $${inst}.files): \ 102 instfiles += $$files($$absolute_path($$file, $$_PRO_FILE_PWD_)) 103 addInstallFiles(srcfiles, $$instfiles) 104 105 thefiles = $$files($$_PRO_FILE_PWD_/*) 106 for(i, thefiles): \ 107 allfiles += $$relative_path($$i, $$_PRO_FILE_PWD_) 108 for(i, srcfiles): \ 109 allfiles -= $$relative_path($$i, $$_PRO_FILE_PWD_) 110 for(i, SUBDIRS) { 111 sd = $$eval($${i}.file) 112 !isEmpty(sd) { 113 sd ~= s,/.*,, 114 } else { 115 sd = $$eval($${i}.subdir) 116 isEmpty(sd): sd = $$i 117 } 118 allfiles -= $$sd 119 } 120 allfiles -= doc 121 !isEmpty(allfiles): warning("remaining files in $$_PRO_FILE_PWD_: $$allfiles") 122} 123 124equals(TEMPLATE, app)|equals(TEMPLATE, lib) { 125 !contains(INSTALLS, target) { 126 !install_ok: \ 127 error("$$_PRO_FILE_ is lacking an install target.") 128 else: check_examples: \ 129 warning("$$_PRO_FILE_ is lacking an install target.") 130 } else: !equals(target.path, $$sources.path) { 131 !install_ok: \ 132 error("$$_PRO_FILE_ installs target to unexpected location.") 133 else: check_examples: \ 134 warning("$$_PRO_FILE_ installs target to unexpected location.") 135 } 136} 137 138!equals(TEMPLATE, subdirs):!compile_examples { 139 TEMPLATE = aux 140 CONFIG -= have_target qt staticlib dll 141 SOURCES = 142 OBJECTIVE_SOURCES = 143 INSTALLS -= target 144 QMAKE_SUBSTITUTES = 145 QMAKE_EXTRA_COMPILERS = 146 COPIES = 147} else { 148 CONFIG += relative_qt_rpath # Examples built as part of Qt should be relocatable 149} 150