cmQtAutoGenInitializer.cxx 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmQtAutoGenInitializer.h"
  4. #include "cmQtAutoGen.h"
  5. #include "cmQtAutoGenGlobalInitializer.h"
  6. #include "cmCustomCommand.h"
  7. #include "cmCustomCommandLines.h"
  8. #include "cmFilePathChecksum.h"
  9. #include "cmGeneratorExpression.h"
  10. #include "cmGeneratorTarget.h"
  11. #include "cmGlobalGenerator.h"
  12. #include "cmLinkItem.h"
  13. #include "cmListFileCache.h"
  14. #include "cmLocalGenerator.h"
  15. #include "cmMakefile.h"
  16. #include "cmMessageType.h"
  17. #include "cmOutputConverter.h"
  18. #include "cmPolicies.h"
  19. #include "cmSourceFile.h"
  20. #include "cmSourceFileLocationKind.h"
  21. #include "cmSourceGroup.h"
  22. #include "cmState.h"
  23. #include "cmStateTypes.h"
  24. #include "cmStringAlgorithms.h"
  25. #include "cmSystemTools.h"
  26. #include "cmTarget.h"
  27. #include "cmake.h"
  28. #include "cmsys/SystemInformation.hxx"
  29. #include <algorithm>
  30. #include <cstddef>
  31. #include <deque>
  32. #include <initializer_list>
  33. #include <map>
  34. #include <set>
  35. #include <string>
  36. #include <unordered_set>
  37. #include <utility>
  38. #include <vector>
  39. #include "cm_memory.hxx"
  40. static std::size_t GetParallelCPUCount()
  41. {
  42. static std::size_t count = 0;
  43. // Detect only on the first call
  44. if (count == 0) {
  45. cmsys::SystemInformation info;
  46. info.RunCPUCheck();
  47. count = info.GetNumberOfPhysicalCPU();
  48. count = std::max<std::size_t>(count, 1);
  49. count = std::min<std::size_t>(count, cmQtAutoGen::ParallelMax);
  50. }
  51. return count;
  52. }
  53. static std::string FileProjectRelativePath(cmMakefile* makefile,
  54. std::string const& fileName)
  55. {
  56. std::string res;
  57. {
  58. std::string pSource = cmSystemTools::RelativePath(
  59. makefile->GetCurrentSourceDirectory(), fileName);
  60. std::string pBinary = cmSystemTools::RelativePath(
  61. makefile->GetCurrentBinaryDirectory(), fileName);
  62. if (pSource.size() < pBinary.size()) {
  63. res = std::move(pSource);
  64. } else if (pBinary.size() < fileName.size()) {
  65. res = std::move(pBinary);
  66. } else {
  67. res = fileName;
  68. }
  69. }
  70. return res;
  71. }
  72. /**
  73. * Tests if targetDepend is a STATIC_LIBRARY and if any of its
  74. * recursive STATIC_LIBRARY dependencies depends on targetOrigin
  75. * (STATIC_LIBRARY cycle).
  76. */
  77. static bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin,
  78. cmGeneratorTarget const* targetDepend,
  79. std::string const& config)
  80. {
  81. bool cycle = false;
  82. if ((targetOrigin->GetType() == cmStateEnums::STATIC_LIBRARY) &&
  83. (targetDepend->GetType() == cmStateEnums::STATIC_LIBRARY)) {
  84. std::set<cmGeneratorTarget const*> knownLibs;
  85. std::deque<cmGeneratorTarget const*> testLibs;
  86. // Insert initial static_library dependency
  87. knownLibs.insert(targetDepend);
  88. testLibs.push_back(targetDepend);
  89. while (!testLibs.empty()) {
  90. cmGeneratorTarget const* testTarget = testLibs.front();
  91. testLibs.pop_front();
  92. // Check if the test target is the origin target (cycle)
  93. if (testTarget == targetOrigin) {
  94. cycle = true;
  95. break;
  96. }
  97. // Collect all static_library dependencies from the test target
  98. cmLinkImplementationLibraries const* libs =
  99. testTarget->GetLinkImplementationLibraries(config);
  100. if (libs != nullptr) {
  101. for (cmLinkItem const& item : libs->Libraries) {
  102. cmGeneratorTarget const* depTarget = item.Target;
  103. if ((depTarget != nullptr) &&
  104. (depTarget->GetType() == cmStateEnums::STATIC_LIBRARY) &&
  105. knownLibs.insert(depTarget).second) {
  106. testLibs.push_back(depTarget);
  107. }
  108. }
  109. }
  110. }
  111. }
  112. return cycle;
  113. }
  114. cmQtAutoGenInitializer::InfoWriter::InfoWriter(std::string const& filename)
  115. {
  116. Ofs_.SetCopyIfDifferent(true);
  117. Ofs_.Open(filename, false, true);
  118. }
  119. template <class IT>
  120. std::string cmQtAutoGenInitializer::InfoWriter::ListJoin(IT it_begin,
  121. IT it_end)
  122. {
  123. std::string res;
  124. for (IT it = it_begin; it != it_end; ++it) {
  125. if (it != it_begin) {
  126. res += ';';
  127. }
  128. for (const char* c = it->c_str(); *c; ++c) {
  129. if (*c == '"') {
  130. // Escape the double quote to avoid ending the argument.
  131. res += "\\\"";
  132. } else if (*c == '$') {
  133. // Escape the dollar to avoid expanding variables.
  134. res += "\\$";
  135. } else if (*c == '\\') {
  136. // Escape the backslash to avoid other escapes.
  137. res += "\\\\";
  138. } else if (*c == ';') {
  139. // Escape the semicolon to avoid list expansion.
  140. res += "\\;";
  141. } else {
  142. // Other characters will be parsed correctly.
  143. res += *c;
  144. }
  145. }
  146. }
  147. return res;
  148. }
  149. inline std::string cmQtAutoGenInitializer::InfoWriter::ConfigKey(
  150. cm::string_view key, std::string const& config)
  151. {
  152. return cmStrCat(key, "_", config);
  153. }
  154. void cmQtAutoGenInitializer::InfoWriter::Write(cm::string_view key,
  155. std::string const& value)
  156. {
  157. Ofs_ << "set(" << key << " " << cmOutputConverter::EscapeForCMake(value)
  158. << ")\n";
  159. };
  160. void cmQtAutoGenInitializer::InfoWriter::WriteUInt(cm::string_view key,
  161. unsigned int value)
  162. {
  163. Ofs_ << "set(" << key << " " << value << ")\n";
  164. };
  165. template <class C>
  166. void cmQtAutoGenInitializer::InfoWriter::WriteStrings(cm::string_view key,
  167. C const& container)
  168. {
  169. Ofs_ << "set(" << key << " \""
  170. << ListJoin(container.begin(), container.end()) << "\")\n";
  171. }
  172. void cmQtAutoGenInitializer::InfoWriter::WriteConfig(
  173. cm::string_view key, std::map<std::string, std::string> const& map)
  174. {
  175. for (auto const& item : map) {
  176. Write(ConfigKey(key, item.first), item.second);
  177. }
  178. };
  179. template <class C>
  180. void cmQtAutoGenInitializer::InfoWriter::WriteConfigStrings(
  181. cm::string_view key, std::map<std::string, C> const& map)
  182. {
  183. for (auto const& item : map) {
  184. WriteStrings(ConfigKey(key, item.first), item.second);
  185. }
  186. }
  187. void cmQtAutoGenInitializer::InfoWriter::WriteNestedLists(
  188. cm::string_view key, std::vector<std::vector<std::string>> const& lists)
  189. {
  190. std::vector<std::string> seplist;
  191. seplist.reserve(lists.size());
  192. for (std::vector<std::string> const& list : lists) {
  193. seplist.push_back(cmStrCat("{", ListJoin(list.begin(), list.end()), "}"));
  194. }
  195. Write(key, cmJoin(seplist, cmQtAutoGen::ListSep));
  196. };
  197. cmQtAutoGenInitializer::cmQtAutoGenInitializer(
  198. cmQtAutoGenGlobalInitializer* globalInitializer, cmGeneratorTarget* target,
  199. IntegerVersion const& qtVersion, bool mocEnabled, bool uicEnabled,
  200. bool rccEnabled, bool globalAutogenTarget, bool globalAutoRccTarget)
  201. : GlobalInitializer(globalInitializer)
  202. , Target(target)
  203. , QtVersion(qtVersion)
  204. {
  205. AutogenTarget.GlobalTarget = globalAutogenTarget;
  206. Moc.Enabled = mocEnabled;
  207. Uic.Enabled = uicEnabled;
  208. Rcc.Enabled = rccEnabled;
  209. Rcc.GlobalTarget = globalAutoRccTarget;
  210. }
  211. bool cmQtAutoGenInitializer::InitCustomTargets()
  212. {
  213. cmMakefile* makefile = this->Target->Target->GetMakefile();
  214. cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
  215. cmGlobalGenerator* globalGen = localGen->GetGlobalGenerator();
  216. // Configurations
  217. this->MultiConfig = globalGen->IsMultiConfig();
  218. this->ConfigDefault = makefile->GetConfigurations(this->ConfigsList);
  219. if (this->ConfigsList.empty()) {
  220. this->ConfigsList.push_back(this->ConfigDefault);
  221. }
  222. // Verbosity
  223. this->Verbosity = makefile->GetSafeDefinition("CMAKE_AUTOGEN_VERBOSE");
  224. if (!this->Verbosity.empty()) {
  225. unsigned long iVerb = 0;
  226. if (!cmStrToULong(this->Verbosity, &iVerb)) {
  227. // Non numeric verbosity
  228. this->Verbosity = cmIsOn(this->Verbosity) ? "1" : "0";
  229. }
  230. }
  231. // Targets FOLDER
  232. {
  233. const char* folder =
  234. makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
  235. if (folder == nullptr) {
  236. folder =
  237. makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER");
  238. }
  239. // Inherit FOLDER property from target (#13688)
  240. if (folder == nullptr) {
  241. folder = this->Target->GetProperty("FOLDER");
  242. }
  243. if (folder != nullptr) {
  244. this->TargetsFolder = folder;
  245. }
  246. }
  247. // Check status of policy CMP0071
  248. {
  249. cmPolicies::PolicyStatus const CMP0071_status =
  250. makefile->GetPolicyStatus(cmPolicies::CMP0071);
  251. switch (CMP0071_status) {
  252. case cmPolicies::WARN:
  253. this->CMP0071Warn = true;
  254. CM_FALLTHROUGH;
  255. case cmPolicies::OLD:
  256. // Ignore GENERATED file
  257. break;
  258. case cmPolicies::REQUIRED_IF_USED:
  259. case cmPolicies::REQUIRED_ALWAYS:
  260. case cmPolicies::NEW:
  261. // Process GENERATED file
  262. this->CMP0071Accept = true;
  263. break;
  264. }
  265. }
  266. // Common directories
  267. {
  268. // Collapsed current binary directory
  269. std::string const cbd = cmSystemTools::CollapseFullPath(
  270. std::string(), makefile->GetCurrentBinaryDirectory());
  271. // Info directory
  272. this->Dir.Info =
  273. cmStrCat(cbd, "/CMakeFiles/", this->Target->GetName(), "_autogen.dir");
  274. cmSystemTools::ConvertToUnixSlashes(this->Dir.Info);
  275. // Build directory
  276. this->Dir.Build = this->Target->GetSafeProperty("AUTOGEN_BUILD_DIR");
  277. if (this->Dir.Build.empty()) {
  278. this->Dir.Build =
  279. cmStrCat(cbd, '/', this->Target->GetName(), "_autogen");
  280. }
  281. cmSystemTools::ConvertToUnixSlashes(this->Dir.Build);
  282. // Cleanup build directory
  283. this->AddCleanFile(this->Dir.Build);
  284. // Working directory
  285. this->Dir.Work = cbd;
  286. cmSystemTools::ConvertToUnixSlashes(this->Dir.Work);
  287. // Include directory
  288. this->Dir.Include = cmStrCat(this->Dir.Build, "/include");
  289. if (this->MultiConfig) {
  290. this->Dir.Include += "_$<CONFIG>";
  291. }
  292. // Per config include directories
  293. if (this->MultiConfig) {
  294. for (std::string const& cfg : this->ConfigsList) {
  295. std::string& dir = this->Dir.ConfigInclude[cfg];
  296. dir = cmStrCat(this->Dir.Build, "/include_", cfg);
  297. }
  298. }
  299. }
  300. // Moc, Uic and _autogen target settings
  301. if (this->MocOrUicEnabled()) {
  302. // Init moc specific settings
  303. if (this->Moc.Enabled && !InitMoc()) {
  304. return false;
  305. }
  306. // Init uic specific settings
  307. if (this->Uic.Enabled && !InitUic()) {
  308. return false;
  309. }
  310. // Autogen target name
  311. this->AutogenTarget.Name = cmStrCat(this->Target->GetName(), "_autogen");
  312. // Autogen target parallel processing
  313. this->AutogenTarget.Parallel =
  314. this->Target->GetSafeProperty("AUTOGEN_PARALLEL");
  315. if (this->AutogenTarget.Parallel.empty() ||
  316. (this->AutogenTarget.Parallel == "AUTO")) {
  317. // Autodetect number of CPUs
  318. this->AutogenTarget.Parallel = std::to_string(GetParallelCPUCount());
  319. }
  320. // Autogen target info and settings files
  321. {
  322. this->AutogenTarget.InfoFile =
  323. cmStrCat(this->Dir.Info, "/AutogenInfo.cmake");
  324. this->AutogenTarget.SettingsFile =
  325. cmStrCat(this->Dir.Info, "/AutogenOldSettings.txt");
  326. if (this->MultiConfig) {
  327. for (std::string const& cfg : this->ConfigsList) {
  328. std::string& filename = this->AutogenTarget.ConfigSettingsFile[cfg];
  329. filename =
  330. AppendFilenameSuffix(this->AutogenTarget.SettingsFile, "_" + cfg);
  331. this->AddCleanFile(filename);
  332. }
  333. } else {
  334. this->AddCleanFile(this->AutogenTarget.SettingsFile);
  335. }
  336. this->AutogenTarget.ParseCacheFile =
  337. cmStrCat(this->Dir.Info, "/ParseCache.txt");
  338. this->AddCleanFile(this->AutogenTarget.ParseCacheFile);
  339. }
  340. // Autogen target: Compute user defined dependencies
  341. {
  342. this->AutogenTarget.DependOrigin =
  343. this->Target->GetPropertyAsBool("AUTOGEN_ORIGIN_DEPENDS");
  344. std::string const deps =
  345. this->Target->GetSafeProperty("AUTOGEN_TARGET_DEPENDS");
  346. if (!deps.empty()) {
  347. std::vector<std::string> extraDeps = cmExpandedList(deps);
  348. for (std::string const& depName : extraDeps) {
  349. // Allow target and file dependencies
  350. auto* depTarget = makefile->FindTargetToUse(depName);
  351. if (depTarget != nullptr) {
  352. this->AutogenTarget.DependTargets.insert(depTarget);
  353. } else {
  354. this->AutogenTarget.DependFiles.insert(depName);
  355. }
  356. }
  357. }
  358. }
  359. // CMAKE_AUTOMOC_RELAXED_MODE deprecation warning
  360. if (this->Moc.Enabled) {
  361. if (makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE")) {
  362. makefile->IssueMessage(
  363. MessageType::AUTHOR_WARNING,
  364. cmStrCat("AUTOMOC: CMAKE_AUTOMOC_RELAXED_MODE is "
  365. "deprecated an will be removed in the future. Consider "
  366. "disabling it and converting the target ",
  367. this->Target->GetName(), " to regular mode."));
  368. }
  369. }
  370. }
  371. // Init rcc specific settings
  372. if (this->Rcc.Enabled && !InitRcc()) {
  373. return false;
  374. }
  375. // Add autogen include directory to the origin target INCLUDE_DIRECTORIES
  376. if (this->MocOrUicEnabled() || (this->Rcc.Enabled && this->MultiConfig)) {
  377. this->Target->AddIncludeDirectory(this->Dir.Include, true);
  378. }
  379. // Scan files
  380. if (!this->InitScanFiles()) {
  381. return false;
  382. }
  383. // Create autogen target
  384. if (this->MocOrUicEnabled() && !this->InitAutogenTarget()) {
  385. return false;
  386. }
  387. // Create rcc targets
  388. if (this->Rcc.Enabled && !this->InitRccTargets()) {
  389. return false;
  390. }
  391. return true;
  392. }
  393. bool cmQtAutoGenInitializer::InitMoc()
  394. {
  395. cmMakefile* makefile = this->Target->Target->GetMakefile();
  396. cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
  397. // Mocs compilation file
  398. this->Moc.MocsCompilation =
  399. cmStrCat(this->Dir.Build, "/mocs_compilation.cpp");
  400. // Moc predefs command
  401. if (this->Target->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES") &&
  402. (this->QtVersion >= IntegerVersion(5, 8))) {
  403. this->Moc.PredefsCmd =
  404. makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND");
  405. }
  406. // Moc includes
  407. {
  408. bool const appendImplicit = (this->QtVersion.Major >= 5);
  409. auto GetIncludeDirs =
  410. [this, localGen,
  411. appendImplicit](std::string const& cfg) -> std::vector<std::string> {
  412. // Get the include dirs for this target, without stripping the implicit
  413. // include dirs off, see
  414. // https://gitlab.kitware.com/cmake/cmake/issues/13667
  415. std::vector<std::string> dirs;
  416. localGen->GetIncludeDirectoriesImplicit(dirs, this->Target, "CXX", cfg,
  417. false, appendImplicit);
  418. return dirs;
  419. };
  420. // Default configuration include directories
  421. this->Moc.Includes = GetIncludeDirs(this->ConfigDefault);
  422. // Other configuration settings
  423. if (this->MultiConfig) {
  424. for (std::string const& cfg : this->ConfigsList) {
  425. std::vector<std::string> dirs = GetIncludeDirs(cfg);
  426. if (dirs != this->Moc.Includes) {
  427. this->Moc.ConfigIncludes[cfg] = std::move(dirs);
  428. }
  429. }
  430. }
  431. }
  432. // Moc compile definitions
  433. {
  434. auto GetCompileDefinitions =
  435. [this, localGen](std::string const& cfg) -> std::set<std::string> {
  436. std::set<std::string> defines;
  437. localGen->GetTargetDefines(this->Target, cfg, "CXX", defines);
  438. #ifdef _WIN32
  439. if (this->Moc.PredefsCmd.empty()) {
  440. // Add WIN32 definition if we don't have a moc_predefs.h
  441. defines.insert("WIN32");
  442. }
  443. #endif
  444. return defines;
  445. };
  446. // Default configuration defines
  447. this->Moc.Defines = GetCompileDefinitions(this->ConfigDefault);
  448. // Other configuration defines
  449. if (this->MultiConfig) {
  450. for (std::string const& cfg : this->ConfigsList) {
  451. std::set<std::string> defines = GetCompileDefinitions(cfg);
  452. if (defines != this->Moc.Defines) {
  453. this->Moc.ConfigDefines[cfg] = std::move(defines);
  454. }
  455. }
  456. }
  457. }
  458. // Moc executable
  459. {
  460. if (!this->GetQtExecutable(this->Moc, "moc", false)) {
  461. return false;
  462. }
  463. // Let the _autogen target depend on the moc executable
  464. if (this->Moc.ExecutableTarget != nullptr) {
  465. this->AutogenTarget.DependTargets.insert(
  466. this->Moc.ExecutableTarget->Target);
  467. }
  468. }
  469. return true;
  470. }
  471. bool cmQtAutoGenInitializer::InitUic()
  472. {
  473. cmMakefile* makefile = this->Target->Target->GetMakefile();
  474. // Uic search paths
  475. {
  476. std::string const usp =
  477. this->Target->GetSafeProperty("AUTOUIC_SEARCH_PATHS");
  478. if (!usp.empty()) {
  479. cmExpandList(usp, this->Uic.SearchPaths);
  480. std::string const& srcDir = makefile->GetCurrentSourceDirectory();
  481. for (std::string& path : this->Uic.SearchPaths) {
  482. path = cmSystemTools::CollapseFullPath(path, srcDir);
  483. }
  484. }
  485. }
  486. // Uic target options
  487. {
  488. auto UicGetOpts =
  489. [this](std::string const& cfg) -> std::vector<std::string> {
  490. std::vector<std::string> opts;
  491. this->Target->GetAutoUicOptions(opts, cfg);
  492. return opts;
  493. };
  494. // Default settings
  495. this->Uic.Options = UicGetOpts(this->ConfigDefault);
  496. // Configuration specific settings
  497. if (this->MultiConfig) {
  498. for (std::string const& cfg : this->ConfigsList) {
  499. std::vector<std::string> options = UicGetOpts(cfg);
  500. if (options != this->Uic.Options) {
  501. this->Uic.ConfigOptions[cfg] = std::move(options);
  502. }
  503. }
  504. }
  505. }
  506. // Uic executable
  507. {
  508. if (!this->GetQtExecutable(this->Uic, "uic", true)) {
  509. return false;
  510. }
  511. // Let the _autogen target depend on the uic executable
  512. if (this->Uic.ExecutableTarget != nullptr) {
  513. this->AutogenTarget.DependTargets.insert(
  514. this->Uic.ExecutableTarget->Target);
  515. }
  516. }
  517. return true;
  518. }
  519. bool cmQtAutoGenInitializer::InitRcc()
  520. {
  521. // Rcc executable
  522. {
  523. if (!this->GetQtExecutable(this->Rcc, "rcc", false)) {
  524. return false;
  525. }
  526. // Evaluate test output on demand
  527. CompilerFeatures& features = *this->Rcc.ExecutableFeatures;
  528. if (!features.Evaluated) {
  529. // Look for list options
  530. if (this->QtVersion.Major == 5 || this->QtVersion.Major == 6) {
  531. if (features.HelpOutput.find("--list") != std::string::npos) {
  532. features.ListOptions.emplace_back("--list");
  533. } else if (features.HelpOutput.find("-list") != std::string::npos) {
  534. features.ListOptions.emplace_back("-list");
  535. }
  536. }
  537. // Evaluation finished
  538. features.Evaluated = true;
  539. }
  540. }
  541. return true;
  542. }
  543. bool cmQtAutoGenInitializer::InitScanFiles()
  544. {
  545. cmMakefile* makefile = this->Target->Target->GetMakefile();
  546. cmake const* cm = makefile->GetCMakeInstance();
  547. auto const& kw = this->GlobalInitializer->kw();
  548. auto makeMUFile = [this, &kw](cmSourceFile* sf, std::string const& fullPath,
  549. bool muIt) -> MUFileHandle {
  550. MUFileHandle muf = cm::make_unique<MUFile>();
  551. muf->RealPath = cmSystemTools::GetRealPath(fullPath);
  552. muf->SF = sf;
  553. muf->Generated = sf->GetIsGenerated();
  554. bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN);
  555. muf->SkipMoc = this->Moc.Enabled &&
  556. (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOMOC));
  557. muf->SkipUic = this->Uic.Enabled &&
  558. (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC));
  559. if (muIt) {
  560. muf->MocIt = this->Moc.Enabled && !muf->SkipMoc;
  561. muf->UicIt = this->Uic.Enabled && !muf->SkipUic;
  562. }
  563. return muf;
  564. };
  565. auto addMUFile = [&](MUFileHandle&& muf, bool isHeader) {
  566. if ((muf->MocIt || muf->UicIt) && muf->Generated) {
  567. this->AutogenTarget.FilesGenerated.emplace_back(muf.get());
  568. }
  569. if (isHeader) {
  570. this->AutogenTarget.Headers.emplace(muf->SF, std::move(muf));
  571. } else {
  572. this->AutogenTarget.Sources.emplace(muf->SF, std::move(muf));
  573. }
  574. };
  575. // Scan through target files
  576. {
  577. // Scan through target files
  578. std::vector<cmSourceFile*> srcFiles;
  579. this->Target->GetConfigCommonSourceFiles(srcFiles);
  580. for (cmSourceFile* sf : srcFiles) {
  581. // sf->GetExtension() is only valid after sf->GetFullPath() ...
  582. // Since we're iterating over source files that might be not in the
  583. // target we need to check for path errors (not existing files).
  584. std::string pathError;
  585. std::string const& fullPath = sf->ResolveFullPath(&pathError);
  586. if (!pathError.empty() || fullPath.empty()) {
  587. continue;
  588. }
  589. std::string const& extLower =
  590. cmSystemTools::LowerCase(sf->GetExtension());
  591. // Register files that will be scanned by moc or uic
  592. if (this->MocOrUicEnabled()) {
  593. if (cm->IsHeaderExtension(extLower)) {
  594. addMUFile(makeMUFile(sf, fullPath, true), true);
  595. } else if (cm->IsSourceExtension(extLower)) {
  596. addMUFile(makeMUFile(sf, fullPath, true), false);
  597. }
  598. }
  599. // Register rcc enabled files
  600. if (this->Rcc.Enabled) {
  601. if ((extLower == kw.qrc) && !sf->GetPropertyAsBool(kw.SKIP_AUTOGEN) &&
  602. !sf->GetPropertyAsBool(kw.SKIP_AUTORCC)) {
  603. // Register qrc file
  604. Qrc qrc;
  605. qrc.QrcFile = cmSystemTools::GetRealPath(fullPath);
  606. qrc.QrcName =
  607. cmSystemTools::GetFilenameWithoutLastExtension(qrc.QrcFile);
  608. qrc.Generated = sf->GetIsGenerated();
  609. // RCC options
  610. {
  611. std::string const opts = sf->GetSafeProperty(kw.AUTORCC_OPTIONS);
  612. if (!opts.empty()) {
  613. cmExpandList(opts, qrc.Options);
  614. }
  615. }
  616. this->Rcc.Qrcs.push_back(std::move(qrc));
  617. }
  618. }
  619. }
  620. }
  621. // cmGeneratorTarget::GetConfigCommonSourceFiles computes the target's
  622. // sources meta data cache. Clear it so that OBJECT library targets that
  623. // are AUTOGEN initialized after this target get their added
  624. // mocs_compilation.cpp source acknowledged by this target.
  625. this->Target->ClearSourcesCache();
  626. // For source files find additional headers and private headers
  627. if (this->MocOrUicEnabled()) {
  628. std::vector<MUFileHandle> extraHeaders;
  629. extraHeaders.reserve(this->AutogenTarget.Sources.size() * 2);
  630. // Header search suffixes and extensions
  631. static std::initializer_list<cm::string_view> const suffixes{ "", "_p" };
  632. auto const& exts = cm->GetHeaderExtensions();
  633. // Scan through sources
  634. for (auto const& pair : this->AutogenTarget.Sources) {
  635. MUFile const& muf = *pair.second;
  636. if (muf.MocIt || muf.UicIt) {
  637. // Search for the default header file and a private header
  638. std::string const& srcPath = muf.SF->ResolveFullPath();
  639. std::string basePath =
  640. cmStrCat(cmQtAutoGen::SubDirPrefix(srcPath),
  641. cmSystemTools::GetFilenameWithoutLastExtension(srcPath));
  642. for (auto const& suffix : suffixes) {
  643. std::string const suffixedPath = cmStrCat(basePath, suffix);
  644. for (auto const& ext : exts) {
  645. std::string fullPath = cmStrCat(suffixedPath, '.', ext);
  646. auto constexpr locationKind = cmSourceFileLocationKind::Known;
  647. cmSourceFile* sf = makefile->GetSource(fullPath, locationKind);
  648. if (sf != nullptr) {
  649. // Check if we know about this header already
  650. if (this->AutogenTarget.Headers.find(sf) !=
  651. this->AutogenTarget.Headers.end()) {
  652. continue;
  653. }
  654. // We only accept not-GENERATED files that do exist.
  655. if (!sf->GetIsGenerated() &&
  656. !cmSystemTools::FileExists(fullPath)) {
  657. continue;
  658. }
  659. } else if (cmSystemTools::FileExists(fullPath)) {
  660. // Create a new source file for the existing file
  661. sf = makefile->CreateSource(fullPath, false, locationKind);
  662. }
  663. if (sf != nullptr) {
  664. auto eMuf = makeMUFile(sf, fullPath, true);
  665. // Ony process moc/uic when the parent is processed as well
  666. if (!muf.MocIt) {
  667. eMuf->MocIt = false;
  668. }
  669. if (!muf.UicIt) {
  670. eMuf->UicIt = false;
  671. }
  672. extraHeaders.emplace_back(std::move(eMuf));
  673. }
  674. }
  675. }
  676. }
  677. }
  678. // Move generated files to main headers list
  679. for (auto& eMuf : extraHeaders) {
  680. addMUFile(std::move(eMuf), true);
  681. }
  682. }
  683. // Scan through all source files in the makefile to extract moc and uic
  684. // parameters. Historically we support non target source file parameters.
  685. // The reason is that their file names might be discovered from source files
  686. // at generation time.
  687. if (this->MocOrUicEnabled()) {
  688. for (cmSourceFile* sf : makefile->GetSourceFiles()) {
  689. // sf->GetExtension() is only valid after sf->GetFullPath() ...
  690. // Since we're iterating over source files that might be not in the
  691. // target we need to check for path errors (not existing files).
  692. std::string pathError;
  693. std::string const& fullPath = sf->ResolveFullPath(&pathError);
  694. if (!pathError.empty() || fullPath.empty()) {
  695. continue;
  696. }
  697. std::string const& extLower =
  698. cmSystemTools::LowerCase(sf->GetExtension());
  699. if (cm->IsHeaderExtension(extLower)) {
  700. if (this->AutogenTarget.Headers.find(sf) ==
  701. this->AutogenTarget.Headers.end()) {
  702. auto muf = makeMUFile(sf, fullPath, false);
  703. if (muf->SkipMoc || muf->SkipUic) {
  704. this->AutogenTarget.Headers.emplace(sf, std::move(muf));
  705. }
  706. }
  707. } else if (cm->IsSourceExtension(extLower)) {
  708. if (this->AutogenTarget.Sources.find(sf) ==
  709. this->AutogenTarget.Sources.end()) {
  710. auto muf = makeMUFile(sf, fullPath, false);
  711. if (muf->SkipMoc || muf->SkipUic) {
  712. this->AutogenTarget.Sources.emplace(sf, std::move(muf));
  713. }
  714. }
  715. } else if (this->Uic.Enabled && (extLower == kw.ui)) {
  716. // .ui file
  717. std::string realPath = cmSystemTools::GetRealPath(fullPath);
  718. bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN);
  719. bool const skipUic =
  720. (skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC));
  721. if (!skipUic) {
  722. // Check if the .ui file has uic options
  723. std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS);
  724. if (!uicOpts.empty()) {
  725. this->Uic.FileFiles.push_back(std::move(realPath));
  726. std::vector<std::string> optsVec = cmExpandedList(uicOpts);
  727. this->Uic.FileOptions.push_back(std::move(optsVec));
  728. }
  729. } else {
  730. // Register skipped .ui file
  731. this->Uic.SkipUi.insert(std::move(realPath));
  732. }
  733. }
  734. }
  735. }
  736. // Process GENERATED sources and headers
  737. if (this->MocOrUicEnabled() && !this->AutogenTarget.FilesGenerated.empty()) {
  738. if (this->CMP0071Accept) {
  739. // Let the autogen target depend on the GENERATED files
  740. for (MUFile* muf : this->AutogenTarget.FilesGenerated) {
  741. this->AutogenTarget.DependFiles.insert(muf->RealPath);
  742. }
  743. } else if (this->CMP0071Warn) {
  744. cm::string_view property;
  745. if (this->Moc.Enabled && this->Uic.Enabled) {
  746. property = "SKIP_AUTOGEN";
  747. } else if (this->Moc.Enabled) {
  748. property = "SKIP_AUTOMOC";
  749. } else if (this->Uic.Enabled) {
  750. property = "SKIP_AUTOUIC";
  751. }
  752. std::string files;
  753. for (MUFile* muf : this->AutogenTarget.FilesGenerated) {
  754. files += cmStrCat(" ", Quoted(muf->RealPath), '\n');
  755. }
  756. makefile->IssueMessage(
  757. MessageType::AUTHOR_WARNING,
  758. cmStrCat(
  759. cmPolicies::GetPolicyWarning(cmPolicies::CMP0071), '\n',
  760. "For compatibility, CMake is excluding the GENERATED source "
  761. "file(s):\n",
  762. files, "from processing by ",
  763. cmQtAutoGen::Tools(this->Moc.Enabled, this->Uic.Enabled, false),
  764. ". If any of the files should be processed, set CMP0071 to NEW. "
  765. "If any of the files should not be processed, "
  766. "explicitly exclude them by setting the source file property ",
  767. property, ":\n set_property(SOURCE file.h PROPERTY ", property,
  768. " ON)\n"));
  769. }
  770. }
  771. // Process qrc files
  772. if (!this->Rcc.Qrcs.empty()) {
  773. const bool modernQt = (this->QtVersion.Major >= 5);
  774. // Target rcc options
  775. std::vector<std::string> optionsTarget =
  776. cmExpandedList(this->Target->GetSafeProperty(kw.AUTORCC_OPTIONS));
  777. // Check if file name is unique
  778. for (Qrc& qrc : this->Rcc.Qrcs) {
  779. qrc.Unique = true;
  780. for (Qrc const& qrc2 : this->Rcc.Qrcs) {
  781. if ((&qrc != &qrc2) && (qrc.QrcName == qrc2.QrcName)) {
  782. qrc.Unique = false;
  783. break;
  784. }
  785. }
  786. }
  787. // Path checksum and file names
  788. {
  789. cmFilePathChecksum const fpathCheckSum(makefile);
  790. for (Qrc& qrc : this->Rcc.Qrcs) {
  791. qrc.PathChecksum = fpathCheckSum.getPart(qrc.QrcFile);
  792. // RCC output file name
  793. qrc.RccFile = cmStrCat(this->Dir.Build, '/', qrc.PathChecksum, "/qrc_",
  794. qrc.QrcName, ".cpp");
  795. {
  796. cm::string_view const baseSuffix =
  797. qrc.Unique ? cm::string_view() : cm::string_view(qrc.PathChecksum);
  798. std::string const base =
  799. cmStrCat(this->Dir.Info, "/RCC", qrc.QrcName, baseSuffix);
  800. qrc.LockFile = cmStrCat(base, ".lock");
  801. qrc.InfoFile = cmStrCat(base, "Info.cmake");
  802. qrc.SettingsFile = cmStrCat(base, "Settings.txt");
  803. if (this->MultiConfig) {
  804. for (std::string const& cfg : this->ConfigsList) {
  805. qrc.ConfigSettingsFile[cfg] =
  806. AppendFilenameSuffix(qrc.SettingsFile, "_" + cfg);
  807. }
  808. }
  809. }
  810. }
  811. }
  812. // RCC options
  813. for (Qrc& qrc : this->Rcc.Qrcs) {
  814. // Target options
  815. std::vector<std::string> opts = optionsTarget;
  816. // Merge computed "-name XYZ" option
  817. {
  818. std::string name = qrc.QrcName;
  819. // Replace '-' with '_'. The former is not valid for symbol names.
  820. std::replace(name.begin(), name.end(), '-', '_');
  821. if (!qrc.Unique) {
  822. name += cmStrCat('_', qrc.PathChecksum);
  823. }
  824. std::vector<std::string> nameOpts;
  825. nameOpts.emplace_back("-name");
  826. nameOpts.emplace_back(std::move(name));
  827. RccMergeOptions(opts, nameOpts, modernQt);
  828. }
  829. // Merge file option
  830. RccMergeOptions(opts, qrc.Options, modernQt);
  831. qrc.Options = std::move(opts);
  832. }
  833. // RCC resources
  834. for (Qrc& qrc : this->Rcc.Qrcs) {
  835. if (!qrc.Generated) {
  836. std::string error;
  837. RccLister const lister(this->Rcc.Executable,
  838. this->Rcc.ExecutableFeatures->ListOptions);
  839. if (!lister.list(qrc.QrcFile, qrc.Resources, error)) {
  840. cmSystemTools::Error(error);
  841. return false;
  842. }
  843. }
  844. }
  845. }
  846. return true;
  847. }
  848. bool cmQtAutoGenInitializer::InitAutogenTarget()
  849. {
  850. cmMakefile* makefile = this->Target->Target->GetMakefile();
  851. cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
  852. cmGlobalGenerator* globalGen = localGen->GetGlobalGenerator();
  853. // Register info file as generated by CMake
  854. makefile->AddCMakeOutputFile(this->AutogenTarget.InfoFile);
  855. // Files provided by the autogen target
  856. std::vector<std::string> autogenProvides;
  857. if (this->Moc.Enabled) {
  858. this->AddGeneratedSource(this->Moc.MocsCompilation, this->Moc, true);
  859. autogenProvides.push_back(this->Moc.MocsCompilation);
  860. }
  861. // Compose target comment
  862. std::string autogenComment;
  863. {
  864. std::string tools;
  865. if (this->Moc.Enabled) {
  866. tools += "MOC";
  867. }
  868. if (this->Uic.Enabled) {
  869. if (!tools.empty()) {
  870. tools += " and ";
  871. }
  872. tools += "UIC";
  873. }
  874. autogenComment =
  875. cmStrCat("Automatic ", tools, " for target ", this->Target->GetName());
  876. }
  877. // Compose command lines
  878. cmCustomCommandLines commandLines;
  879. {
  880. cmCustomCommandLine currentLine;
  881. currentLine.push_back(cmSystemTools::GetCMakeCommand());
  882. currentLine.push_back("-E");
  883. currentLine.push_back("cmake_autogen");
  884. currentLine.push_back(this->AutogenTarget.InfoFile);
  885. currentLine.push_back("$<CONFIGURATION>");
  886. commandLines.push_back(std::move(currentLine));
  887. }
  888. // Use PRE_BUILD on demand
  889. bool usePRE_BUILD = false;
  890. if (globalGen->GetName().find("Visual Studio") != std::string::npos) {
  891. // Under VS use a PRE_BUILD event instead of a separate target to
  892. // reduce the number of targets loaded into the IDE.
  893. // This also works around a VS 11 bug that may skip updating the target:
  894. // https://connect.microsoft.com/VisualStudio/feedback/details/769495
  895. usePRE_BUILD = true;
  896. }
  897. // Disable PRE_BUILD in some cases
  898. if (usePRE_BUILD) {
  899. // Cannot use PRE_BUILD with file depends
  900. if (!this->AutogenTarget.DependFiles.empty()) {
  901. usePRE_BUILD = false;
  902. }
  903. // Cannot use PRE_BUILD when a global autogen target is in place
  904. if (AutogenTarget.GlobalTarget) {
  905. usePRE_BUILD = false;
  906. }
  907. }
  908. // Create the autogen target/command
  909. if (usePRE_BUILD) {
  910. // Add additional autogen target dependencies to origin target
  911. for (cmTarget* depTarget : this->AutogenTarget.DependTargets) {
  912. this->Target->Target->AddUtility(depTarget->GetName(), makefile);
  913. }
  914. // Add the pre-build command directly to bypass the OBJECT_LIBRARY
  915. // rejection in cmMakefile::AddCustomCommandToTarget because we know
  916. // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case.
  917. //
  918. // PRE_BUILD does not support file dependencies!
  919. const std::vector<std::string> no_output;
  920. const std::vector<std::string> no_deps;
  921. cmCustomCommand cc(makefile, no_output, autogenProvides, no_deps,
  922. commandLines, autogenComment.c_str(),
  923. this->Dir.Work.c_str());
  924. cc.SetEscapeOldStyle(false);
  925. cc.SetEscapeAllowMakeVars(true);
  926. this->Target->Target->AddPreBuildCommand(cc);
  927. } else {
  928. // Add link library target dependencies to the autogen target
  929. // dependencies
  930. if (this->AutogenTarget.DependOrigin) {
  931. // add_dependencies/addUtility do not support generator expressions.
  932. // We depend only on the libraries found in all configs therefore.
  933. std::map<cmGeneratorTarget const*, std::size_t> commonTargets;
  934. for (std::string const& config : this->ConfigsList) {
  935. cmLinkImplementationLibraries const* libs =
  936. this->Target->GetLinkImplementationLibraries(config);
  937. if (libs != nullptr) {
  938. for (cmLinkItem const& item : libs->Libraries) {
  939. cmGeneratorTarget const* libTarget = item.Target;
  940. if ((libTarget != nullptr) &&
  941. !StaticLibraryCycle(this->Target, libTarget, config)) {
  942. // Increment target config count
  943. commonTargets[libTarget]++;
  944. }
  945. }
  946. }
  947. }
  948. for (auto const& item : commonTargets) {
  949. if (item.second == this->ConfigsList.size()) {
  950. this->AutogenTarget.DependTargets.insert(item.first->Target);
  951. }
  952. }
  953. }
  954. // Create autogen target
  955. cmTarget* autogenTarget = makefile->AddUtilityCommand(
  956. this->AutogenTarget.Name, cmMakefile::TargetOrigin::Generator, true,
  957. this->Dir.Work.c_str(), /*byproducts=*/autogenProvides,
  958. std::vector<std::string>(this->AutogenTarget.DependFiles.begin(),
  959. this->AutogenTarget.DependFiles.end()),
  960. commandLines, false, autogenComment.c_str());
  961. // Create autogen generator target
  962. localGen->AddGeneratorTarget(
  963. new cmGeneratorTarget(autogenTarget, localGen));
  964. // Forward origin utilities to autogen target
  965. if (this->AutogenTarget.DependOrigin) {
  966. for (BT<std::string> const& depName : this->Target->GetUtilities()) {
  967. autogenTarget->AddUtility(depName.Value, makefile);
  968. }
  969. }
  970. // Add additional autogen target dependencies to autogen target
  971. for (cmTarget* depTarget : this->AutogenTarget.DependTargets) {
  972. autogenTarget->AddUtility(depTarget->GetName(), makefile);
  973. }
  974. // Set FOLDER property in autogen target
  975. if (!this->TargetsFolder.empty()) {
  976. autogenTarget->SetProperty("FOLDER", this->TargetsFolder.c_str());
  977. }
  978. // Add autogen target to the origin target dependencies
  979. this->Target->Target->AddUtility(this->AutogenTarget.Name, makefile);
  980. // Add autogen target to the global autogen target dependencies
  981. if (this->AutogenTarget.GlobalTarget) {
  982. this->GlobalInitializer->AddToGlobalAutoGen(localGen,
  983. this->AutogenTarget.Name);
  984. }
  985. }
  986. return true;
  987. }
  988. bool cmQtAutoGenInitializer::InitRccTargets()
  989. {
  990. cmMakefile* makefile = this->Target->Target->GetMakefile();
  991. cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
  992. for (Qrc const& qrc : this->Rcc.Qrcs) {
  993. // Register info file as generated by CMake
  994. makefile->AddCMakeOutputFile(qrc.InfoFile);
  995. // Register file at target
  996. this->AddGeneratedSource(qrc.RccFile, this->Rcc);
  997. std::vector<std::string> ccOutput;
  998. ccOutput.push_back(qrc.RccFile);
  999. std::vector<std::string> ccDepends;
  1000. // Add the .qrc and info file to the custom command dependencies
  1001. ccDepends.push_back(qrc.QrcFile);
  1002. ccDepends.push_back(qrc.InfoFile);
  1003. cmCustomCommandLines commandLines;
  1004. if (this->MultiConfig) {
  1005. // Build for all configurations
  1006. for (std::string const& config : this->ConfigsList) {
  1007. cmCustomCommandLine currentLine;
  1008. currentLine.push_back(cmSystemTools::GetCMakeCommand());
  1009. currentLine.push_back("-E");
  1010. currentLine.push_back("cmake_autorcc");
  1011. currentLine.push_back(qrc.InfoFile);
  1012. currentLine.push_back(config);
  1013. commandLines.push_back(std::move(currentLine));
  1014. }
  1015. } else {
  1016. cmCustomCommandLine currentLine;
  1017. currentLine.push_back(cmSystemTools::GetCMakeCommand());
  1018. currentLine.push_back("-E");
  1019. currentLine.push_back("cmake_autorcc");
  1020. currentLine.push_back(qrc.InfoFile);
  1021. currentLine.push_back("$<CONFIG>");
  1022. commandLines.push_back(std::move(currentLine));
  1023. }
  1024. std::string ccComment = cmStrCat(
  1025. "Automatic RCC for ", FileProjectRelativePath(makefile, qrc.QrcFile));
  1026. if (qrc.Generated || this->Rcc.GlobalTarget) {
  1027. // Create custom rcc target
  1028. std::string ccName;
  1029. {
  1030. ccName = cmStrCat(this->Target->GetName(), "_arcc_", qrc.QrcName);
  1031. if (!qrc.Unique) {
  1032. ccName += cmStrCat('_', qrc.PathChecksum);
  1033. }
  1034. cmTarget* autoRccTarget = makefile->AddUtilityCommand(
  1035. ccName, cmMakefile::TargetOrigin::Generator, true,
  1036. this->Dir.Work.c_str(), ccOutput, ccDepends, commandLines, false,
  1037. ccComment.c_str());
  1038. // Create autogen generator target
  1039. localGen->AddGeneratorTarget(
  1040. new cmGeneratorTarget(autoRccTarget, localGen));
  1041. // Set FOLDER property in autogen target
  1042. if (!this->TargetsFolder.empty()) {
  1043. autoRccTarget->SetProperty("FOLDER", this->TargetsFolder.c_str());
  1044. }
  1045. if (!this->Rcc.ExecutableTargetName.empty()) {
  1046. autoRccTarget->AddUtility(this->Rcc.ExecutableTargetName, makefile);
  1047. }
  1048. }
  1049. // Add autogen target to the origin target dependencies
  1050. this->Target->Target->AddUtility(ccName, makefile);
  1051. // Add autogen target to the global autogen target dependencies
  1052. if (this->Rcc.GlobalTarget) {
  1053. this->GlobalInitializer->AddToGlobalAutoRcc(localGen, ccName);
  1054. }
  1055. } else {
  1056. // Create custom rcc command
  1057. {
  1058. std::vector<std::string> ccByproducts;
  1059. // Add the resource files to the dependencies
  1060. for (std::string const& fileName : qrc.Resources) {
  1061. // Add resource file to the custom command dependencies
  1062. ccDepends.push_back(fileName);
  1063. }
  1064. if (!this->Rcc.ExecutableTargetName.empty()) {
  1065. ccDepends.push_back(this->Rcc.ExecutableTargetName);
  1066. }
  1067. std::string no_main_dependency;
  1068. cmImplicitDependsList no_implicit_depends;
  1069. makefile->AddCustomCommandToOutput(
  1070. ccOutput, ccByproducts, ccDepends, no_main_dependency,
  1071. no_implicit_depends, commandLines, ccComment.c_str(),
  1072. this->Dir.Work.c_str());
  1073. }
  1074. // Reconfigure when .qrc file changes
  1075. makefile->AddCMakeDependFile(qrc.QrcFile);
  1076. }
  1077. }
  1078. return true;
  1079. }
  1080. bool cmQtAutoGenInitializer::SetupCustomTargets()
  1081. {
  1082. // Create info directory on demand
  1083. if (!cmSystemTools::MakeDirectory(this->Dir.Info)) {
  1084. cmSystemTools::Error(cmStrCat("AutoGen: Could not create directory: ",
  1085. Quoted(this->Dir.Info)));
  1086. return false;
  1087. }
  1088. // Generate autogen target info file
  1089. if (this->MocOrUicEnabled()) {
  1090. // Write autogen target info files
  1091. if (!this->SetupWriteAutogenInfo()) {
  1092. return false;
  1093. }
  1094. }
  1095. // Write AUTORCC info files
  1096. return !this->Rcc.Enabled || this->SetupWriteRccInfo();
  1097. }
  1098. bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
  1099. {
  1100. InfoWriter ofs(this->AutogenTarget.InfoFile);
  1101. if (ofs) {
  1102. // Utility lambdas
  1103. cmMakefile* makefile = this->Target->Target->GetMakefile();
  1104. auto MfDef = [makefile](const char* key) {
  1105. return makefile->GetSafeDefinition(key);
  1106. };
  1107. // Write common settings
  1108. ofs.Write("# Meta\n");
  1109. ofs.Write("AM_MULTI_CONFIG", this->MultiConfig ? "TRUE" : "FALSE");
  1110. ofs.Write("AM_PARALLEL", this->AutogenTarget.Parallel);
  1111. ofs.Write("AM_VERBOSITY", this->Verbosity);
  1112. ofs.Write("# Directories\n");
  1113. ofs.Write("AM_CMAKE_SOURCE_DIR", MfDef("CMAKE_SOURCE_DIR"));
  1114. ofs.Write("AM_CMAKE_BINARY_DIR", MfDef("CMAKE_BINARY_DIR"));
  1115. ofs.Write("AM_CMAKE_CURRENT_SOURCE_DIR",
  1116. MfDef("CMAKE_CURRENT_SOURCE_DIR"));
  1117. ofs.Write("AM_CMAKE_CURRENT_BINARY_DIR",
  1118. MfDef("CMAKE_CURRENT_BINARY_DIR"));
  1119. ofs.Write("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE",
  1120. MfDef("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"));
  1121. ofs.Write("AM_BUILD_DIR", this->Dir.Build);
  1122. ofs.Write("AM_INCLUDE_DIR", this->Dir.Include);
  1123. ofs.WriteConfig("AM_INCLUDE_DIR", this->Dir.ConfigInclude);
  1124. std::vector<std::string> headers;
  1125. std::vector<std::string> headersFlags;
  1126. std::vector<std::string> headersBuildPaths;
  1127. std::vector<std::string> sources;
  1128. std::vector<std::string> sourcesFlags;
  1129. std::set<std::string> moc_skip;
  1130. std::set<std::string> uic_skip;
  1131. // Filter headers
  1132. {
  1133. auto headerCount = this->AutogenTarget.Headers.size();
  1134. headers.reserve(headerCount);
  1135. headersFlags.reserve(headerCount);
  1136. std::vector<MUFile const*> sortedHeaders;
  1137. {
  1138. sortedHeaders.reserve(headerCount);
  1139. for (auto const& pair : this->AutogenTarget.Headers) {
  1140. sortedHeaders.emplace_back(pair.second.get());
  1141. }
  1142. std::sort(sortedHeaders.begin(), sortedHeaders.end(),
  1143. [](MUFile const* a, MUFile const* b) {
  1144. return (a->RealPath < b->RealPath);
  1145. });
  1146. }
  1147. for (MUFile const* const muf : sortedHeaders) {
  1148. if (muf->Generated && !this->CMP0071Accept) {
  1149. continue;
  1150. }
  1151. if (muf->SkipMoc) {
  1152. moc_skip.insert(muf->RealPath);
  1153. }
  1154. if (muf->SkipUic) {
  1155. uic_skip.insert(muf->RealPath);
  1156. }
  1157. if (muf->MocIt || muf->UicIt) {
  1158. headers.emplace_back(muf->RealPath);
  1159. headersFlags.emplace_back(
  1160. cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u'));
  1161. }
  1162. }
  1163. }
  1164. // Header build paths
  1165. {
  1166. cmFilePathChecksum const fpathCheckSum(makefile);
  1167. std::unordered_set<std::string> emitted;
  1168. for (std::string const& hdr : headers) {
  1169. std::string const basePath =
  1170. cmStrCat(fpathCheckSum.getPart(hdr), "/moc_",
  1171. cmSystemTools::GetFilenameWithoutLastExtension(hdr));
  1172. std::string suffix;
  1173. for (int ii = 0; ii != 1024; ++ii) {
  1174. std::string path = cmStrCat(basePath, suffix, ".cpp");
  1175. if (emitted.emplace(path).second) {
  1176. headersBuildPaths.emplace_back(std::move(path));
  1177. break;
  1178. }
  1179. suffix = cmStrCat('_', ii + 1);
  1180. }
  1181. }
  1182. }
  1183. // Filter sources
  1184. {
  1185. auto sourcesCount = this->AutogenTarget.Sources.size();
  1186. sources.reserve(sourcesCount);
  1187. sourcesFlags.reserve(sourcesCount);
  1188. std::vector<MUFile const*> sorted;
  1189. sorted.reserve(sourcesCount);
  1190. for (auto const& pair : this->AutogenTarget.Sources) {
  1191. sorted.emplace_back(pair.second.get());
  1192. }
  1193. std::sort(sorted.begin(), sorted.end(),
  1194. [](MUFile const* a, MUFile const* b) {
  1195. return (a->RealPath < b->RealPath);
  1196. });
  1197. for (MUFile const* const muf : sorted) {
  1198. if (muf->Generated && !this->CMP0071Accept) {
  1199. continue;
  1200. }
  1201. if (muf->SkipMoc) {
  1202. moc_skip.insert(muf->RealPath);
  1203. }
  1204. if (muf->SkipUic) {
  1205. uic_skip.insert(muf->RealPath);
  1206. }
  1207. if (muf->MocIt || muf->UicIt) {
  1208. sources.emplace_back(muf->RealPath);
  1209. sourcesFlags.emplace_back(
  1210. cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u'));
  1211. }
  1212. }
  1213. }
  1214. ofs.Write("# Qt\n");
  1215. ofs.WriteUInt("AM_QT_VERSION_MAJOR", this->QtVersion.Major);
  1216. ofs.Write("AM_QT_MOC_EXECUTABLE", this->Moc.Executable);
  1217. ofs.Write("AM_QT_UIC_EXECUTABLE", this->Uic.Executable);
  1218. ofs.Write("# Files\n");
  1219. ofs.Write("AM_CMAKE_EXECUTABLE", cmSystemTools::GetCMakeCommand());
  1220. ofs.Write("AM_SETTINGS_FILE", this->AutogenTarget.SettingsFile);
  1221. ofs.WriteConfig("AM_SETTINGS_FILE",
  1222. this->AutogenTarget.ConfigSettingsFile);
  1223. ofs.Write("AM_PARSE_CACHE_FILE", this->AutogenTarget.ParseCacheFile);
  1224. ofs.WriteStrings("AM_HEADERS", headers);
  1225. ofs.WriteStrings("AM_HEADERS_FLAGS", headersFlags);
  1226. ofs.WriteStrings("AM_HEADERS_BUILD_PATHS", headersBuildPaths);
  1227. ofs.WriteStrings("AM_SOURCES", sources);
  1228. ofs.WriteStrings("AM_SOURCES_FLAGS", sourcesFlags);
  1229. // Write moc settings
  1230. if (this->Moc.Enabled) {
  1231. ofs.Write("# MOC settings\n");
  1232. ofs.WriteStrings("AM_MOC_SKIP", moc_skip);
  1233. ofs.WriteStrings("AM_MOC_DEFINITIONS", this->Moc.Defines);
  1234. ofs.WriteConfigStrings("AM_MOC_DEFINITIONS", this->Moc.ConfigDefines);
  1235. ofs.WriteStrings("AM_MOC_INCLUDES", this->Moc.Includes);
  1236. ofs.WriteConfigStrings("AM_MOC_INCLUDES", this->Moc.ConfigIncludes);
  1237. ofs.Write("AM_MOC_OPTIONS",
  1238. this->Target->GetSafeProperty("AUTOMOC_MOC_OPTIONS"));
  1239. ofs.Write("AM_MOC_RELAXED_MODE", MfDef("CMAKE_AUTOMOC_RELAXED_MODE"));
  1240. ofs.Write("AM_MOC_MACRO_NAMES",
  1241. this->Target->GetSafeProperty("AUTOMOC_MACRO_NAMES"));
  1242. ofs.Write("AM_MOC_DEPEND_FILTERS",
  1243. this->Target->GetSafeProperty("AUTOMOC_DEPEND_FILTERS"));
  1244. ofs.Write("AM_MOC_PREDEFS_CMD", this->Moc.PredefsCmd);
  1245. }
  1246. // Write uic settings
  1247. if (this->Uic.Enabled) {
  1248. // Add skipped .ui files
  1249. uic_skip.insert(this->Uic.SkipUi.begin(), this->Uic.SkipUi.end());
  1250. ofs.Write("# UIC settings\n");
  1251. ofs.WriteStrings("AM_UIC_SKIP", uic_skip);
  1252. ofs.WriteStrings("AM_UIC_TARGET_OPTIONS", this->Uic.Options);
  1253. ofs.WriteConfigStrings("AM_UIC_TARGET_OPTIONS", this->Uic.ConfigOptions);
  1254. ofs.WriteStrings("AM_UIC_OPTIONS_FILES", this->Uic.FileFiles);
  1255. ofs.WriteNestedLists("AM_UIC_OPTIONS_OPTIONS", this->Uic.FileOptions);
  1256. ofs.WriteStrings("AM_UIC_SEARCH_PATHS", this->Uic.SearchPaths);
  1257. }
  1258. } else {
  1259. cmSystemTools::Error(cmStrCat("AutoGen: Could not write file ",
  1260. this->AutogenTarget.InfoFile));
  1261. return false;
  1262. }
  1263. return true;
  1264. }
  1265. bool cmQtAutoGenInitializer::SetupWriteRccInfo()
  1266. {
  1267. for (Qrc const& qrc : this->Rcc.Qrcs) {
  1268. InfoWriter ofs(qrc.InfoFile);
  1269. if (ofs) {
  1270. // Write
  1271. ofs.Write("# Configurations\n");
  1272. ofs.Write("ARCC_MULTI_CONFIG", this->MultiConfig ? "TRUE" : "FALSE");
  1273. ofs.Write("ARCC_VERBOSITY", this->Verbosity);
  1274. ofs.Write("# Settings file\n");
  1275. ofs.Write("ARCC_SETTINGS_FILE", qrc.SettingsFile);
  1276. ofs.WriteConfig("ARCC_SETTINGS_FILE", qrc.ConfigSettingsFile);
  1277. ofs.Write("# Directories\n");
  1278. ofs.Write("ARCC_BUILD_DIR", this->Dir.Build);
  1279. ofs.Write("ARCC_INCLUDE_DIR", this->Dir.Include);
  1280. ofs.WriteConfig("ARCC_INCLUDE_DIR", this->Dir.ConfigInclude);
  1281. ofs.Write("# Rcc executable\n");
  1282. ofs.Write("ARCC_RCC_EXECUTABLE", this->Rcc.Executable);
  1283. ofs.WriteStrings("ARCC_RCC_LIST_OPTIONS",
  1284. this->Rcc.ExecutableFeatures->ListOptions);
  1285. ofs.Write("# Rcc job\n");
  1286. ofs.Write("ARCC_LOCK_FILE", qrc.LockFile);
  1287. ofs.Write("ARCC_SOURCE", qrc.QrcFile);
  1288. ofs.Write("ARCC_OUTPUT_CHECKSUM", qrc.PathChecksum);
  1289. ofs.Write("ARCC_OUTPUT_NAME",
  1290. cmSystemTools::GetFilenameName(qrc.RccFile));
  1291. ofs.WriteStrings("ARCC_OPTIONS", qrc.Options);
  1292. ofs.WriteStrings("ARCC_INPUTS", qrc.Resources);
  1293. } else {
  1294. cmSystemTools::Error(
  1295. cmStrCat("AutoRcc: Could not write file ", qrc.InfoFile));
  1296. return false;
  1297. }
  1298. }
  1299. return true;
  1300. }
  1301. void cmQtAutoGenInitializer::RegisterGeneratedSource(
  1302. std::string const& filename)
  1303. {
  1304. cmMakefile* makefile = this->Target->Target->GetMakefile();
  1305. cmSourceFile* gFile = makefile->GetOrCreateSource(filename, true);
  1306. gFile->SetProperty("GENERATED", "1");
  1307. gFile->SetProperty("SKIP_AUTOGEN", "1");
  1308. }
  1309. bool cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename,
  1310. GenVarsT const& genVars,
  1311. bool prepend)
  1312. {
  1313. // Register source at makefile
  1314. this->RegisterGeneratedSource(filename);
  1315. // Add source file to target
  1316. this->Target->AddSource(filename, prepend);
  1317. // Add source file to source group
  1318. return this->AddToSourceGroup(filename, genVars.GenNameUpper);
  1319. }
  1320. bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
  1321. cm::string_view genNameUpper)
  1322. {
  1323. cmMakefile* makefile = this->Target->Target->GetMakefile();
  1324. cmSourceGroup* sourceGroup = nullptr;
  1325. // Acquire source group
  1326. {
  1327. std::string property;
  1328. std::string groupName;
  1329. {
  1330. // Prefer generator specific source group name
  1331. std::initializer_list<std::string> const props{
  1332. cmStrCat(genNameUpper, "_SOURCE_GROUP"), "AUTOGEN_SOURCE_GROUP"
  1333. };
  1334. for (std::string const& prop : props) {
  1335. const char* propName = makefile->GetState()->GetGlobalProperty(prop);
  1336. if ((propName != nullptr) && (*propName != '\0')) {
  1337. groupName = propName;
  1338. property = prop;
  1339. break;
  1340. }
  1341. }
  1342. }
  1343. // Generate a source group on demand
  1344. if (!groupName.empty()) {
  1345. sourceGroup = makefile->GetOrCreateSourceGroup(groupName);
  1346. if (sourceGroup == nullptr) {
  1347. cmSystemTools::Error(
  1348. cmStrCat(genNameUpper, " error in ", property,
  1349. ": Could not find or create the source group ",
  1350. cmQtAutoGen::Quoted(groupName)));
  1351. return false;
  1352. }
  1353. }
  1354. }
  1355. if (sourceGroup != nullptr) {
  1356. sourceGroup->AddGroupFile(fileName);
  1357. }
  1358. return true;
  1359. }
  1360. void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName)
  1361. {
  1362. Target->Target->AppendProperty("ADDITIONAL_CLEAN_FILES", fileName.c_str(),
  1363. false);
  1364. }
  1365. static unsigned int CharPtrToUInt(const char* const input)
  1366. {
  1367. unsigned long tmp = 0;
  1368. if (input != nullptr && cmStrToULong(input, &tmp)) {
  1369. return static_cast<unsigned int>(tmp);
  1370. }
  1371. return 0;
  1372. }
  1373. static std::vector<cmQtAutoGen::IntegerVersion> GetKnownQtVersions(
  1374. cmGeneratorTarget const* target)
  1375. {
  1376. // Qt version variable prefixes
  1377. static std::initializer_list<
  1378. std::pair<cm::string_view, cm::string_view>> const keys{
  1379. { "Qt6Core_VERSION_MAJOR", "Qt6Core_VERSION_MINOR" },
  1380. { "Qt5Core_VERSION_MAJOR", "Qt5Core_VERSION_MINOR" },
  1381. { "QT_VERSION_MAJOR", "QT_VERSION_MINOR" },
  1382. };
  1383. std::vector<cmQtAutoGen::IntegerVersion> result;
  1384. result.reserve(keys.size() * 2);
  1385. // Adds a version to the result (nullptr safe)
  1386. auto addVersion = [&result](const char* major, const char* minor) {
  1387. cmQtAutoGen::IntegerVersion ver(CharPtrToUInt(major),
  1388. CharPtrToUInt(minor));
  1389. if (ver.Major != 0) {
  1390. result.emplace_back(ver);
  1391. }
  1392. };
  1393. cmMakefile* makefile = target->Target->GetMakefile();
  1394. // Read versions from variables
  1395. for (auto const& keyPair : keys) {
  1396. addVersion(makefile->GetDefinition(std::string(keyPair.first)),
  1397. makefile->GetDefinition(std::string(keyPair.second)));
  1398. }
  1399. // Read versions from directory properties
  1400. for (auto const& keyPair : keys) {
  1401. addVersion(makefile->GetProperty(std::string(keyPair.first)),
  1402. makefile->GetProperty(std::string(keyPair.second)));
  1403. }
  1404. return result;
  1405. }
  1406. std::pair<cmQtAutoGen::IntegerVersion, unsigned int>
  1407. cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target)
  1408. {
  1409. std::pair<IntegerVersion, unsigned int> res(
  1410. IntegerVersion(),
  1411. CharPtrToUInt(target->GetLinkInterfaceDependentStringProperty(
  1412. "QT_MAJOR_VERSION", "")));
  1413. auto knownQtVersions = GetKnownQtVersions(target);
  1414. if (!knownQtVersions.empty()) {
  1415. if (res.second == 0) {
  1416. // No specific version was requested by the target:
  1417. // Use highest known Qt version.
  1418. res.first = knownQtVersions.at(0);
  1419. } else {
  1420. // Pick a version from the known versions:
  1421. for (auto it : knownQtVersions) {
  1422. if (it.Major == res.second) {
  1423. res.first = it;
  1424. break;
  1425. }
  1426. }
  1427. }
  1428. }
  1429. return res;
  1430. }
  1431. bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
  1432. const std::string& executable,
  1433. bool ignoreMissingTarget) const
  1434. {
  1435. auto print_err = [this, &genVars](std::string const& err) {
  1436. cmSystemTools::Error(cmStrCat(genVars.GenNameUpper, " for target ",
  1437. this->Target->GetName(), ": ", err));
  1438. };
  1439. // Custom executable
  1440. {
  1441. std::string const prop = cmStrCat(genVars.GenNameUpper, "_EXECUTABLE");
  1442. std::string const val = this->Target->Target->GetSafeProperty(prop);
  1443. if (!val.empty()) {
  1444. // Evaluate generator expression
  1445. {
  1446. cmListFileBacktrace lfbt =
  1447. this->Target->Target->GetMakefile()->GetBacktrace();
  1448. cmGeneratorExpression ge(lfbt);
  1449. std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(val);
  1450. genVars.Executable =
  1451. cge->Evaluate(this->Target->GetLocalGenerator(), "");
  1452. }
  1453. if (genVars.Executable.empty() && !ignoreMissingTarget) {
  1454. print_err(prop + " evaluates to an empty value");
  1455. return false;
  1456. }
  1457. // Create empty compiler features.
  1458. genVars.ExecutableFeatures =
  1459. std::make_shared<cmQtAutoGen::CompilerFeatures>();
  1460. return true;
  1461. }
  1462. }
  1463. // Find executable target
  1464. {
  1465. // Find executable target name
  1466. cm::string_view prefix;
  1467. if (this->QtVersion.Major == 4) {
  1468. prefix = "Qt4::";
  1469. } else if (this->QtVersion.Major == 5) {
  1470. prefix = "Qt5::";
  1471. } else if (this->QtVersion.Major == 6) {
  1472. prefix = "Qt6::";
  1473. }
  1474. std::string const targetName = cmStrCat(prefix, executable);
  1475. // Find target
  1476. cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
  1477. cmGeneratorTarget* target = localGen->FindGeneratorTargetToUse(targetName);
  1478. if (target != nullptr) {
  1479. genVars.ExecutableTargetName = targetName;
  1480. genVars.ExecutableTarget = target;
  1481. if (target->IsImported()) {
  1482. genVars.Executable = target->ImportedGetLocation("");
  1483. } else {
  1484. genVars.Executable = target->GetLocation("");
  1485. }
  1486. } else {
  1487. if (ignoreMissingTarget) {
  1488. // Create empty compiler features.
  1489. genVars.ExecutableFeatures =
  1490. std::make_shared<cmQtAutoGen::CompilerFeatures>();
  1491. return true;
  1492. }
  1493. print_err(cmStrCat("Could not find ", executable, " executable target ",
  1494. targetName));
  1495. return false;
  1496. }
  1497. }
  1498. // Get executable features
  1499. {
  1500. std::string err;
  1501. genVars.ExecutableFeatures = this->GlobalInitializer->GetCompilerFeatures(
  1502. executable, genVars.Executable, err);
  1503. if (!genVars.ExecutableFeatures) {
  1504. print_err(err);
  1505. return false;
  1506. }
  1507. }
  1508. return true;
  1509. }