cmQtAutoGeneratorInitializer.cxx 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096
  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 "cmQtAutoGeneratorInitializer.h"
  4. #include "cmQtAutoGeneratorCommon.h"
  5. #include "cmAlgorithms.h"
  6. #include "cmCustomCommandLines.h"
  7. #include "cmFilePathChecksum.h"
  8. #include "cmGeneratorTarget.h"
  9. #include "cmGlobalGenerator.h"
  10. #include "cmLocalGenerator.h"
  11. #include "cmMakefile.h"
  12. #include "cmOutputConverter.h"
  13. #include "cmSourceFile.h"
  14. #include "cmSourceGroup.h"
  15. #include "cmState.h"
  16. #include "cmSystemTools.h"
  17. #include "cmTarget.h"
  18. #include "cm_sys_stat.h"
  19. #include "cmake.h"
  20. #if defined(_WIN32) && !defined(__CYGWIN__)
  21. #include "cmGlobalVisualStudioGenerator.h"
  22. #endif
  23. #include "cmConfigure.h"
  24. #include "cmsys/FStream.hxx"
  25. #include <algorithm>
  26. #include <map>
  27. #include <set>
  28. #include <string>
  29. #include <utility>
  30. #include <vector>
  31. static void utilCopyTargetProperty(cmTarget* destinationTarget,
  32. cmTarget* sourceTarget,
  33. const std::string& propertyName)
  34. {
  35. const char* propertyValue = sourceTarget->GetProperty(propertyName);
  36. if (propertyValue) {
  37. destinationTarget->SetProperty(propertyName, propertyValue);
  38. }
  39. }
  40. inline static bool PropertyEnabled(cmSourceFile* sourceFile, const char* key)
  41. {
  42. return cmSystemTools::IsOn(sourceFile->GetPropertyForUser(key));
  43. }
  44. static std::string GetSafeProperty(cmGeneratorTarget const* target,
  45. const char* key)
  46. {
  47. const char* tmp = target->GetProperty(key);
  48. return std::string((tmp != CM_NULLPTR) ? tmp : "");
  49. }
  50. static std::string GetAutogenTargetName(cmGeneratorTarget const* target)
  51. {
  52. std::string autogenTargetName = target->GetName();
  53. autogenTargetName += "_autogen";
  54. return autogenTargetName;
  55. }
  56. static std::string GetAutogenTargetFilesDir(cmGeneratorTarget const* target)
  57. {
  58. cmMakefile* makefile = target->Target->GetMakefile();
  59. std::string targetDir = makefile->GetCurrentBinaryDirectory();
  60. targetDir += makefile->GetCMakeInstance()->GetCMakeFilesDirectory();
  61. targetDir += "/";
  62. targetDir += GetAutogenTargetName(target);
  63. targetDir += ".dir";
  64. return targetDir;
  65. }
  66. static std::string GetAutogenTargetBuildDir(cmGeneratorTarget const* target)
  67. {
  68. std::string targetDir = GetSafeProperty(target, "AUTOGEN_BUILD_DIR");
  69. if (targetDir.empty()) {
  70. cmMakefile* makefile = target->Target->GetMakefile();
  71. targetDir = makefile->GetCurrentBinaryDirectory();
  72. targetDir += "/";
  73. targetDir += GetAutogenTargetName(target);
  74. }
  75. return targetDir;
  76. }
  77. static std::string GetQtMajorVersion(cmGeneratorTarget const* target)
  78. {
  79. cmMakefile* makefile = target->Target->GetMakefile();
  80. std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
  81. if (qtMajorVersion.empty()) {
  82. qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
  83. }
  84. const char* targetQtVersion =
  85. target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "");
  86. if (targetQtVersion != CM_NULLPTR) {
  87. qtMajorVersion = targetQtVersion;
  88. }
  89. return qtMajorVersion;
  90. }
  91. static std::string GetQtMinorVersion(cmGeneratorTarget const* target,
  92. const std::string& qtMajorVersion)
  93. {
  94. cmMakefile* makefile = target->Target->GetMakefile();
  95. std::string qtMinorVersion;
  96. if (qtMajorVersion == "5") {
  97. qtMinorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MINOR");
  98. }
  99. if (qtMinorVersion.empty()) {
  100. qtMinorVersion = makefile->GetSafeDefinition("QT_VERSION_MINOR");
  101. }
  102. const char* targetQtVersion =
  103. target->GetLinkInterfaceDependentStringProperty("QT_MINOR_VERSION", "");
  104. if (targetQtVersion != CM_NULLPTR) {
  105. qtMinorVersion = targetQtVersion;
  106. }
  107. return qtMinorVersion;
  108. }
  109. static bool QtVersionGreaterOrEqual(const std::string& major,
  110. const std::string& minor,
  111. unsigned long requestMajor,
  112. unsigned long requestMinor)
  113. {
  114. unsigned long majorUL(0);
  115. unsigned long minorUL(0);
  116. if (cmSystemTools::StringToULong(major.c_str(), &majorUL) &&
  117. cmSystemTools::StringToULong(minor.c_str(), &minorUL)) {
  118. return (majorUL > requestMajor) ||
  119. (majorUL == requestMajor && minorUL >= requestMinor);
  120. }
  121. return false;
  122. }
  123. static void GetCompileDefinitionsAndDirectories(
  124. cmGeneratorTarget const* target, const std::string& config,
  125. std::string& incs, std::string& defs)
  126. {
  127. cmLocalGenerator* localGen = target->GetLocalGenerator();
  128. {
  129. std::vector<std::string> includeDirs;
  130. // Get the include dirs for this target, without stripping the implicit
  131. // include dirs off, see
  132. // https://gitlab.kitware.com/cmake/cmake/issues/13667
  133. localGen->GetIncludeDirectories(includeDirs, target, "CXX", config, false);
  134. incs = cmJoin(includeDirs, ";");
  135. }
  136. {
  137. std::set<std::string> defines;
  138. localGen->AddCompileDefinitions(defines, target, config, "CXX");
  139. defs += cmJoin(defines, ";");
  140. }
  141. }
  142. static bool IsMultiConfig(cmGlobalGenerator* globalGen)
  143. {
  144. // FIXME: Xcode does not support per-config sources, yet.
  145. // (EXCLUDED_SOURCE_FILE_NAMES)
  146. // Treat it as a single configuration generator meanwhile.
  147. if (globalGen->GetName().find("Xcode") != std::string::npos) {
  148. return false;
  149. }
  150. // FIXME: Visual Studio does not fully support per-config sources yet.
  151. if (globalGen->GetName().find("Visual Studio") != std::string::npos) {
  152. return false;
  153. }
  154. return globalGen->IsMultiConfig();
  155. }
  156. static std::vector<std::string> GetConfigurations(
  157. cmMakefile* makefile, std::string* config = CM_NULLPTR)
  158. {
  159. std::vector<std::string> configs;
  160. {
  161. std::string cfg = makefile->GetConfigurations(configs);
  162. if (config != CM_NULLPTR) {
  163. *config = cfg;
  164. }
  165. }
  166. // Add empty configuration on demand
  167. if (configs.empty()) {
  168. configs.push_back("");
  169. }
  170. return configs;
  171. }
  172. static std::vector<std::string> GetConfigurationSuffixes(cmMakefile* makefile)
  173. {
  174. std::vector<std::string> suffixes;
  175. if (IsMultiConfig(makefile->GetGlobalGenerator())) {
  176. makefile->GetConfigurations(suffixes);
  177. for (std::vector<std::string>::iterator it = suffixes.begin();
  178. it != suffixes.end(); ++it) {
  179. it->insert(0, "_");
  180. }
  181. }
  182. if (suffixes.empty()) {
  183. suffixes.push_back("");
  184. }
  185. return suffixes;
  186. }
  187. static void AddDefinitionEscaped(cmMakefile* makefile, const char* key,
  188. const std::string& value)
  189. {
  190. makefile->AddDefinition(key,
  191. cmOutputConverter::EscapeForCMake(value).c_str());
  192. }
  193. static void AddDefinitionEscaped(cmMakefile* makefile, const char* key,
  194. const std::vector<std::string>& values)
  195. {
  196. makefile->AddDefinition(
  197. key, cmOutputConverter::EscapeForCMake(cmJoin(values, ";")).c_str());
  198. }
  199. static bool AddToSourceGroup(cmMakefile* makefile, const std::string& fileName,
  200. cmQtAutoGeneratorCommon::GeneratorType genType)
  201. {
  202. cmSourceGroup* sourceGroup = CM_NULLPTR;
  203. // Acquire source group
  204. {
  205. const char* groupName = CM_NULLPTR;
  206. // Use generator specific group name
  207. switch (genType) {
  208. case cmQtAutoGeneratorCommon::MOC:
  209. groupName =
  210. makefile->GetState()->GetGlobalProperty("AUTOMOC_SOURCE_GROUP");
  211. break;
  212. case cmQtAutoGeneratorCommon::RCC:
  213. groupName =
  214. makefile->GetState()->GetGlobalProperty("AUTORCC_SOURCE_GROUP");
  215. break;
  216. default:
  217. break;
  218. }
  219. // Use default group name on demand
  220. if ((groupName == CM_NULLPTR) || (*groupName == 0)) {
  221. groupName =
  222. makefile->GetState()->GetGlobalProperty("AUTOGEN_SOURCE_GROUP");
  223. }
  224. // Generate a source group on demand
  225. if ((groupName != CM_NULLPTR) && (*groupName != 0)) {
  226. {
  227. const char* delimiter =
  228. makefile->GetDefinition("SOURCE_GROUP_DELIMITER");
  229. if (delimiter == CM_NULLPTR) {
  230. delimiter = "\\";
  231. }
  232. std::vector<std::string> folders =
  233. cmSystemTools::tokenize(groupName, delimiter);
  234. sourceGroup = makefile->GetSourceGroup(folders);
  235. if (sourceGroup == CM_NULLPTR) {
  236. makefile->AddSourceGroup(folders);
  237. sourceGroup = makefile->GetSourceGroup(folders);
  238. }
  239. }
  240. if (sourceGroup == CM_NULLPTR) {
  241. cmSystemTools::Error(
  242. "Autogen: Could not create or find source group: ",
  243. cmQtAutoGeneratorCommon::Quoted(groupName).c_str());
  244. return false;
  245. }
  246. }
  247. }
  248. if (sourceGroup != CM_NULLPTR) {
  249. sourceGroup->AddGroupFile(fileName);
  250. }
  251. return true;
  252. }
  253. static void AddGeneratedSource(cmMakefile* makefile,
  254. const std::string& filename,
  255. cmQtAutoGeneratorCommon::GeneratorType genType)
  256. {
  257. cmSourceFile* gFile = makefile->GetOrCreateSource(filename, true);
  258. gFile->SetProperty("GENERATED", "1");
  259. gFile->SetProperty("SKIP_AUTOGEN", "On");
  260. AddToSourceGroup(makefile, filename, genType);
  261. }
  262. static void AcquireScanFiles(cmGeneratorTarget const* target,
  263. std::vector<std::string>& mocUicSources,
  264. std::vector<std::string>& mocUicHeaders,
  265. std::vector<std::string>& mocSkipList,
  266. std::vector<std::string>& uicSkipList)
  267. {
  268. const bool mocTarget = target->GetPropertyAsBool("AUTOMOC");
  269. const bool uicTarget = target->GetPropertyAsBool("AUTOUIC");
  270. std::vector<cmSourceFile*> srcFiles;
  271. target->GetConfigCommonSourceFiles(srcFiles);
  272. for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
  273. fileIt != srcFiles.end(); ++fileIt) {
  274. cmSourceFile* sf = *fileIt;
  275. const cmSystemTools::FileFormat fileType =
  276. cmSystemTools::GetFileFormat(sf->GetExtension().c_str());
  277. if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) &&
  278. !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
  279. continue;
  280. }
  281. if (PropertyEnabled(sf, "GENERATED") &&
  282. !target->GetPropertyAsBool("__UNDOCUMENTED_AUTOGEN_GENERATED_FILES")) {
  283. // FIXME: Add a policy whose NEW behavior allows generated files.
  284. // The implementation already works. We disable it here to avoid
  285. // changing behavior for existing projects that do not expect it.
  286. continue;
  287. }
  288. const std::string absFile =
  289. cmsys::SystemTools::GetRealPath(sf->GetFullPath());
  290. // Skip flags
  291. const bool skipAll = PropertyEnabled(sf, "SKIP_AUTOGEN");
  292. const bool mocSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOMOC");
  293. const bool uicSkip = skipAll || PropertyEnabled(sf, "SKIP_AUTOUIC");
  294. // Add file name to skip lists.
  295. // Do this even when the file is not added to the sources/headers lists
  296. // because the file name may be extracted from an other file when
  297. // processing
  298. if (mocSkip) {
  299. mocSkipList.push_back(absFile);
  300. }
  301. if (uicSkip) {
  302. uicSkipList.push_back(absFile);
  303. }
  304. if ((mocTarget && !mocSkip) || (uicTarget && !uicSkip)) {
  305. // Add file name to sources or headers list
  306. switch (fileType) {
  307. case cmSystemTools::CXX_FILE_FORMAT:
  308. mocUicSources.push_back(absFile);
  309. break;
  310. case cmSystemTools::HEADER_FILE_FORMAT:
  311. mocUicHeaders.push_back(absFile);
  312. break;
  313. default:
  314. break;
  315. }
  316. }
  317. }
  318. }
  319. static void MocSetupAutoTarget(
  320. cmGeneratorTarget const* target, const std::string& autogenTargetName,
  321. std::string const& qtMajorVersion, std::string const& config,
  322. std::vector<std::string> const& configs,
  323. std::vector<std::string> const& mocSkipList,
  324. std::map<std::string, std::string>& configMocIncludes,
  325. std::map<std::string, std::string>& configMocDefines)
  326. {
  327. cmLocalGenerator* lg = target->GetLocalGenerator();
  328. cmMakefile* makefile = target->Target->GetMakefile();
  329. AddDefinitionEscaped(makefile, "_moc_options",
  330. GetSafeProperty(target, "AUTOMOC_MOC_OPTIONS"));
  331. AddDefinitionEscaped(makefile, "_moc_skip", mocSkipList);
  332. AddDefinitionEscaped(makefile, "_moc_relaxed_mode",
  333. makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE") ? "TRUE"
  334. : "FALSE");
  335. AddDefinitionEscaped(makefile, "_moc_depend_filters",
  336. GetSafeProperty(target, "AUTOMOC_DEPEND_FILTERS"));
  337. if (QtVersionGreaterOrEqual(
  338. qtMajorVersion, GetQtMinorVersion(target, qtMajorVersion), 5, 8)) {
  339. AddDefinitionEscaped(
  340. makefile, "_moc_predefs_cmd",
  341. makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND"));
  342. }
  343. // Moc includes and compile definitions
  344. {
  345. // Default settings
  346. std::string incs;
  347. std::string compileDefs;
  348. GetCompileDefinitionsAndDirectories(target, config, incs, compileDefs);
  349. AddDefinitionEscaped(makefile, "_moc_incs", incs);
  350. AddDefinitionEscaped(makefile, "_moc_compile_defs", compileDefs);
  351. // Configuration specific settings
  352. for (std::vector<std::string>::const_iterator li = configs.begin();
  353. li != configs.end(); ++li) {
  354. std::string configIncs;
  355. std::string configCompileDefs;
  356. GetCompileDefinitionsAndDirectories(target, *li, configIncs,
  357. configCompileDefs);
  358. if (configIncs != incs) {
  359. configMocIncludes[*li] = cmOutputConverter::EscapeForCMake(configIncs);
  360. }
  361. if (configCompileDefs != compileDefs) {
  362. configMocDefines[*li] =
  363. cmOutputConverter::EscapeForCMake(configCompileDefs);
  364. }
  365. }
  366. }
  367. // Moc executable
  368. {
  369. std::string err;
  370. const char* mocExec = CM_NULLPTR;
  371. if (qtMajorVersion == "5") {
  372. cmGeneratorTarget* qt5Moc = lg->FindGeneratorTargetToUse("Qt5::moc");
  373. if (qt5Moc != CM_NULLPTR) {
  374. mocExec = qt5Moc->ImportedGetLocation("");
  375. } else {
  376. err = "Qt5::moc target not found " + autogenTargetName;
  377. }
  378. } else if (qtMajorVersion == "4") {
  379. cmGeneratorTarget* qt4Moc = lg->FindGeneratorTargetToUse("Qt4::moc");
  380. if (qt4Moc != CM_NULLPTR) {
  381. mocExec = qt4Moc->ImportedGetLocation("");
  382. } else {
  383. err = "Qt4::moc target not found " + autogenTargetName;
  384. }
  385. } else {
  386. err = "The CMAKE_AUTOMOC feature supports only Qt 4 and Qt 5 ";
  387. err += autogenTargetName;
  388. }
  389. // Add definition or error
  390. if (err.empty()) {
  391. AddDefinitionEscaped(makefile, "_qt_moc_executable",
  392. mocExec ? mocExec : "");
  393. } else {
  394. cmSystemTools::Error(err.c_str());
  395. }
  396. }
  397. }
  398. static void UicGetOpts(cmGeneratorTarget const* target,
  399. const std::string& config, std::string& optString)
  400. {
  401. std::vector<std::string> opts;
  402. target->GetAutoUicOptions(opts, config);
  403. optString = cmJoin(opts, ";");
  404. }
  405. static void UicSetupAutoTarget(
  406. cmGeneratorTarget const* target, std::string const& qtMajorVersion,
  407. std::string const& config, std::vector<std::string> const& configs,
  408. std::vector<std::string> const& uicSkipList,
  409. std::map<std::string, std::string>& configUicOptions)
  410. {
  411. cmLocalGenerator* lg = target->GetLocalGenerator();
  412. cmMakefile* makefile = target->Target->GetMakefile();
  413. AddDefinitionEscaped(makefile, "_uic_skip", uicSkipList);
  414. // Uic search paths
  415. {
  416. std::vector<std::string> uicSearchPaths;
  417. cmSystemTools::ExpandListArgument(
  418. GetSafeProperty(target, "AUTOUIC_SEARCH_PATHS"), uicSearchPaths);
  419. const std::string srcDir = makefile->GetCurrentSourceDirectory();
  420. for (std::vector<std::string>::iterator it = uicSearchPaths.begin();
  421. it != uicSearchPaths.end(); ++it) {
  422. *it = cmSystemTools::CollapseFullPath(*it, srcDir);
  423. }
  424. AddDefinitionEscaped(makefile, "_uic_search_paths", uicSearchPaths);
  425. }
  426. // Uic target options
  427. {
  428. // Default settings
  429. std::string uicOpts;
  430. UicGetOpts(target, config, uicOpts);
  431. AddDefinitionEscaped(makefile, "_uic_target_options", uicOpts);
  432. // Configuration specific settings
  433. for (std::vector<std::string>::const_iterator li = configs.begin();
  434. li != configs.end(); ++li) {
  435. std::string configUicOpts;
  436. UicGetOpts(target, *li, configUicOpts);
  437. if (configUicOpts != uicOpts) {
  438. configUicOptions[*li] =
  439. cmOutputConverter::EscapeForCMake(configUicOpts);
  440. }
  441. }
  442. }
  443. // Uic files options
  444. {
  445. std::vector<std::string> uiFileFiles;
  446. std::vector<std::string> uiFileOptions;
  447. {
  448. std::set<std::string> skipped;
  449. skipped.insert(uicSkipList.begin(), uicSkipList.end());
  450. const std::vector<cmSourceFile*> uiFilesWithOptions =
  451. makefile->GetQtUiFilesWithOptions();
  452. for (std::vector<cmSourceFile*>::const_iterator fileIt =
  453. uiFilesWithOptions.begin();
  454. fileIt != uiFilesWithOptions.end(); ++fileIt) {
  455. cmSourceFile* sf = *fileIt;
  456. const std::string absFile =
  457. cmsys::SystemTools::GetRealPath(sf->GetFullPath());
  458. if (skipped.insert(absFile).second) {
  459. // The file wasn't skipped
  460. uiFileFiles.push_back(absFile);
  461. {
  462. std::string opts = sf->GetProperty("AUTOUIC_OPTIONS");
  463. cmSystemTools::ReplaceString(opts, ";",
  464. cmQtAutoGeneratorCommon::listSep);
  465. uiFileOptions.push_back(opts);
  466. }
  467. }
  468. }
  469. }
  470. AddDefinitionEscaped(makefile, "_qt_uic_options_files", uiFileFiles);
  471. AddDefinitionEscaped(makefile, "_qt_uic_options_options", uiFileOptions);
  472. }
  473. // Uic executable
  474. {
  475. std::string err;
  476. const char* uicExec = CM_NULLPTR;
  477. if (qtMajorVersion == "5") {
  478. cmGeneratorTarget* qt5Uic = lg->FindGeneratorTargetToUse("Qt5::uic");
  479. if (qt5Uic != CM_NULLPTR) {
  480. uicExec = qt5Uic->ImportedGetLocation("");
  481. } else {
  482. // Project does not use Qt5Widgets, but has AUTOUIC ON anyway
  483. }
  484. } else if (qtMajorVersion == "4") {
  485. cmGeneratorTarget* qt4Uic = lg->FindGeneratorTargetToUse("Qt4::uic");
  486. if (qt4Uic != CM_NULLPTR) {
  487. uicExec = qt4Uic->ImportedGetLocation("");
  488. } else {
  489. err = "Qt4::uic target not found " + target->GetName();
  490. }
  491. } else {
  492. err = "The CMAKE_AUTOUIC feature supports only Qt 4 and Qt 5 ";
  493. err += target->GetName();
  494. }
  495. // Add definition or error
  496. if (err.empty()) {
  497. AddDefinitionEscaped(makefile, "_qt_uic_executable",
  498. uicExec ? uicExec : "");
  499. } else {
  500. cmSystemTools::Error(err.c_str());
  501. }
  502. }
  503. }
  504. static std::string RccGetExecutable(cmGeneratorTarget const* target,
  505. const std::string& qtMajorVersion)
  506. {
  507. std::string rccExec;
  508. cmLocalGenerator* lg = target->GetLocalGenerator();
  509. if (qtMajorVersion == "5") {
  510. cmGeneratorTarget* qt5Rcc = lg->FindGeneratorTargetToUse("Qt5::rcc");
  511. if (qt5Rcc != CM_NULLPTR) {
  512. rccExec = qt5Rcc->ImportedGetLocation("");
  513. } else {
  514. cmSystemTools::Error("Qt5::rcc target not found ",
  515. target->GetName().c_str());
  516. }
  517. } else if (qtMajorVersion == "4") {
  518. cmGeneratorTarget* qt4Rcc = lg->FindGeneratorTargetToUse("Qt4::rcc");
  519. if (qt4Rcc != CM_NULLPTR) {
  520. rccExec = qt4Rcc->ImportedGetLocation("");
  521. } else {
  522. cmSystemTools::Error("Qt4::rcc target not found ",
  523. target->GetName().c_str());
  524. }
  525. } else {
  526. cmSystemTools::Error(
  527. "The CMAKE_AUTORCC feature supports only Qt 4 and Qt 5 ",
  528. target->GetName().c_str());
  529. }
  530. return rccExec;
  531. }
  532. static void RccMergeOptions(std::vector<std::string>& opts,
  533. const std::vector<std::string>& fileOpts,
  534. bool isQt5)
  535. {
  536. static const char* valueOptions[] = { "name", "root", "compress",
  537. "threshold" };
  538. std::vector<std::string> extraOpts;
  539. for (std::vector<std::string>::const_iterator fit = fileOpts.begin();
  540. fit != fileOpts.end(); ++fit) {
  541. std::vector<std::string>::iterator existingIt =
  542. std::find(opts.begin(), opts.end(), *fit);
  543. if (existingIt != opts.end()) {
  544. const char* optName = fit->c_str();
  545. if (*optName == '-') {
  546. ++optName;
  547. if (isQt5 && *optName == '-') {
  548. ++optName;
  549. }
  550. }
  551. // Test if this is a value option and change the existing value
  552. if ((optName != fit->c_str()) &&
  553. std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions),
  554. cmStrCmp(optName)) != cmArrayEnd(valueOptions)) {
  555. const std::vector<std::string>::iterator existValueIt(existingIt + 1);
  556. const std::vector<std::string>::const_iterator fileValueIt(fit + 1);
  557. if ((existValueIt != opts.end()) && (fileValueIt != fileOpts.end())) {
  558. *existValueIt = *fileValueIt;
  559. ++fit;
  560. }
  561. }
  562. } else {
  563. extraOpts.push_back(*fit);
  564. }
  565. }
  566. opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
  567. }
  568. static void RccSetupAutoTarget(cmGeneratorTarget const* target,
  569. const std::string& qtMajorVersion)
  570. {
  571. cmMakefile* makefile = target->Target->GetMakefile();
  572. const bool qtMajorVersion5 = (qtMajorVersion == "5");
  573. const std::string rccCommand = RccGetExecutable(target, qtMajorVersion);
  574. std::vector<std::string> _rcc_files;
  575. std::vector<std::string> _rcc_inputs;
  576. std::vector<std::string> rccFileFiles;
  577. std::vector<std::string> rccFileOptions;
  578. std::vector<std::string> rccOptionsTarget;
  579. if (const char* opts = target->GetProperty("AUTORCC_OPTIONS")) {
  580. cmSystemTools::ExpandListArgument(opts, rccOptionsTarget);
  581. }
  582. std::vector<cmSourceFile*> srcFiles;
  583. target->GetConfigCommonSourceFiles(srcFiles);
  584. for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
  585. fileIt != srcFiles.end(); ++fileIt) {
  586. cmSourceFile* sf = *fileIt;
  587. if ((sf->GetExtension() == "qrc") &&
  588. !PropertyEnabled(sf, "SKIP_AUTOGEN") &&
  589. !PropertyEnabled(sf, "SKIP_AUTORCC")) {
  590. const std::string absFile =
  591. cmsys::SystemTools::GetRealPath(sf->GetFullPath());
  592. // qrc file
  593. _rcc_files.push_back(absFile);
  594. // qrc file entries
  595. {
  596. std::string entriesList = "{";
  597. // Read input file list only for non generated .qrc files.
  598. if (!PropertyEnabled(sf, "GENERATED")) {
  599. std::string error;
  600. std::vector<std::string> files;
  601. if (cmQtAutoGeneratorCommon::RccListInputs(
  602. qtMajorVersion, rccCommand, absFile, files, &error)) {
  603. entriesList += cmJoin(files, cmQtAutoGeneratorCommon::listSep);
  604. } else {
  605. cmSystemTools::Error(error.c_str());
  606. }
  607. }
  608. entriesList += "}";
  609. _rcc_inputs.push_back(entriesList);
  610. }
  611. // rcc options for this qrc file
  612. {
  613. // Merged target and file options
  614. std::vector<std::string> rccOptions(rccOptionsTarget);
  615. if (const char* prop = sf->GetProperty("AUTORCC_OPTIONS")) {
  616. std::vector<std::string> optsVec;
  617. cmSystemTools::ExpandListArgument(prop, optsVec);
  618. RccMergeOptions(rccOptions, optsVec, qtMajorVersion5);
  619. }
  620. // Only store non empty options lists
  621. if (!rccOptions.empty()) {
  622. rccFileFiles.push_back(absFile);
  623. rccFileOptions.push_back(
  624. cmJoin(rccOptions, cmQtAutoGeneratorCommon::listSep));
  625. }
  626. }
  627. }
  628. }
  629. AddDefinitionEscaped(makefile, "_qt_rcc_executable", rccCommand);
  630. AddDefinitionEscaped(makefile, "_rcc_files", _rcc_files);
  631. AddDefinitionEscaped(makefile, "_rcc_inputs", _rcc_inputs);
  632. AddDefinitionEscaped(makefile, "_rcc_options_files", rccFileFiles);
  633. AddDefinitionEscaped(makefile, "_rcc_options_options", rccFileOptions);
  634. }
  635. void cmQtAutoGeneratorInitializer::InitializeAutogenSources(
  636. cmGeneratorTarget* target)
  637. {
  638. if (target->GetPropertyAsBool("AUTOMOC")) {
  639. cmMakefile* makefile = target->Target->GetMakefile();
  640. const std::vector<std::string> suffixes =
  641. GetConfigurationSuffixes(makefile);
  642. // Get build directory
  643. const std::string autogenBuildDir = GetAutogenTargetBuildDir(target);
  644. // Register all compilation files as generated
  645. for (std::vector<std::string>::const_iterator it = suffixes.begin();
  646. it != suffixes.end(); ++it) {
  647. std::string mcFile = autogenBuildDir + "/mocs_compilation";
  648. mcFile += *it;
  649. mcFile += ".cpp";
  650. AddGeneratedSource(makefile, mcFile, cmQtAutoGeneratorCommon::MOC);
  651. }
  652. // Mocs compilation file
  653. if (IsMultiConfig(target->GetGlobalGenerator())) {
  654. target->AddSource(autogenBuildDir + "/mocs_compilation_$<CONFIG>.cpp");
  655. } else {
  656. target->AddSource(autogenBuildDir + "/mocs_compilation.cpp");
  657. }
  658. }
  659. }
  660. void cmQtAutoGeneratorInitializer::InitializeAutogenTarget(
  661. cmLocalGenerator* lg, cmGeneratorTarget* target)
  662. {
  663. cmMakefile* makefile = target->Target->GetMakefile();
  664. // Create a custom target for running generators at buildtime
  665. const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC");
  666. const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC");
  667. const bool rccEnabled = target->GetPropertyAsBool("AUTORCC");
  668. const bool multiConfig = IsMultiConfig(target->GetGlobalGenerator());
  669. const std::string autogenTargetName = GetAutogenTargetName(target);
  670. const std::string autogenBuildDir = GetAutogenTargetBuildDir(target);
  671. const std::string workingDirectory =
  672. cmSystemTools::CollapseFullPath("", makefile->GetCurrentBinaryDirectory());
  673. const std::string qtMajorVersion = GetQtMajorVersion(target);
  674. const std::string rccCommand = RccGetExecutable(target, qtMajorVersion);
  675. const std::vector<std::string> suffixes = GetConfigurationSuffixes(makefile);
  676. std::vector<std::string> autogenDepends;
  677. std::vector<std::string> autogenProvides;
  678. // Remove build directories on cleanup
  679. makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
  680. autogenBuildDir.c_str(), false);
  681. // Remove old settings on cleanup
  682. {
  683. std::string base = GetAutogenTargetFilesDir(target);
  684. for (std::vector<std::string>::const_iterator it = suffixes.begin();
  685. it != suffixes.end(); ++it) {
  686. std::string fname = base + "/AutogenOldSettings" + *it + ".cmake";
  687. makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES", fname.c_str(),
  688. false);
  689. }
  690. }
  691. // Compose command lines
  692. cmCustomCommandLines commandLines;
  693. {
  694. cmCustomCommandLine currentLine;
  695. currentLine.push_back(cmSystemTools::GetCMakeCommand());
  696. currentLine.push_back("-E");
  697. currentLine.push_back("cmake_autogen");
  698. currentLine.push_back(GetAutogenTargetFilesDir(target));
  699. currentLine.push_back("$<CONFIGURATION>");
  700. commandLines.push_back(currentLine);
  701. }
  702. // Compose target comment
  703. std::string autogenComment;
  704. {
  705. std::vector<std::string> toolNames;
  706. if (mocEnabled) {
  707. toolNames.push_back("MOC");
  708. }
  709. if (uicEnabled) {
  710. toolNames.push_back("UIC");
  711. }
  712. if (rccEnabled) {
  713. toolNames.push_back("RCC");
  714. }
  715. std::string tools = toolNames[0];
  716. toolNames.erase(toolNames.begin());
  717. while (toolNames.size() > 1) {
  718. tools += ", " + toolNames[0];
  719. toolNames.erase(toolNames.begin());
  720. }
  721. if (toolNames.size() == 1) {
  722. tools += " and " + toolNames[0];
  723. }
  724. autogenComment = "Automatic " + tools + " for target " + target->GetName();
  725. }
  726. // Add moc compilation to generated files list
  727. if (mocEnabled) {
  728. for (std::vector<std::string>::const_iterator it = suffixes.begin();
  729. it != suffixes.end(); ++it) {
  730. std::string mcFile = autogenBuildDir + "/mocs_compilation";
  731. mcFile += *it;
  732. mcFile += ".cpp";
  733. autogenProvides.push_back(mcFile);
  734. }
  735. }
  736. // Add autogen includes directory to the origin target INCLUDE_DIRECTORIES
  737. if (mocEnabled || uicEnabled) {
  738. if (multiConfig) {
  739. target->AddIncludeDirectory(autogenBuildDir + "/include_$<CONFIG>",
  740. true);
  741. } else {
  742. target->AddIncludeDirectory(autogenBuildDir + "/include", true);
  743. }
  744. }
  745. #if defined(_WIN32) && !defined(__CYGWIN__)
  746. bool usePRE_BUILD = false;
  747. cmGlobalGenerator* gg = lg->GetGlobalGenerator();
  748. if (gg->GetName().find("Visual Studio") != std::string::npos) {
  749. // Under VS use a PRE_BUILD event instead of a separate target to
  750. // reduce the number of targets loaded into the IDE.
  751. // This also works around a VS 11 bug that may skip updating the target:
  752. // https://connect.microsoft.com/VisualStudio/feedback/details/769495
  753. usePRE_BUILD = true;
  754. }
  755. #endif
  756. // Initialize autogen target dependencies
  757. if (const char* deps = target->GetProperty("AUTOGEN_TARGET_DEPENDS")) {
  758. cmSystemTools::ExpandListArgument(deps, autogenDepends);
  759. }
  760. // Add link library targets to the autogen dependencies
  761. {
  762. const cmTarget::LinkLibraryVectorType& libVec =
  763. target->Target->GetOriginalLinkLibraries();
  764. for (cmTarget::LinkLibraryVectorType::const_iterator it = libVec.begin();
  765. it != libVec.end(); ++it) {
  766. const std::string& libName = it->first;
  767. if (makefile->FindTargetToUse(libName) != CM_NULLPTR) {
  768. autogenDepends.push_back(libName);
  769. }
  770. }
  771. }
  772. {
  773. cmFilePathChecksum fpathCheckSum(makefile);
  774. // Iterate over all source files
  775. std::vector<cmSourceFile*> srcFiles;
  776. target->GetConfigCommonSourceFiles(srcFiles);
  777. for (std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
  778. fileIt != srcFiles.end(); ++fileIt) {
  779. cmSourceFile* sf = *fileIt;
  780. if (!PropertyEnabled(sf, "SKIP_AUTOGEN")) {
  781. std::string const& ext = sf->GetExtension();
  782. // Add generated file that will be scanned by moc or uic to
  783. // the dependencies
  784. if (mocEnabled || uicEnabled) {
  785. const cmSystemTools::FileFormat fileType =
  786. cmSystemTools::GetFileFormat(ext.c_str());
  787. if ((fileType == cmSystemTools::CXX_FILE_FORMAT) ||
  788. (fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
  789. if (PropertyEnabled(sf, "GENERATED")) {
  790. if ((mocEnabled && !PropertyEnabled(sf, "SKIP_AUTOMOC")) ||
  791. (uicEnabled && !PropertyEnabled(sf, "SKIP_AUTOUIC"))) {
  792. autogenDepends.push_back(
  793. cmsys::SystemTools::GetRealPath(sf->GetFullPath()));
  794. #if defined(_WIN32) && !defined(__CYGWIN__)
  795. // Cannot use PRE_BUILD with generated files
  796. usePRE_BUILD = false;
  797. #endif
  798. }
  799. }
  800. }
  801. }
  802. // Process rcc enabled files
  803. if (rccEnabled && (ext == "qrc") &&
  804. !PropertyEnabled(sf, "SKIP_AUTORCC")) {
  805. const std::string absFile =
  806. cmsys::SystemTools::GetRealPath(sf->GetFullPath());
  807. // Compose rcc output file name
  808. {
  809. std::string rccOutBase = autogenBuildDir + "/";
  810. rccOutBase += fpathCheckSum.getPart(absFile);
  811. rccOutBase += "/qrc_";
  812. rccOutBase +=
  813. cmsys::SystemTools::GetFilenameWithoutLastExtension(absFile);
  814. // Register rcc ouput file as generated
  815. for (std::vector<std::string>::const_iterator it =
  816. suffixes.begin();
  817. it != suffixes.end(); ++it) {
  818. std::string rccOutCfg = rccOutBase;
  819. rccOutCfg += *it;
  820. rccOutCfg += ".cpp";
  821. AddGeneratedSource(makefile, rccOutCfg,
  822. cmQtAutoGeneratorCommon::RCC);
  823. autogenProvides.push_back(rccOutCfg);
  824. }
  825. // Add rcc output file to origin target sources
  826. if (multiConfig) {
  827. target->AddSource(rccOutBase + "_$<CONFIG>.cpp");
  828. } else {
  829. target->AddSource(rccOutBase + ".cpp");
  830. }
  831. }
  832. if (PropertyEnabled(sf, "GENERATED")) {
  833. // Add generated qrc file to the dependencies
  834. autogenDepends.push_back(absFile);
  835. } else {
  836. // Run cmake again when .qrc file changes
  837. makefile->AddCMakeDependFile(absFile);
  838. // Add the qrc input files to the dependencies
  839. std::string error;
  840. if (!cmQtAutoGeneratorCommon::RccListInputs(
  841. qtMajorVersion, rccCommand, absFile, autogenDepends,
  842. &error)) {
  843. cmSystemTools::Error(error.c_str());
  844. }
  845. }
  846. #if defined(_WIN32) && !defined(__CYGWIN__)
  847. // Cannot use PRE_BUILD because the resource files themselves
  848. // may not be sources within the target so VS may not know the
  849. // target needs to re-build at all.
  850. usePRE_BUILD = false;
  851. #endif
  852. }
  853. }
  854. }
  855. }
  856. #if defined(_WIN32) && !defined(__CYGWIN__)
  857. if (usePRE_BUILD) {
  858. // If the autogen target depends on an other target don't use PRE_BUILD
  859. for (std::vector<std::string>::iterator it = autogenDepends.begin();
  860. it != autogenDepends.end(); ++it) {
  861. if (makefile->FindTargetToUse(*it) != CM_NULLPTR) {
  862. usePRE_BUILD = false;
  863. break;
  864. }
  865. }
  866. }
  867. if (usePRE_BUILD) {
  868. // Add the pre-build command directly to bypass the OBJECT_LIBRARY
  869. // rejection in cmMakefile::AddCustomCommandToTarget because we know
  870. // PRE_BUILD will work for an OBJECT_LIBRARY in this specific case.
  871. std::vector<std::string> no_output;
  872. cmCustomCommand cc(makefile, no_output, autogenProvides, autogenDepends,
  873. commandLines, autogenComment.c_str(),
  874. workingDirectory.c_str());
  875. cc.SetEscapeOldStyle(false);
  876. cc.SetEscapeAllowMakeVars(true);
  877. target->Target->AddPreBuildCommand(cc);
  878. } else
  879. #endif
  880. {
  881. cmTarget* autogenTarget = makefile->AddUtilityCommand(
  882. autogenTargetName, true, workingDirectory.c_str(),
  883. /*byproducts=*/autogenProvides, autogenDepends, commandLines, false,
  884. autogenComment.c_str());
  885. cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg);
  886. lg->AddGeneratorTarget(gt);
  887. // Set target folder
  888. const char* autogenFolder =
  889. makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
  890. if (!autogenFolder) {
  891. autogenFolder =
  892. makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER");
  893. }
  894. if (autogenFolder && *autogenFolder) {
  895. autogenTarget->SetProperty("FOLDER", autogenFolder);
  896. } else {
  897. // inherit FOLDER property from target (#13688)
  898. utilCopyTargetProperty(gt->Target, target->Target, "FOLDER");
  899. }
  900. target->Target->AddUtility(autogenTargetName);
  901. }
  902. }
  903. void cmQtAutoGeneratorInitializer::SetupAutoGenerateTarget(
  904. cmGeneratorTarget const* target)
  905. {
  906. cmMakefile* makefile = target->Target->GetMakefile();
  907. // forget the variables added here afterwards again:
  908. cmMakefile::ScopePushPop varScope(makefile);
  909. static_cast<void>(varScope);
  910. // Get configurations
  911. std::string config;
  912. const std::vector<std::string> configs(GetConfigurations(makefile, &config));
  913. // Configurations settings buffers
  914. std::map<std::string, std::string> configSuffix;
  915. std::map<std::string, std::string> configMocIncludes;
  916. std::map<std::string, std::string> configMocDefines;
  917. std::map<std::string, std::string> configUicOptions;
  918. // Configuration suffix
  919. if (IsMultiConfig(target->GetGlobalGenerator())) {
  920. for (std::vector<std::string>::const_iterator it = configs.begin();
  921. it != configs.end(); ++it) {
  922. configSuffix[*it] = "_" + *it;
  923. }
  924. }
  925. // Basic setup
  926. {
  927. const bool mocEnabled = target->GetPropertyAsBool("AUTOMOC");
  928. const bool uicEnabled = target->GetPropertyAsBool("AUTOUIC");
  929. const bool rccEnabled = target->GetPropertyAsBool("AUTORCC");
  930. const std::string autogenTargetName = GetAutogenTargetName(target);
  931. const std::string qtMajorVersion = GetQtMajorVersion(target);
  932. std::vector<std::string> sources;
  933. std::vector<std::string> headers;
  934. if (mocEnabled || uicEnabled || rccEnabled) {
  935. std::vector<std::string> mocSkipList;
  936. std::vector<std::string> uicSkipList;
  937. AcquireScanFiles(target, sources, headers, mocSkipList, uicSkipList);
  938. if (mocEnabled) {
  939. MocSetupAutoTarget(target, autogenTargetName, qtMajorVersion, config,
  940. configs, mocSkipList, configMocIncludes,
  941. configMocDefines);
  942. }
  943. if (uicEnabled) {
  944. UicSetupAutoTarget(target, qtMajorVersion, config, configs,
  945. uicSkipList, configUicOptions);
  946. }
  947. if (rccEnabled) {
  948. RccSetupAutoTarget(target, qtMajorVersion);
  949. }
  950. }
  951. AddDefinitionEscaped(makefile, "_autogen_build_dir",
  952. GetAutogenTargetBuildDir(target));
  953. AddDefinitionEscaped(makefile, "_qt_version_major", qtMajorVersion);
  954. AddDefinitionEscaped(makefile, "_sources", sources);
  955. AddDefinitionEscaped(makefile, "_headers", headers);
  956. }
  957. // Generate info file
  958. std::string infoFile = GetAutogenTargetFilesDir(target);
  959. infoFile += "/AutogenInfo.cmake";
  960. {
  961. std::string inf = cmSystemTools::GetCMakeRoot();
  962. inf += "/Modules/AutogenInfo.cmake.in";
  963. makefile->ConfigureFile(inf.c_str(), infoFile.c_str(), false, true, false);
  964. }
  965. // Append custom definitions to info file on demand
  966. if (!configSuffix.empty() || !configMocDefines.empty() ||
  967. !configMocIncludes.empty() || !configUicOptions.empty()) {
  968. // Ensure we have write permission in case .in was read-only.
  969. mode_t perm = 0;
  970. #if defined(_WIN32) && !defined(__CYGWIN__)
  971. mode_t mode_write = S_IWRITE;
  972. #else
  973. mode_t mode_write = S_IWUSR;
  974. #endif
  975. cmSystemTools::GetPermissions(infoFile, perm);
  976. if (!(perm & mode_write)) {
  977. cmSystemTools::SetPermissions(infoFile, perm | mode_write);
  978. }
  979. // Open and write file
  980. cmsys::ofstream ofs(infoFile.c_str(), std::ios::app);
  981. if (ofs) {
  982. ofs << "# Configuration specific options\n";
  983. for (std::map<std::string, std::string>::iterator
  984. it = configSuffix.begin(),
  985. end = configSuffix.end();
  986. it != end; ++it) {
  987. ofs << "set(AM_CONFIG_SUFFIX_" << it->first << " " << it->second
  988. << ")\n";
  989. }
  990. for (std::map<std::string, std::string>::iterator
  991. it = configMocDefines.begin(),
  992. end = configMocDefines.end();
  993. it != end; ++it) {
  994. ofs << "set(AM_MOC_DEFINITIONS_" << it->first << " " << it->second
  995. << ")\n";
  996. }
  997. for (std::map<std::string, std::string>::iterator
  998. it = configMocIncludes.begin(),
  999. end = configMocIncludes.end();
  1000. it != end; ++it) {
  1001. ofs << "set(AM_MOC_INCLUDES_" << it->first << " " << it->second
  1002. << ")\n";
  1003. }
  1004. for (std::map<std::string, std::string>::iterator
  1005. it = configUicOptions.begin(),
  1006. end = configUicOptions.end();
  1007. it != end; ++it) {
  1008. ofs << "set(AM_UIC_TARGET_OPTIONS_" << it->first << " " << it->second
  1009. << ")\n";
  1010. }
  1011. } else {
  1012. // File open error
  1013. std::string error = "Internal CMake error when trying to open file: ";
  1014. error += cmQtAutoGeneratorCommon::Quoted(infoFile);
  1015. error += " for writing.";
  1016. cmSystemTools::Error(error.c_str());
  1017. }
  1018. }
  1019. }