cmInstallCommand.cxx 43 KB

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