cmInstallCommand.cxx 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmInstallCommand.h"
  14. #include "cmInstallDirectoryGenerator.h"
  15. #include "cmInstallFilesGenerator.h"
  16. #include "cmInstallScriptGenerator.h"
  17. #include "cmInstallTargetGenerator.h"
  18. #include "cmInstallExportGenerator.h"
  19. #include "cmInstallCommandArguments.h"
  20. #include <cmsys/Glob.hxx>
  21. static cmInstallTargetGenerator* CreateInstallTargetGenerator(cmTarget& target,
  22. const cmInstallCommandArguments& args, bool impLib, bool forceOpt = false)
  23. {
  24. return new cmInstallTargetGenerator(target, args.GetDestination().c_str(),
  25. impLib, args.GetPermissions().c_str(),
  26. args.GetConfigurations(), args.GetComponent().c_str(),
  27. args.GetOptional() || forceOpt);
  28. }
  29. static cmInstallFilesGenerator* CreateInstallFilesGenerator(
  30. const std::vector<std::string>& absFiles,
  31. const cmInstallCommandArguments& args, bool programs)
  32. {
  33. return new cmInstallFilesGenerator(absFiles, args.GetDestination().c_str(),
  34. programs, args.GetPermissions().c_str(),
  35. args.GetConfigurations(), args.GetComponent().c_str(),
  36. args.GetRename().c_str(), args.GetOptional());
  37. }
  38. // cmInstallCommand
  39. bool cmInstallCommand::InitialPass(std::vector<std::string> const& args,
  40. cmExecutionStatus &)
  41. {
  42. // Allow calling with no arguments so that arguments may be built up
  43. // using a variable that may be left empty.
  44. if(args.empty())
  45. {
  46. return true;
  47. }
  48. // Enable the install target.
  49. this->Makefile->GetLocalGenerator()
  50. ->GetGlobalGenerator()->EnableInstallTarget();
  51. // Switch among the command modes.
  52. if(args[0] == "SCRIPT")
  53. {
  54. return this->HandleScriptMode(args);
  55. }
  56. else if(args[0] == "CODE")
  57. {
  58. return this->HandleScriptMode(args);
  59. }
  60. else if(args[0] == "TARGETS")
  61. {
  62. return this->HandleTargetsMode(args);
  63. }
  64. else if(args[0] == "FILES")
  65. {
  66. return this->HandleFilesMode(args);
  67. }
  68. else if(args[0] == "PROGRAMS")
  69. {
  70. return this->HandleFilesMode(args);
  71. }
  72. else if(args[0] == "DIRECTORY")
  73. {
  74. return this->HandleDirectoryMode(args);
  75. }
  76. else if(args[0] == "EXPORT")
  77. {
  78. return this->HandleExportMode(args);
  79. }
  80. // Unknown mode.
  81. cmStdString e = "called with unknown mode ";
  82. e += args[0];
  83. this->SetError(e.c_str());
  84. return false;
  85. }
  86. //----------------------------------------------------------------------------
  87. bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
  88. {
  89. std::string component("Unspecified");
  90. int componentCount = 0;
  91. bool doing_script = false;
  92. bool doing_code = false;
  93. // Scan the args once for COMPONENT. Only allow one.
  94. //
  95. for(size_t i=0; i < args.size(); ++i)
  96. {
  97. if(args[i] == "COMPONENT" && i+1 < args.size())
  98. {
  99. ++componentCount;
  100. ++i;
  101. component = args[i];
  102. }
  103. }
  104. if(componentCount>1)
  105. {
  106. this->SetError("given more than one COMPONENT for the SCRIPT or CODE "
  107. "signature of the INSTALL command. "
  108. "Use multiple INSTALL commands with one COMPONENT each.");
  109. return false;
  110. }
  111. // Scan the args again, this time adding install generators each time we
  112. // encounter a SCRIPT or CODE arg:
  113. //
  114. for(size_t i=0; i < args.size(); ++i)
  115. {
  116. if(args[i] == "SCRIPT")
  117. {
  118. doing_script = true;
  119. doing_code = false;
  120. }
  121. else if(args[i] == "CODE")
  122. {
  123. doing_script = false;
  124. doing_code = true;
  125. }
  126. else if(args[i] == "COMPONENT")
  127. {
  128. doing_script = false;
  129. doing_code = false;
  130. }
  131. else if(doing_script)
  132. {
  133. doing_script = false;
  134. std::string script = args[i];
  135. if(!cmSystemTools::FileIsFullPath(script.c_str()))
  136. {
  137. script = this->Makefile->GetCurrentDirectory();
  138. script += "/";
  139. script += args[i];
  140. }
  141. if(cmSystemTools::FileIsDirectory(script.c_str()))
  142. {
  143. this->SetError("given a directory as value of SCRIPT argument.");
  144. return false;
  145. }
  146. this->Makefile->AddInstallGenerator(
  147. new cmInstallScriptGenerator(script.c_str(), false,
  148. component.c_str()));
  149. }
  150. else if(doing_code)
  151. {
  152. doing_code = false;
  153. std::string code = args[i];
  154. this->Makefile->AddInstallGenerator(
  155. new cmInstallScriptGenerator(code.c_str(), true,
  156. component.c_str()));
  157. }
  158. }
  159. if(doing_script)
  160. {
  161. this->SetError("given no value for SCRIPT argument.");
  162. return false;
  163. }
  164. if(doing_code)
  165. {
  166. this->SetError("given no value for CODE argument.");
  167. return false;
  168. }
  169. //Tell the global generator about any installation component names specified.
  170. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  171. ->AddInstallComponent(component.c_str());
  172. return true;
  173. }
  174. /*struct InstallPart
  175. {
  176. InstallPart(cmCommandArgumentsHelper* helper, const char* key,
  177. cmCommandArgumentGroup* group);
  178. cmCAStringVector argVector;
  179. cmInstallCommandArguments args;
  180. };*/
  181. //----------------------------------------------------------------------------
  182. bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
  183. {
  184. // This is the TARGETS mode.
  185. std::vector<cmTarget*> targets;
  186. cmCommandArgumentsHelper argHelper;
  187. cmCommandArgumentGroup group;
  188. cmCAStringVector genericArgVector (&argHelper,0);
  189. cmCAStringVector archiveArgVector (&argHelper,"ARCHIVE",&group);
  190. cmCAStringVector libraryArgVector (&argHelper,"LIBRARY",&group);
  191. cmCAStringVector runtimeArgVector (&argHelper,"RUNTIME",&group);
  192. cmCAStringVector frameworkArgVector (&argHelper,"FRAMEWORK",&group);
  193. cmCAStringVector bundleArgVector (&argHelper,"BUNDLE",&group);
  194. cmCAStringVector privateHeaderArgVector(&argHelper,"PRIVATE_HEADER",&group);
  195. cmCAStringVector publicHeaderArgVector (&argHelper,"PUBLIC_HEADER",&group);
  196. cmCAStringVector resourceArgVector (&argHelper,"RESOURCE",&group);
  197. genericArgVector.Follows(0);
  198. group.Follows(&genericArgVector);
  199. argHelper.Parse(&args, 0);
  200. // now parse the generic args (i.e. the ones not specialized on LIBRARY/
  201. // ARCHIVE, RUNTIME etc. (see above)
  202. // These generic args also contain the targets and the export stuff
  203. std::vector<std::string> unknownArgs;
  204. cmInstallCommandArguments genericArgs;
  205. cmCAStringVector targetList(&genericArgs.Parser, "TARGETS");
  206. cmCAString exports(&genericArgs.Parser,"EXPORT", &genericArgs.ArgumentGroup);
  207. targetList.Follows(0);
  208. genericArgs.ArgumentGroup.Follows(&targetList);
  209. genericArgs.Parse(&genericArgVector.GetVector(), &unknownArgs);
  210. bool success = genericArgs.Finalize();
  211. cmInstallCommandArguments archiveArgs;
  212. cmInstallCommandArguments libraryArgs;
  213. cmInstallCommandArguments runtimeArgs;
  214. cmInstallCommandArguments frameworkArgs;
  215. cmInstallCommandArguments bundleArgs;
  216. cmInstallCommandArguments privateHeaderArgs;
  217. cmInstallCommandArguments publicHeaderArgs;
  218. cmInstallCommandArguments resourceArgs;
  219. // now parse the args for specific parts of the target (e.g. LIBRARY,
  220. // RUNTIME, ARCHIVE etc.
  221. archiveArgs.Parse (&archiveArgVector.GetVector(), &unknownArgs);
  222. libraryArgs.Parse (&libraryArgVector.GetVector(), &unknownArgs);
  223. runtimeArgs.Parse (&runtimeArgVector.GetVector(), &unknownArgs);
  224. frameworkArgs.Parse (&frameworkArgVector.GetVector(), &unknownArgs);
  225. bundleArgs.Parse (&bundleArgVector.GetVector(), &unknownArgs);
  226. privateHeaderArgs.Parse(&privateHeaderArgVector.GetVector(), &unknownArgs);
  227. publicHeaderArgs.Parse (&publicHeaderArgVector.GetVector(), &unknownArgs);
  228. resourceArgs.Parse (&resourceArgVector.GetVector(), &unknownArgs);
  229. if(!unknownArgs.empty())
  230. {
  231. // Unknown argument.
  232. cmOStringStream e;
  233. e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\".";
  234. this->SetError(e.str().c_str());
  235. return false;
  236. }
  237. // apply generic args
  238. archiveArgs.SetGenericArguments(&genericArgs);
  239. libraryArgs.SetGenericArguments(&genericArgs);
  240. runtimeArgs.SetGenericArguments(&genericArgs);
  241. frameworkArgs.SetGenericArguments(&genericArgs);
  242. bundleArgs.SetGenericArguments(&genericArgs);
  243. privateHeaderArgs.SetGenericArguments(&genericArgs);
  244. publicHeaderArgs.SetGenericArguments(&genericArgs);
  245. resourceArgs.SetGenericArguments(&genericArgs);
  246. success = success && archiveArgs.Finalize();
  247. success = success && libraryArgs.Finalize();
  248. success = success && runtimeArgs.Finalize();
  249. success = success && frameworkArgs.Finalize();
  250. success = success && bundleArgs.Finalize();
  251. success = success && privateHeaderArgs.Finalize();
  252. success = success && publicHeaderArgs.Finalize();
  253. success = success && resourceArgs.Finalize();
  254. if(!success)
  255. {
  256. return false;
  257. }
  258. // Enforce argument rules too complex to specify for the
  259. // general-purpose parser.
  260. if(archiveArgs.GetNamelinkOnly() ||
  261. runtimeArgs.GetNamelinkOnly() ||
  262. frameworkArgs.GetNamelinkOnly() ||
  263. bundleArgs.GetNamelinkOnly() ||
  264. privateHeaderArgs.GetNamelinkOnly() ||
  265. publicHeaderArgs.GetNamelinkOnly() ||
  266. resourceArgs.GetNamelinkOnly())
  267. {
  268. this->SetError(
  269. "TARGETS given NAMELINK_ONLY option not in LIBRARY group. "
  270. "The NAMELINK_ONLY option may be specified only following LIBRARY."
  271. );
  272. return false;
  273. }
  274. if(archiveArgs.GetNamelinkSkip() ||
  275. runtimeArgs.GetNamelinkSkip() ||
  276. frameworkArgs.GetNamelinkSkip() ||
  277. bundleArgs.GetNamelinkSkip() ||
  278. privateHeaderArgs.GetNamelinkSkip() ||
  279. publicHeaderArgs.GetNamelinkSkip() ||
  280. resourceArgs.GetNamelinkSkip())
  281. {
  282. this->SetError(
  283. "TARGETS given NAMELINK_SKIP option not in LIBRARY group. "
  284. "The NAMELINK_SKIP option may be specified only following LIBRARY."
  285. );
  286. return false;
  287. }
  288. if(libraryArgs.GetNamelinkOnly() && libraryArgs.GetNamelinkSkip())
  289. {
  290. this->SetError(
  291. "TARGETS given NAMELINK_ONLY and NAMELINK_SKIP. "
  292. "At most one of these two options may be specified."
  293. );
  294. return false;
  295. }
  296. // Select the mode for installing symlinks to versioned shared libraries.
  297. cmInstallTargetGenerator::NamelinkModeType
  298. namelinkMode = cmInstallTargetGenerator::NamelinkModeNone;
  299. if(libraryArgs.GetNamelinkOnly())
  300. {
  301. namelinkMode = cmInstallTargetGenerator::NamelinkModeOnly;
  302. }
  303. else if(libraryArgs.GetNamelinkSkip())
  304. {
  305. namelinkMode = cmInstallTargetGenerator::NamelinkModeSkip;
  306. }
  307. // Check if there is something to do.
  308. if(targetList.GetVector().empty())
  309. {
  310. return true;
  311. }
  312. // Check whether this is a DLL platform.
  313. bool dll_platform = (this->Makefile->IsOn("WIN32") ||
  314. this->Makefile->IsOn("CYGWIN") ||
  315. this->Makefile->IsOn("MINGW"));
  316. for(std::vector<std::string>::const_iterator
  317. targetIt=targetList.GetVector().begin();
  318. targetIt!=targetList.GetVector().end();
  319. ++targetIt)
  320. {
  321. // Lookup this target in the current directory.
  322. if(cmTarget* target=this->Makefile->FindTarget(targetIt->c_str()))
  323. {
  324. // Found the target. Check its type.
  325. if(target->GetType() != cmTarget::EXECUTABLE &&
  326. target->GetType() != cmTarget::STATIC_LIBRARY &&
  327. target->GetType() != cmTarget::SHARED_LIBRARY &&
  328. target->GetType() != cmTarget::MODULE_LIBRARY)
  329. {
  330. cmOStringStream e;
  331. e << "TARGETS given target \"" << (*targetIt)
  332. << "\" which is not an executable, library, or module.";
  333. this->SetError(e.str().c_str());
  334. return false;
  335. }
  336. // Store the target in the list to be installed.
  337. targets.push_back(target);
  338. }
  339. else
  340. {
  341. // Did not find the target.
  342. cmOStringStream e;
  343. e << "TARGETS given target \"" << (*targetIt)
  344. << "\" which does not exist in this directory.";
  345. this->SetError(e.str().c_str());
  346. return false;
  347. }
  348. }
  349. // Generate install script code to install the given targets.
  350. for(std::vector<cmTarget*>::iterator ti = targets.begin();
  351. ti != targets.end(); ++ti)
  352. {
  353. // Handle each target type.
  354. cmTarget& target = *(*ti);
  355. cmInstallTargetGenerator* archiveGenerator = 0;
  356. cmInstallTargetGenerator* libraryGenerator = 0;
  357. cmInstallTargetGenerator* runtimeGenerator = 0;
  358. cmInstallTargetGenerator* frameworkGenerator = 0;
  359. cmInstallTargetGenerator* bundleGenerator = 0;
  360. cmInstallFilesGenerator* privateHeaderGenerator = 0;
  361. cmInstallFilesGenerator* publicHeaderGenerator = 0;
  362. cmInstallFilesGenerator* resourceGenerator = 0;
  363. // Track whether this is a namelink-only rule.
  364. bool namelinkOnly = false;
  365. switch(target.GetType())
  366. {
  367. case cmTarget::SHARED_LIBRARY:
  368. {
  369. // Shared libraries are handled differently on DLL and non-DLL
  370. // platforms. All windows platforms are DLL platforms including
  371. // cygwin. Currently no other platform is a DLL platform.
  372. if(dll_platform)
  373. {
  374. // When in namelink only mode skip all libraries on Windows.
  375. if(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly)
  376. {
  377. continue;
  378. }
  379. // This is a DLL platform.
  380. if(!archiveArgs.GetDestination().empty())
  381. {
  382. // The import library uses the ARCHIVE properties.
  383. archiveGenerator = CreateInstallTargetGenerator(target,
  384. archiveArgs, true);
  385. }
  386. if(!runtimeArgs.GetDestination().empty())
  387. {
  388. // The DLL uses the RUNTIME properties.
  389. runtimeGenerator = CreateInstallTargetGenerator(target,
  390. runtimeArgs, false);
  391. }
  392. if ((archiveGenerator==0) && (runtimeGenerator==0))
  393. {
  394. this->SetError("Library TARGETS given no DESTINATION!");
  395. return false;
  396. }
  397. }
  398. else
  399. {
  400. // This is a non-DLL platform.
  401. // If it is marked with FRAMEWORK property use the FRAMEWORK set of
  402. // INSTALL properties. Otherwise, use the LIBRARY properties.
  403. if(target.IsFrameworkOnApple())
  404. {
  405. // When in namelink only mode skip frameworks.
  406. if(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly)
  407. {
  408. continue;
  409. }
  410. // Use the FRAMEWORK properties.
  411. if (!frameworkArgs.GetDestination().empty())
  412. {
  413. frameworkGenerator = CreateInstallTargetGenerator(target,
  414. frameworkArgs, false);
  415. }
  416. else
  417. {
  418. cmOStringStream e;
  419. e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
  420. "FRAMEWORK target \"" << target.GetName() << "\".";
  421. this->SetError(e.str().c_str());
  422. return false;
  423. }
  424. }
  425. else
  426. {
  427. // The shared library uses the LIBRARY properties.
  428. if (!libraryArgs.GetDestination().empty())
  429. {
  430. libraryGenerator = CreateInstallTargetGenerator(target,
  431. libraryArgs, false);
  432. libraryGenerator->SetNamelinkMode(namelinkMode);
  433. namelinkOnly =
  434. (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
  435. }
  436. else
  437. {
  438. cmOStringStream e;
  439. e << "TARGETS given no LIBRARY DESTINATION for shared library "
  440. "target \"" << target.GetName() << "\".";
  441. this->SetError(e.str().c_str());
  442. return false;
  443. }
  444. }
  445. }
  446. }
  447. break;
  448. case cmTarget::STATIC_LIBRARY:
  449. {
  450. // Static libraries use ARCHIVE properties.
  451. if (!archiveArgs.GetDestination().empty())
  452. {
  453. archiveGenerator = CreateInstallTargetGenerator(target, archiveArgs,
  454. false);
  455. }
  456. else
  457. {
  458. cmOStringStream e;
  459. e << "TARGETS given no ARCHIVE DESTINATION for static library "
  460. "target \"" << target.GetName() << "\".";
  461. this->SetError(e.str().c_str());
  462. return false;
  463. }
  464. }
  465. break;
  466. case cmTarget::MODULE_LIBRARY:
  467. {
  468. // Modules use LIBRARY properties.
  469. if (!libraryArgs.GetDestination().empty())
  470. {
  471. libraryGenerator = CreateInstallTargetGenerator(target, libraryArgs,
  472. false);
  473. libraryGenerator->SetNamelinkMode(namelinkMode);
  474. namelinkOnly =
  475. (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
  476. }
  477. else
  478. {
  479. cmOStringStream e;
  480. e << "TARGETS given no LIBRARY DESTINATION for module target \""
  481. << target.GetName() << "\".";
  482. this->SetError(e.str().c_str());
  483. return false;
  484. }
  485. }
  486. break;
  487. case cmTarget::EXECUTABLE:
  488. {
  489. if(target.IsAppBundleOnApple())
  490. {
  491. // Application bundles use the BUNDLE properties.
  492. if (!bundleArgs.GetDestination().empty())
  493. {
  494. bundleGenerator = CreateInstallTargetGenerator(target, bundleArgs,
  495. false);
  496. }
  497. else if(!runtimeArgs.GetDestination().empty())
  498. {
  499. bool failure = false;
  500. if(this->CheckCMP0006(failure))
  501. {
  502. // For CMake 2.4 compatibility fallback to the RUNTIME
  503. // properties.
  504. bundleGenerator =
  505. CreateInstallTargetGenerator(target, runtimeArgs, false);
  506. }
  507. else if(failure)
  508. {
  509. return false;
  510. }
  511. }
  512. if(!bundleGenerator)
  513. {
  514. cmOStringStream e;
  515. e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE "
  516. "executable target \"" << target.GetName() << "\".";
  517. this->SetError(e.str().c_str());
  518. return false;
  519. }
  520. }
  521. else
  522. {
  523. // Executables use the RUNTIME properties.
  524. if (!runtimeArgs.GetDestination().empty())
  525. {
  526. runtimeGenerator = CreateInstallTargetGenerator(target,
  527. runtimeArgs, false);
  528. }
  529. else
  530. {
  531. cmOStringStream e;
  532. e << "TARGETS given no RUNTIME DESTINATION for executable "
  533. "target \"" << target.GetName() << "\".";
  534. this->SetError(e.str().c_str());
  535. return false;
  536. }
  537. }
  538. // On DLL platforms an executable may also have an import
  539. // library. Install it to the archive destination if it
  540. // exists.
  541. if(dll_platform && !archiveArgs.GetDestination().empty() &&
  542. target.IsExecutableWithExports())
  543. {
  544. // The import library uses the ARCHIVE properties.
  545. archiveGenerator = CreateInstallTargetGenerator(target,
  546. archiveArgs, true, true);
  547. }
  548. }
  549. break;
  550. default:
  551. // This should never happen due to the above type check.
  552. // Ignore the case.
  553. break;
  554. }
  555. // if(target.GetProperty("ASSOCIATED_FILES");
  556. // These well-known sets of files are installed *automatically* for FRAMEWORK
  557. // SHARED library targets on the Mac as part of installing the FRAMEWORK.
  558. // For other target types or on other platforms, they are not installed
  559. // automatically and so we need to create install files generators for them.
  560. //
  561. bool createInstallGeneratorsForTargetFileSets = true;
  562. if(target.IsFrameworkOnApple())
  563. {
  564. createInstallGeneratorsForTargetFileSets = false;
  565. }
  566. if(createInstallGeneratorsForTargetFileSets && !namelinkOnly)
  567. {
  568. const char* files = target.GetProperty("PRIVATE_HEADER");
  569. if ((files) && (*files))
  570. {
  571. std::vector<std::string> relFiles;
  572. cmSystemTools::ExpandListArgument(files, relFiles);
  573. std::vector<std::string> absFiles;
  574. if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles))
  575. {
  576. return false;
  577. }
  578. // Create the files install generator.
  579. if (!privateHeaderArgs.GetDestination().empty())
  580. {
  581. privateHeaderGenerator = CreateInstallFilesGenerator(absFiles,
  582. privateHeaderArgs, false);
  583. }
  584. else
  585. {
  586. cmOStringStream e;
  587. e << "INSTALL TARGETS - target " << target.GetName() << " has "
  588. << "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.";
  589. cmSystemTools::Message(e.str().c_str(), "Warning");
  590. }
  591. }
  592. files = target.GetProperty("PUBLIC_HEADER");
  593. if ((files) && (*files))
  594. {
  595. std::vector<std::string> relFiles;
  596. cmSystemTools::ExpandListArgument(files, relFiles);
  597. std::vector<std::string> absFiles;
  598. if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles))
  599. {
  600. return false;
  601. }
  602. // Create the files install generator.
  603. if (!publicHeaderArgs.GetDestination().empty())
  604. {
  605. publicHeaderGenerator = CreateInstallFilesGenerator(absFiles,
  606. publicHeaderArgs, false);
  607. }
  608. else
  609. {
  610. cmOStringStream e;
  611. e << "INSTALL TARGETS - target " << target.GetName() << " has "
  612. << "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.";
  613. cmSystemTools::Message(e.str().c_str(), "Warning");
  614. }
  615. }
  616. files = target.GetProperty("RESOURCE");
  617. if ((files) && (*files))
  618. {
  619. std::vector<std::string> relFiles;
  620. cmSystemTools::ExpandListArgument(files, relFiles);
  621. std::vector<std::string> absFiles;
  622. if (!this->MakeFilesFullPath("RESOURCE", relFiles, absFiles))
  623. {
  624. return false;
  625. }
  626. // Create the files install generator.
  627. if (!resourceArgs.GetDestination().empty())
  628. {
  629. resourceGenerator = CreateInstallFilesGenerator(absFiles,
  630. resourceArgs, false);
  631. }
  632. else
  633. {
  634. cmOStringStream e;
  635. e << "INSTALL TARGETS - target " << target.GetName() << " has "
  636. << "RESOURCE files but no RESOURCE DESTINATION.";
  637. cmSystemTools::Message(e.str().c_str(), "Warning");
  638. }
  639. }
  640. }
  641. this->Makefile->AddInstallGenerator(archiveGenerator);
  642. this->Makefile->AddInstallGenerator(libraryGenerator);
  643. this->Makefile->AddInstallGenerator(runtimeGenerator);
  644. this->Makefile->AddInstallGenerator(frameworkGenerator);
  645. this->Makefile->AddInstallGenerator(bundleGenerator);
  646. this->Makefile->AddInstallGenerator(privateHeaderGenerator);
  647. this->Makefile->AddInstallGenerator(publicHeaderGenerator);
  648. this->Makefile->AddInstallGenerator(resourceGenerator);
  649. // Add this install rule to an export if one was specified and
  650. // this is not a namelink-only rule.
  651. if(!exports.GetString().empty() && !namelinkOnly)
  652. {
  653. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  654. ->AddTargetToExports(exports.GetCString(), &target,
  655. archiveGenerator, runtimeGenerator,
  656. libraryGenerator, frameworkGenerator,
  657. bundleGenerator, publicHeaderGenerator);
  658. }
  659. }
  660. // Tell the global generator about any installation component names specified
  661. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  662. ->AddInstallComponent(archiveArgs.GetComponent().c_str());
  663. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  664. ->AddInstallComponent(libraryArgs.GetComponent().c_str());
  665. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  666. ->AddInstallComponent(runtimeArgs.GetComponent().c_str());
  667. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  668. ->AddInstallComponent(frameworkArgs.GetComponent().c_str());
  669. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  670. ->AddInstallComponent(bundleArgs.GetComponent().c_str());
  671. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  672. ->AddInstallComponent(privateHeaderArgs.GetComponent().c_str());
  673. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  674. ->AddInstallComponent(publicHeaderArgs.GetComponent().c_str());
  675. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  676. ->AddInstallComponent(resourceArgs.GetComponent().c_str());
  677. return true;
  678. }
  679. //----------------------------------------------------------------------------
  680. bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
  681. {
  682. // This is the FILES mode.
  683. bool programs = (args[0] == "PROGRAMS");
  684. cmInstallCommandArguments ica;
  685. cmCAStringVector files(&ica.Parser, programs ? "PROGRAMS" : "FILES");
  686. files.Follows(0);
  687. ica.ArgumentGroup.Follows(&files);
  688. std::vector<std::string> unknownArgs;
  689. ica.Parse(&args, &unknownArgs);
  690. if(!unknownArgs.empty())
  691. {
  692. // Unknown argument.
  693. cmOStringStream e;
  694. e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
  695. this->SetError(e.str().c_str());
  696. return false;
  697. }
  698. // Check if there is something to do.
  699. if(files.GetVector().empty())
  700. {
  701. return true;
  702. }
  703. if(!ica.GetRename().empty() && files.GetVector().size() > 1)
  704. {
  705. // The rename option works only with one file.
  706. cmOStringStream e;
  707. e << args[0] << " given RENAME option with more than one file.";
  708. this->SetError(e.str().c_str());
  709. return false;
  710. }
  711. std::vector<std::string> absFiles;
  712. if (!this->MakeFilesFullPath(args[0].c_str(), files.GetVector(), absFiles))
  713. {
  714. return false;
  715. }
  716. if (!ica.Finalize())
  717. {
  718. return false;
  719. }
  720. if(ica.GetDestination().empty())
  721. {
  722. // A destination is required.
  723. cmOStringStream e;
  724. e << args[0] << " given no DESTINATION!";
  725. this->SetError(e.str().c_str());
  726. return false;
  727. }
  728. // Create the files install generator.
  729. this->Makefile->AddInstallGenerator(
  730. CreateInstallFilesGenerator(absFiles, ica, programs));
  731. //Tell the global generator about any installation component names specified.
  732. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  733. ->AddInstallComponent(ica.GetComponent().c_str());
  734. return true;
  735. }
  736. //----------------------------------------------------------------------------
  737. bool
  738. cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
  739. {
  740. bool doing_dirs = true;
  741. bool doing_destination = false;
  742. bool doing_pattern = false;
  743. bool doing_regex = false;
  744. bool doing_permissions_file = false;
  745. bool doing_permissions_dir = false;
  746. bool doing_permissions_match = false;
  747. bool doing_configurations = false;
  748. bool doing_component = false;
  749. bool in_match_mode = false;
  750. std::vector<std::string> dirs;
  751. const char* destination = 0;
  752. std::string permissions_file;
  753. std::string permissions_dir;
  754. std::vector<std::string> configurations;
  755. std::string component = "Unspecified";
  756. std::string literal_args;
  757. for(unsigned int i=1; i < args.size(); ++i)
  758. {
  759. if(args[i] == "DESTINATION")
  760. {
  761. if(in_match_mode)
  762. {
  763. cmOStringStream e;
  764. e << args[0] << " does not allow \""
  765. << args[i] << "\" after PATTERN or REGEX.";
  766. this->SetError(e.str().c_str());
  767. return false;
  768. }
  769. // Switch to setting the destination property.
  770. doing_dirs = false;
  771. doing_destination = true;
  772. doing_pattern = false;
  773. doing_regex = false;
  774. doing_permissions_file = false;
  775. doing_permissions_dir = false;
  776. doing_configurations = false;
  777. doing_component = false;
  778. }
  779. else if(args[i] == "PATTERN")
  780. {
  781. // Switch to a new pattern match rule.
  782. doing_dirs = false;
  783. doing_destination = false;
  784. doing_pattern = true;
  785. doing_regex = false;
  786. doing_permissions_file = false;
  787. doing_permissions_dir = false;
  788. doing_permissions_match = false;
  789. doing_configurations = false;
  790. doing_component = false;
  791. in_match_mode = true;
  792. }
  793. else if(args[i] == "REGEX")
  794. {
  795. // Switch to a new regex match rule.
  796. doing_dirs = false;
  797. doing_destination = false;
  798. doing_pattern = false;
  799. doing_regex = true;
  800. doing_permissions_file = false;
  801. doing_permissions_dir = false;
  802. doing_permissions_match = false;
  803. doing_configurations = false;
  804. doing_component = false;
  805. in_match_mode = true;
  806. }
  807. else if(args[i] == "EXCLUDE")
  808. {
  809. // Add this property to the current match rule.
  810. if(!in_match_mode || doing_pattern || doing_regex)
  811. {
  812. cmOStringStream e;
  813. e << args[0] << " does not allow \""
  814. << args[i] << "\" before a PATTERN or REGEX is given.";
  815. this->SetError(e.str().c_str());
  816. return false;
  817. }
  818. literal_args += " EXCLUDE";
  819. doing_permissions_match = false;
  820. }
  821. else if(args[i] == "PERMISSIONS")
  822. {
  823. if(!in_match_mode)
  824. {
  825. cmOStringStream e;
  826. e << args[0] << " does not allow \""
  827. << args[i] << "\" before a PATTERN or REGEX is given.";
  828. this->SetError(e.str().c_str());
  829. return false;
  830. }
  831. // Switch to setting the current match permissions property.
  832. literal_args += " PERMISSIONS";
  833. doing_permissions_match = true;
  834. }
  835. else if(args[i] == "FILE_PERMISSIONS")
  836. {
  837. if(in_match_mode)
  838. {
  839. cmOStringStream e;
  840. e << args[0] << " does not allow \""
  841. << args[i] << "\" after PATTERN or REGEX.";
  842. this->SetError(e.str().c_str());
  843. return false;
  844. }
  845. // Switch to setting the file permissions property.
  846. doing_dirs = false;
  847. doing_destination = false;
  848. doing_pattern = false;
  849. doing_regex = false;
  850. doing_permissions_file = true;
  851. doing_permissions_dir = false;
  852. doing_configurations = false;
  853. doing_component = false;
  854. }
  855. else if(args[i] == "DIRECTORY_PERMISSIONS")
  856. {
  857. if(in_match_mode)
  858. {
  859. cmOStringStream e;
  860. e << args[0] << " does not allow \""
  861. << args[i] << "\" after PATTERN or REGEX.";
  862. this->SetError(e.str().c_str());
  863. return false;
  864. }
  865. // Switch to setting the directory permissions property.
  866. doing_dirs = false;
  867. doing_destination = false;
  868. doing_pattern = false;
  869. doing_regex = false;
  870. doing_permissions_file = false;
  871. doing_permissions_dir = true;
  872. doing_configurations = false;
  873. doing_component = false;
  874. }
  875. else if(args[i] == "USE_SOURCE_PERMISSIONS")
  876. {
  877. if(in_match_mode)
  878. {
  879. cmOStringStream e;
  880. e << args[0] << " does not allow \""
  881. << args[i] << "\" after PATTERN or REGEX.";
  882. this->SetError(e.str().c_str());
  883. return false;
  884. }
  885. // Add this option literally.
  886. doing_dirs = false;
  887. doing_destination = false;
  888. doing_pattern = false;
  889. doing_regex = false;
  890. doing_permissions_file = false;
  891. doing_permissions_dir = false;
  892. doing_configurations = false;
  893. doing_component = false;
  894. literal_args += " USE_SOURCE_PERMISSIONS";
  895. }
  896. else if(args[i] == "FILES_MATCHING")
  897. {
  898. if(in_match_mode)
  899. {
  900. cmOStringStream e;
  901. e << args[0] << " does not allow \""
  902. << args[i] << "\" after PATTERN or REGEX.";
  903. this->SetError(e.str().c_str());
  904. return false;
  905. }
  906. // Add this option literally.
  907. doing_dirs = false;
  908. doing_destination = false;
  909. doing_pattern = false;
  910. doing_regex = false;
  911. doing_permissions_file = false;
  912. doing_permissions_dir = false;
  913. doing_permissions_match = false;
  914. doing_configurations = false;
  915. doing_component = false;
  916. literal_args += " FILES_MATCHING";
  917. }
  918. else if(args[i] == "CONFIGURATIONS")
  919. {
  920. if(in_match_mode)
  921. {
  922. cmOStringStream e;
  923. e << args[0] << " does not allow \""
  924. << args[i] << "\" after PATTERN or REGEX.";
  925. this->SetError(e.str().c_str());
  926. return false;
  927. }
  928. // Switch to setting the configurations property.
  929. doing_dirs = false;
  930. doing_destination = false;
  931. doing_pattern = false;
  932. doing_regex = false;
  933. doing_permissions_file = false;
  934. doing_permissions_dir = false;
  935. doing_configurations = true;
  936. doing_component = false;
  937. }
  938. else if(args[i] == "COMPONENT")
  939. {
  940. if(in_match_mode)
  941. {
  942. cmOStringStream e;
  943. e << args[0] << " does not allow \""
  944. << args[i] << "\" after PATTERN or REGEX.";
  945. this->SetError(e.str().c_str());
  946. return false;
  947. }
  948. // Switch to setting the component property.
  949. doing_dirs = false;
  950. doing_destination = false;
  951. doing_pattern = false;
  952. doing_regex = false;
  953. doing_permissions_file = false;
  954. doing_permissions_dir = false;
  955. doing_configurations = false;
  956. doing_component = true;
  957. }
  958. else if(doing_dirs)
  959. {
  960. // Convert this directory to a full path.
  961. std::string dir = args[i];
  962. if(!cmSystemTools::FileIsFullPath(dir.c_str()))
  963. {
  964. dir = this->Makefile->GetCurrentDirectory();
  965. dir += "/";
  966. dir += args[i];
  967. }
  968. // Make sure the name is a directory.
  969. if(cmSystemTools::FileExists(dir.c_str()) &&
  970. !cmSystemTools::FileIsDirectory(dir.c_str()))
  971. {
  972. cmOStringStream e;
  973. e << args[0] << " given non-directory \""
  974. << args[i] << "\" to install.";
  975. this->SetError(e.str().c_str());
  976. return false;
  977. }
  978. // Store the directory for installation.
  979. dirs.push_back(dir);
  980. }
  981. else if(doing_configurations)
  982. {
  983. configurations.push_back(args[i]);
  984. }
  985. else if(doing_destination)
  986. {
  987. destination = args[i].c_str();
  988. doing_destination = false;
  989. }
  990. else if(doing_pattern)
  991. {
  992. // Convert the pattern to a regular expression. Require a
  993. // leading slash and trailing end-of-string in the matched
  994. // string to make sure the pattern matches only whole file
  995. // names.
  996. literal_args += " REGEX \"/";
  997. std::string regex = cmsys::Glob::PatternToRegex(args[i], false);
  998. cmSystemTools::ReplaceString(regex, "\\", "\\\\");
  999. literal_args += regex;
  1000. literal_args += "$\"";
  1001. doing_pattern = false;
  1002. }
  1003. else if(doing_regex)
  1004. {
  1005. literal_args += " REGEX \"";
  1006. // Match rules are case-insensitive on some platforms.
  1007. #if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
  1008. std::string regex = cmSystemTools::LowerCase(args[i]);
  1009. #else
  1010. std::string regex = args[i];
  1011. #endif
  1012. cmSystemTools::ReplaceString(regex, "\\", "\\\\");
  1013. literal_args += regex;
  1014. literal_args += "\"";
  1015. doing_regex = false;
  1016. }
  1017. else if(doing_component)
  1018. {
  1019. component = args[i];
  1020. doing_component = false;
  1021. }
  1022. else if(doing_permissions_file)
  1023. {
  1024. // Check the requested permission.
  1025. if(!cmInstallCommandArguments::CheckPermissions(args[i],permissions_file))
  1026. {
  1027. cmOStringStream e;
  1028. e << args[0] << " given invalid file permission \""
  1029. << args[i] << "\".";
  1030. this->SetError(e.str().c_str());
  1031. return false;
  1032. }
  1033. }
  1034. else if(doing_permissions_dir)
  1035. {
  1036. // Check the requested permission.
  1037. if(!cmInstallCommandArguments::CheckPermissions(args[i],permissions_dir))
  1038. {
  1039. cmOStringStream e;
  1040. e << args[0] << " given invalid directory permission \""
  1041. << args[i] << "\".";
  1042. this->SetError(e.str().c_str());
  1043. return false;
  1044. }
  1045. }
  1046. else if(doing_permissions_match)
  1047. {
  1048. // Check the requested permission.
  1049. if(!cmInstallCommandArguments::CheckPermissions(args[i], literal_args))
  1050. {
  1051. cmOStringStream e;
  1052. e << args[0] << " given invalid permission \""
  1053. << args[i] << "\".";
  1054. this->SetError(e.str().c_str());
  1055. return false;
  1056. }
  1057. }
  1058. else
  1059. {
  1060. // Unknown argument.
  1061. cmOStringStream e;
  1062. e << args[0] << " given unknown argument \"" << args[i] << "\".";
  1063. this->SetError(e.str().c_str());
  1064. return false;
  1065. }
  1066. }
  1067. // Support installing an empty directory.
  1068. if(dirs.empty() && destination)
  1069. {
  1070. dirs.push_back("");
  1071. }
  1072. // Check if there is something to do.
  1073. if(dirs.empty())
  1074. {
  1075. return true;
  1076. }
  1077. if(!destination)
  1078. {
  1079. // A destination is required.
  1080. cmOStringStream e;
  1081. e << args[0] << " given no DESTINATION!";
  1082. this->SetError(e.str().c_str());
  1083. return false;
  1084. }
  1085. // Create the directory install generator.
  1086. this->Makefile->AddInstallGenerator(
  1087. new cmInstallDirectoryGenerator(dirs, destination,
  1088. permissions_file.c_str(),
  1089. permissions_dir.c_str(),
  1090. configurations,
  1091. component.c_str(),
  1092. literal_args.c_str()));
  1093. // Tell the global generator about any installation component names
  1094. // specified.
  1095. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  1096. ->AddInstallComponent(component.c_str());
  1097. return true;
  1098. }
  1099. //----------------------------------------------------------------------------
  1100. bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
  1101. {
  1102. // This is the EXPORT mode.
  1103. cmInstallCommandArguments ica;
  1104. cmCAString exp(&ica.Parser, "EXPORT");
  1105. cmCAString name_space(&ica.Parser, "NAMESPACE", &ica.ArgumentGroup);
  1106. cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup);
  1107. exp.Follows(0);
  1108. ica.ArgumentGroup.Follows(&exp);
  1109. std::vector<std::string> unknownArgs;
  1110. ica.Parse(&args, &unknownArgs);
  1111. if (!unknownArgs.empty())
  1112. {
  1113. // Unknown argument.
  1114. cmOStringStream e;
  1115. e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
  1116. this->SetError(e.str().c_str());
  1117. return false;
  1118. }
  1119. if (!ica.Finalize())
  1120. {
  1121. return false;
  1122. }
  1123. // Make sure there is a destination.
  1124. if(ica.GetDestination().empty())
  1125. {
  1126. // A destination is required.
  1127. cmOStringStream e;
  1128. e << args[0] << " given no DESTINATION!";
  1129. this->SetError(e.str().c_str());
  1130. return false;
  1131. }
  1132. // Check the file name.
  1133. std::string fname = filename.GetString();
  1134. if(fname.find_first_of(":/\\") != fname.npos)
  1135. {
  1136. cmOStringStream e;
  1137. e << args[0] << " given invalid export file name \"" << fname << "\". "
  1138. << "The FILE argument may not contain a path. "
  1139. << "Specify the path in the DESTINATION argument.";
  1140. this->SetError(e.str().c_str());
  1141. return false;
  1142. }
  1143. // Check the file extension.
  1144. if(!fname.empty() &&
  1145. cmSystemTools::GetFilenameLastExtension(fname) != ".cmake")
  1146. {
  1147. cmOStringStream e;
  1148. e << args[0] << " given invalid export file name \"" << fname << "\". "
  1149. << "The FILE argument must specify a name ending in \".cmake\".";
  1150. this->SetError(e.str().c_str());
  1151. return false;
  1152. }
  1153. // Construct the file name.
  1154. if(fname.empty())
  1155. {
  1156. fname = exp.GetString();
  1157. fname += ".cmake";
  1158. if(fname.find_first_of(":/\\") != fname.npos)
  1159. {
  1160. cmOStringStream e;
  1161. e << args[0] << " given export name \"" << exp.GetString() << "\". "
  1162. << "This name cannot be safely converted to a file name. "
  1163. << "Specify a different export name or use the FILE option to set "
  1164. << "a file name explicitly.";
  1165. this->SetError(e.str().c_str());
  1166. return false;
  1167. }
  1168. }
  1169. // Create the export install generator.
  1170. cmInstallExportGenerator* exportGenerator =
  1171. new cmInstallExportGenerator(
  1172. exp.GetCString(), ica.GetDestination().c_str(),
  1173. ica.GetPermissions().c_str(), ica.GetConfigurations(),
  1174. ica.GetComponent().c_str(), fname.c_str(),
  1175. name_space.GetCString(), this->Makefile);
  1176. this->Makefile->AddInstallGenerator(exportGenerator);
  1177. return true;
  1178. }
  1179. bool cmInstallCommand::MakeFilesFullPath(const char* modeName,
  1180. const std::vector<std::string>& relFiles,
  1181. std::vector<std::string>& absFiles)
  1182. {
  1183. for(std::vector<std::string>::const_iterator fileIt = relFiles.begin();
  1184. fileIt != relFiles.end();
  1185. ++fileIt)
  1186. {
  1187. std::string file = (*fileIt);
  1188. if(!cmSystemTools::FileIsFullPath(file.c_str()))
  1189. {
  1190. file = this->Makefile->GetCurrentDirectory();
  1191. file += "/";
  1192. file += *fileIt;
  1193. }
  1194. // Make sure the file is not a directory.
  1195. if(cmSystemTools::FileIsDirectory(file.c_str()))
  1196. {
  1197. cmOStringStream e;
  1198. e << modeName << " given directory \"" << (*fileIt) << "\" to install.";
  1199. this->SetError(e.str().c_str());
  1200. return false;
  1201. }
  1202. // Store the file for installation.
  1203. absFiles.push_back(file);
  1204. }
  1205. return true;
  1206. }
  1207. //----------------------------------------------------------------------------
  1208. bool cmInstallCommand::CheckCMP0006(bool& failure)
  1209. {
  1210. switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0006))
  1211. {
  1212. case cmPolicies::WARN:
  1213. {
  1214. this->Makefile->IssueMessage(
  1215. cmake::AUTHOR_WARNING,
  1216. this->Makefile->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0006)
  1217. );
  1218. }
  1219. case cmPolicies::OLD:
  1220. // OLD behavior is to allow compatibility
  1221. return true;
  1222. case cmPolicies::NEW:
  1223. // NEW behavior is to disallow compatibility
  1224. break;
  1225. case cmPolicies::REQUIRED_IF_USED:
  1226. case cmPolicies::REQUIRED_ALWAYS:
  1227. failure = true;
  1228. this->Makefile->IssueMessage(
  1229. cmake::FATAL_ERROR,
  1230. this->Makefile->GetPolicies()
  1231. ->GetRequiredPolicyError(cmPolicies::CMP0006)
  1232. );
  1233. break;
  1234. }
  1235. return false;
  1236. }