cmQtAutoGeneratorInitializer.cxx 39 KB

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