cmInstallCommand.cxx 42 KB

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