cmInstallCommand.cxx 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319
  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. {
  327. cmOStringStream e;
  328. e << "TARGETS given target \"" << (*targetIt)
  329. << "\" which is not an executable, library, or module.";
  330. this->SetError(e.str().c_str());
  331. return false;
  332. }
  333. // Store the target in the list to be installed.
  334. targets.push_back(target);
  335. }
  336. else
  337. {
  338. // Did not find the target.
  339. cmOStringStream e;
  340. e << "TARGETS given target \"" << (*targetIt)
  341. << "\" which does not exist in this directory.";
  342. this->SetError(e.str().c_str());
  343. return false;
  344. }
  345. }
  346. // Keep track of whether we will be performing an installation of
  347. // any files of the given type.
  348. bool installsArchive = false;
  349. bool installsLibrary = false;
  350. bool installsRuntime = false;
  351. bool installsFramework = false;
  352. bool installsBundle = false;
  353. bool installsPrivateHeader = false;
  354. bool installsPublicHeader = false;
  355. bool installsResource = false;
  356. // Generate install script code to install the given targets.
  357. for(std::vector<cmTarget*>::iterator ti = targets.begin();
  358. ti != targets.end(); ++ti)
  359. {
  360. // Handle each target type.
  361. cmTarget& target = *(*ti);
  362. cmInstallTargetGenerator* archiveGenerator = 0;
  363. cmInstallTargetGenerator* libraryGenerator = 0;
  364. cmInstallTargetGenerator* runtimeGenerator = 0;
  365. cmInstallTargetGenerator* frameworkGenerator = 0;
  366. cmInstallTargetGenerator* bundleGenerator = 0;
  367. cmInstallFilesGenerator* privateHeaderGenerator = 0;
  368. cmInstallFilesGenerator* publicHeaderGenerator = 0;
  369. cmInstallFilesGenerator* resourceGenerator = 0;
  370. // Track whether this is a namelink-only rule.
  371. bool namelinkOnly = false;
  372. switch(target.GetType())
  373. {
  374. case cmTarget::SHARED_LIBRARY:
  375. {
  376. // Shared libraries are handled differently on DLL and non-DLL
  377. // platforms. All windows platforms are DLL platforms including
  378. // cygwin. Currently no other platform is a DLL platform.
  379. if(dll_platform)
  380. {
  381. // When in namelink only mode skip all libraries on Windows.
  382. if(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly)
  383. {
  384. continue;
  385. }
  386. // This is a DLL platform.
  387. if(!archiveArgs.GetDestination().empty())
  388. {
  389. // The import library uses the ARCHIVE properties.
  390. archiveGenerator = CreateInstallTargetGenerator(target,
  391. archiveArgs, true);
  392. }
  393. if(!runtimeArgs.GetDestination().empty())
  394. {
  395. // The DLL uses the RUNTIME properties.
  396. runtimeGenerator = CreateInstallTargetGenerator(target,
  397. runtimeArgs, false);
  398. }
  399. if ((archiveGenerator==0) && (runtimeGenerator==0))
  400. {
  401. this->SetError("Library TARGETS given no DESTINATION!");
  402. return false;
  403. }
  404. }
  405. else
  406. {
  407. // This is a non-DLL platform.
  408. // If it is marked with FRAMEWORK property use the FRAMEWORK set of
  409. // INSTALL properties. Otherwise, use the LIBRARY properties.
  410. if(target.IsFrameworkOnApple())
  411. {
  412. // When in namelink only mode skip frameworks.
  413. if(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly)
  414. {
  415. continue;
  416. }
  417. // Use the FRAMEWORK properties.
  418. if (!frameworkArgs.GetDestination().empty())
  419. {
  420. frameworkGenerator = CreateInstallTargetGenerator(target,
  421. frameworkArgs, false);
  422. }
  423. else
  424. {
  425. cmOStringStream e;
  426. e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
  427. "FRAMEWORK target \"" << target.GetName() << "\".";
  428. this->SetError(e.str().c_str());
  429. return false;
  430. }
  431. }
  432. else
  433. {
  434. // The shared library uses the LIBRARY properties.
  435. if (!libraryArgs.GetDestination().empty())
  436. {
  437. libraryGenerator = CreateInstallTargetGenerator(target,
  438. libraryArgs, false);
  439. libraryGenerator->SetNamelinkMode(namelinkMode);
  440. namelinkOnly =
  441. (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
  442. }
  443. else
  444. {
  445. cmOStringStream e;
  446. e << "TARGETS given no LIBRARY DESTINATION for shared library "
  447. "target \"" << target.GetName() << "\".";
  448. this->SetError(e.str().c_str());
  449. return false;
  450. }
  451. }
  452. }
  453. }
  454. break;
  455. case cmTarget::STATIC_LIBRARY:
  456. {
  457. // Static libraries use ARCHIVE properties.
  458. if (!archiveArgs.GetDestination().empty())
  459. {
  460. archiveGenerator = CreateInstallTargetGenerator(target, archiveArgs,
  461. false);
  462. }
  463. else
  464. {
  465. cmOStringStream e;
  466. e << "TARGETS given no ARCHIVE DESTINATION for static library "
  467. "target \"" << target.GetName() << "\".";
  468. this->SetError(e.str().c_str());
  469. return false;
  470. }
  471. }
  472. break;
  473. case cmTarget::MODULE_LIBRARY:
  474. {
  475. // Modules use LIBRARY properties.
  476. if (!libraryArgs.GetDestination().empty())
  477. {
  478. libraryGenerator = CreateInstallTargetGenerator(target, libraryArgs,
  479. false);
  480. libraryGenerator->SetNamelinkMode(namelinkMode);
  481. namelinkOnly =
  482. (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
  483. }
  484. else
  485. {
  486. cmOStringStream e;
  487. e << "TARGETS given no LIBRARY DESTINATION for module target \""
  488. << target.GetName() << "\".";
  489. this->SetError(e.str().c_str());
  490. return false;
  491. }
  492. }
  493. break;
  494. case cmTarget::EXECUTABLE:
  495. {
  496. if(target.IsAppBundleOnApple())
  497. {
  498. // Application bundles use the BUNDLE properties.
  499. if (!bundleArgs.GetDestination().empty())
  500. {
  501. bundleGenerator = CreateInstallTargetGenerator(target, bundleArgs,
  502. false);
  503. }
  504. else if(!runtimeArgs.GetDestination().empty())
  505. {
  506. bool failure = false;
  507. if(this->CheckCMP0006(failure))
  508. {
  509. // For CMake 2.4 compatibility fallback to the RUNTIME
  510. // properties.
  511. bundleGenerator =
  512. CreateInstallTargetGenerator(target, runtimeArgs, false);
  513. }
  514. else if(failure)
  515. {
  516. return false;
  517. }
  518. }
  519. if(!bundleGenerator)
  520. {
  521. cmOStringStream e;
  522. e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE "
  523. "executable target \"" << target.GetName() << "\".";
  524. this->SetError(e.str().c_str());
  525. return false;
  526. }
  527. }
  528. else
  529. {
  530. // Executables use the RUNTIME properties.
  531. if (!runtimeArgs.GetDestination().empty())
  532. {
  533. runtimeGenerator = CreateInstallTargetGenerator(target,
  534. runtimeArgs, false);
  535. }
  536. else
  537. {
  538. cmOStringStream e;
  539. e << "TARGETS given no RUNTIME DESTINATION for executable "
  540. "target \"" << target.GetName() << "\".";
  541. this->SetError(e.str().c_str());
  542. return false;
  543. }
  544. }
  545. // On DLL platforms an executable may also have an import
  546. // library. Install it to the archive destination if it
  547. // exists.
  548. if(dll_platform && !archiveArgs.GetDestination().empty() &&
  549. target.IsExecutableWithExports())
  550. {
  551. // The import library uses the ARCHIVE properties.
  552. archiveGenerator = CreateInstallTargetGenerator(target,
  553. archiveArgs, true, true);
  554. }
  555. }
  556. break;
  557. default:
  558. // This should never happen due to the above type check.
  559. // Ignore the case.
  560. break;
  561. }
  562. // These well-known sets of files are installed *automatically* for FRAMEWORK
  563. // SHARED library targets on the Mac as part of installing the FRAMEWORK.
  564. // For other target types or on other platforms, they are not installed
  565. // automatically and so we need to create install files generators for them.
  566. //
  567. bool createInstallGeneratorsForTargetFileSets = true;
  568. if(target.IsFrameworkOnApple())
  569. {
  570. createInstallGeneratorsForTargetFileSets = false;
  571. }
  572. if(createInstallGeneratorsForTargetFileSets && !namelinkOnly)
  573. {
  574. const char* files = target.GetProperty("PRIVATE_HEADER");
  575. if ((files) && (*files))
  576. {
  577. std::vector<std::string> relFiles;
  578. cmSystemTools::ExpandListArgument(files, relFiles);
  579. std::vector<std::string> absFiles;
  580. if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles))
  581. {
  582. return false;
  583. }
  584. // Create the files install generator.
  585. if (!privateHeaderArgs.GetDestination().empty())
  586. {
  587. privateHeaderGenerator = CreateInstallFilesGenerator(absFiles,
  588. privateHeaderArgs, false);
  589. }
  590. else
  591. {
  592. cmOStringStream e;
  593. e << "INSTALL TARGETS - target " << target.GetName() << " has "
  594. << "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.";
  595. cmSystemTools::Message(e.str().c_str(), "Warning");
  596. }
  597. }
  598. files = target.GetProperty("PUBLIC_HEADER");
  599. if ((files) && (*files))
  600. {
  601. std::vector<std::string> relFiles;
  602. cmSystemTools::ExpandListArgument(files, relFiles);
  603. std::vector<std::string> absFiles;
  604. if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles))
  605. {
  606. return false;
  607. }
  608. // Create the files install generator.
  609. if (!publicHeaderArgs.GetDestination().empty())
  610. {
  611. publicHeaderGenerator = CreateInstallFilesGenerator(absFiles,
  612. publicHeaderArgs, false);
  613. }
  614. else
  615. {
  616. cmOStringStream e;
  617. e << "INSTALL TARGETS - target " << target.GetName() << " has "
  618. << "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.";
  619. cmSystemTools::Message(e.str().c_str(), "Warning");
  620. }
  621. }
  622. files = target.GetProperty("RESOURCE");
  623. if ((files) && (*files))
  624. {
  625. std::vector<std::string> relFiles;
  626. cmSystemTools::ExpandListArgument(files, relFiles);
  627. std::vector<std::string> absFiles;
  628. if (!this->MakeFilesFullPath("RESOURCE", relFiles, absFiles))
  629. {
  630. return false;
  631. }
  632. // Create the files install generator.
  633. if (!resourceArgs.GetDestination().empty())
  634. {
  635. resourceGenerator = CreateInstallFilesGenerator(absFiles,
  636. resourceArgs, false);
  637. }
  638. else
  639. {
  640. cmOStringStream e;
  641. e << "INSTALL TARGETS - target " << target.GetName() << " has "
  642. << "RESOURCE files but no RESOURCE DESTINATION.";
  643. cmSystemTools::Message(e.str().c_str(), "Warning");
  644. }
  645. }
  646. }
  647. // Keep track of whether we're installing anything in each category
  648. installsArchive = installsArchive || archiveGenerator != 0;
  649. installsLibrary = installsLibrary || libraryGenerator != 0;
  650. installsRuntime = installsRuntime || runtimeGenerator != 0;
  651. installsFramework = installsFramework || frameworkGenerator != 0;
  652. installsBundle = installsBundle || bundleGenerator != 0;
  653. installsPrivateHeader = installsPrivateHeader
  654. || privateHeaderGenerator != 0;
  655. installsPublicHeader = installsPublicHeader || publicHeaderGenerator != 0;
  656. installsResource = installsResource || resourceGenerator;
  657. this->Makefile->AddInstallGenerator(archiveGenerator);
  658. this->Makefile->AddInstallGenerator(libraryGenerator);
  659. this->Makefile->AddInstallGenerator(runtimeGenerator);
  660. this->Makefile->AddInstallGenerator(frameworkGenerator);
  661. this->Makefile->AddInstallGenerator(bundleGenerator);
  662. this->Makefile->AddInstallGenerator(privateHeaderGenerator);
  663. this->Makefile->AddInstallGenerator(publicHeaderGenerator);
  664. this->Makefile->AddInstallGenerator(resourceGenerator);
  665. // Add this install rule to an export if one was specified and
  666. // this is not a namelink-only rule.
  667. if(!exports.GetString().empty() && !namelinkOnly)
  668. {
  669. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  670. ->AddTargetToExports(exports.GetCString(), &target,
  671. archiveGenerator, runtimeGenerator,
  672. libraryGenerator, frameworkGenerator,
  673. bundleGenerator, publicHeaderGenerator);
  674. }
  675. }
  676. // Tell the global generator about any installation component names
  677. // specified
  678. if (installsArchive)
  679. {
  680. this->Makefile->GetLocalGenerator()->
  681. GetGlobalGenerator()
  682. ->AddInstallComponent(archiveArgs.GetComponent().c_str());
  683. }
  684. if (installsLibrary)
  685. {
  686. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  687. ->AddInstallComponent(libraryArgs.GetComponent().c_str());
  688. }
  689. if (installsRuntime)
  690. {
  691. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  692. ->AddInstallComponent(runtimeArgs.GetComponent().c_str());
  693. }
  694. if (installsFramework)
  695. {
  696. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  697. ->AddInstallComponent(frameworkArgs.GetComponent().c_str());
  698. }
  699. if (installsBundle)
  700. {
  701. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  702. ->AddInstallComponent(bundleArgs.GetComponent().c_str());
  703. }
  704. if (installsPrivateHeader)
  705. {
  706. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  707. ->AddInstallComponent(privateHeaderArgs.GetComponent().c_str());
  708. }
  709. if (installsPublicHeader)
  710. {
  711. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  712. ->AddInstallComponent(publicHeaderArgs.GetComponent().c_str());
  713. }
  714. if (installsResource)
  715. {
  716. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  717. ->AddInstallComponent(resourceArgs.GetComponent().c_str());
  718. }
  719. return true;
  720. }
  721. //----------------------------------------------------------------------------
  722. bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
  723. {
  724. // This is the FILES mode.
  725. bool programs = (args[0] == "PROGRAMS");
  726. cmInstallCommandArguments ica;
  727. cmCAStringVector files(&ica.Parser, programs ? "PROGRAMS" : "FILES");
  728. files.Follows(0);
  729. ica.ArgumentGroup.Follows(&files);
  730. std::vector<std::string> unknownArgs;
  731. ica.Parse(&args, &unknownArgs);
  732. if(!unknownArgs.empty())
  733. {
  734. // Unknown argument.
  735. cmOStringStream e;
  736. e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
  737. this->SetError(e.str().c_str());
  738. return false;
  739. }
  740. // Check if there is something to do.
  741. if(files.GetVector().empty())
  742. {
  743. return true;
  744. }
  745. if(!ica.GetRename().empty() && files.GetVector().size() > 1)
  746. {
  747. // The rename option works only with one file.
  748. cmOStringStream e;
  749. e << args[0] << " given RENAME option with more than one file.";
  750. this->SetError(e.str().c_str());
  751. return false;
  752. }
  753. std::vector<std::string> absFiles;
  754. if (!this->MakeFilesFullPath(args[0].c_str(), files.GetVector(), absFiles))
  755. {
  756. return false;
  757. }
  758. if (!ica.Finalize())
  759. {
  760. return false;
  761. }
  762. if(ica.GetDestination().empty())
  763. {
  764. // A destination is required.
  765. cmOStringStream e;
  766. e << args[0] << " given no DESTINATION!";
  767. this->SetError(e.str().c_str());
  768. return false;
  769. }
  770. // Create the files install generator.
  771. this->Makefile->AddInstallGenerator(
  772. CreateInstallFilesGenerator(absFiles, ica, programs));
  773. //Tell the global generator about any installation component names specified.
  774. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  775. ->AddInstallComponent(ica.GetComponent().c_str());
  776. return true;
  777. }
  778. //----------------------------------------------------------------------------
  779. bool
  780. cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
  781. {
  782. enum Doing { DoingNone, DoingDirs, DoingDestination, DoingPattern,
  783. DoingRegex, DoingPermsFile, DoingPermsDir, DoingPermsMatch,
  784. DoingConfigurations, DoingComponent };
  785. Doing doing = DoingDirs;
  786. bool in_match_mode = false;
  787. bool optional = false;
  788. std::vector<std::string> dirs;
  789. const char* destination = 0;
  790. std::string permissions_file;
  791. std::string permissions_dir;
  792. std::vector<std::string> configurations;
  793. std::string component = "Unspecified";
  794. std::string literal_args;
  795. for(unsigned int i=1; i < args.size(); ++i)
  796. {
  797. if(args[i] == "DESTINATION")
  798. {
  799. if(in_match_mode)
  800. {
  801. cmOStringStream e;
  802. e << args[0] << " does not allow \""
  803. << args[i] << "\" after PATTERN or REGEX.";
  804. this->SetError(e.str().c_str());
  805. return false;
  806. }
  807. // Switch to setting the destination property.
  808. doing = DoingDestination;
  809. }
  810. else if(args[i] == "OPTIONAL")
  811. {
  812. if(in_match_mode)
  813. {
  814. cmOStringStream e;
  815. e << args[0] << " does not allow \""
  816. << args[i] << "\" after PATTERN or REGEX.";
  817. this->SetError(e.str().c_str());
  818. return false;
  819. }
  820. // Mark the rule as optional.
  821. optional = true;
  822. doing = DoingNone;
  823. }
  824. else if(args[i] == "PATTERN")
  825. {
  826. // Switch to a new pattern match rule.
  827. doing = DoingPattern;
  828. in_match_mode = true;
  829. }
  830. else if(args[i] == "REGEX")
  831. {
  832. // Switch to a new regex match rule.
  833. doing = DoingRegex;
  834. in_match_mode = true;
  835. }
  836. else if(args[i] == "EXCLUDE")
  837. {
  838. // Add this property to the current match rule.
  839. if(!in_match_mode || doing == DoingPattern || doing == DoingRegex)
  840. {
  841. cmOStringStream e;
  842. e << args[0] << " does not allow \""
  843. << args[i] << "\" before a PATTERN or REGEX is given.";
  844. this->SetError(e.str().c_str());
  845. return false;
  846. }
  847. literal_args += " EXCLUDE";
  848. doing = DoingNone;
  849. }
  850. else if(args[i] == "PERMISSIONS")
  851. {
  852. if(!in_match_mode)
  853. {
  854. cmOStringStream e;
  855. e << args[0] << " does not allow \""
  856. << args[i] << "\" before a PATTERN or REGEX is given.";
  857. this->SetError(e.str().c_str());
  858. return false;
  859. }
  860. // Switch to setting the current match permissions property.
  861. literal_args += " PERMISSIONS";
  862. doing = DoingPermsMatch;
  863. }
  864. else if(args[i] == "FILE_PERMISSIONS")
  865. {
  866. if(in_match_mode)
  867. {
  868. cmOStringStream e;
  869. e << args[0] << " does not allow \""
  870. << args[i] << "\" after PATTERN or REGEX.";
  871. this->SetError(e.str().c_str());
  872. return false;
  873. }
  874. // Switch to setting the file permissions property.
  875. doing = DoingPermsFile;
  876. }
  877. else if(args[i] == "DIRECTORY_PERMISSIONS")
  878. {
  879. if(in_match_mode)
  880. {
  881. cmOStringStream e;
  882. e << args[0] << " does not allow \""
  883. << args[i] << "\" after PATTERN or REGEX.";
  884. this->SetError(e.str().c_str());
  885. return false;
  886. }
  887. // Switch to setting the directory permissions property.
  888. doing = DoingPermsDir;
  889. }
  890. else if(args[i] == "USE_SOURCE_PERMISSIONS")
  891. {
  892. if(in_match_mode)
  893. {
  894. cmOStringStream e;
  895. e << args[0] << " does not allow \""
  896. << args[i] << "\" after PATTERN or REGEX.";
  897. this->SetError(e.str().c_str());
  898. return false;
  899. }
  900. // Add this option literally.
  901. literal_args += " USE_SOURCE_PERMISSIONS";
  902. doing = DoingNone;
  903. }
  904. else if(args[i] == "FILES_MATCHING")
  905. {
  906. if(in_match_mode)
  907. {
  908. cmOStringStream e;
  909. e << args[0] << " does not allow \""
  910. << args[i] << "\" after PATTERN or REGEX.";
  911. this->SetError(e.str().c_str());
  912. return false;
  913. }
  914. // Add this option literally.
  915. literal_args += " FILES_MATCHING";
  916. doing = DoingNone;
  917. }
  918. else if(args[i] == "CONFIGURATIONS")
  919. {
  920. if(in_match_mode)
  921. {
  922. cmOStringStream e;
  923. e << args[0] << " does not allow \""
  924. << args[i] << "\" after PATTERN or REGEX.";
  925. this->SetError(e.str().c_str());
  926. return false;
  927. }
  928. // Switch to setting the configurations property.
  929. doing = DoingConfigurations;
  930. }
  931. else if(args[i] == "COMPONENT")
  932. {
  933. if(in_match_mode)
  934. {
  935. cmOStringStream e;
  936. e << args[0] << " does not allow \""
  937. << args[i] << "\" after PATTERN or REGEX.";
  938. this->SetError(e.str().c_str());
  939. return false;
  940. }
  941. // Switch to setting the component property.
  942. doing = DoingComponent;
  943. }
  944. else if(doing == DoingDirs)
  945. {
  946. // Convert this directory to a full path.
  947. std::string dir = args[i];
  948. if(!cmSystemTools::FileIsFullPath(dir.c_str()))
  949. {
  950. dir = this->Makefile->GetCurrentDirectory();
  951. dir += "/";
  952. dir += args[i];
  953. }
  954. // Make sure the name is a directory.
  955. if(cmSystemTools::FileExists(dir.c_str()) &&
  956. !cmSystemTools::FileIsDirectory(dir.c_str()))
  957. {
  958. cmOStringStream e;
  959. e << args[0] << " given non-directory \""
  960. << args[i] << "\" to install.";
  961. this->SetError(e.str().c_str());
  962. return false;
  963. }
  964. // Store the directory for installation.
  965. dirs.push_back(dir);
  966. }
  967. else if(doing == DoingConfigurations)
  968. {
  969. configurations.push_back(args[i]);
  970. }
  971. else if(doing == DoingDestination)
  972. {
  973. destination = args[i].c_str();
  974. doing = DoingNone;
  975. }
  976. else if(doing == DoingPattern)
  977. {
  978. // Convert the pattern to a regular expression. Require a
  979. // leading slash and trailing end-of-string in the matched
  980. // string to make sure the pattern matches only whole file
  981. // names.
  982. literal_args += " REGEX \"/";
  983. std::string regex = cmsys::Glob::PatternToRegex(args[i], false);
  984. cmSystemTools::ReplaceString(regex, "\\", "\\\\");
  985. literal_args += regex;
  986. literal_args += "$\"";
  987. doing = DoingNone;
  988. }
  989. else if(doing == DoingRegex)
  990. {
  991. literal_args += " REGEX \"";
  992. // Match rules are case-insensitive on some platforms.
  993. #if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
  994. std::string regex = cmSystemTools::LowerCase(args[i]);
  995. #else
  996. std::string regex = args[i];
  997. #endif
  998. cmSystemTools::ReplaceString(regex, "\\", "\\\\");
  999. literal_args += regex;
  1000. literal_args += "\"";
  1001. doing = DoingNone;
  1002. }
  1003. else if(doing == DoingComponent)
  1004. {
  1005. component = args[i];
  1006. doing = DoingNone;
  1007. }
  1008. else if(doing == DoingPermsFile)
  1009. {
  1010. // Check the requested permission.
  1011. if(!cmInstallCommandArguments::CheckPermissions(args[i],permissions_file))
  1012. {
  1013. cmOStringStream e;
  1014. e << args[0] << " given invalid file permission \""
  1015. << args[i] << "\".";
  1016. this->SetError(e.str().c_str());
  1017. return false;
  1018. }
  1019. }
  1020. else if(doing == DoingPermsDir)
  1021. {
  1022. // Check the requested permission.
  1023. if(!cmInstallCommandArguments::CheckPermissions(args[i],permissions_dir))
  1024. {
  1025. cmOStringStream e;
  1026. e << args[0] << " given invalid directory permission \""
  1027. << args[i] << "\".";
  1028. this->SetError(e.str().c_str());
  1029. return false;
  1030. }
  1031. }
  1032. else if(doing == DoingPermsMatch)
  1033. {
  1034. // Check the requested permission.
  1035. if(!cmInstallCommandArguments::CheckPermissions(args[i], literal_args))
  1036. {
  1037. cmOStringStream e;
  1038. e << args[0] << " given invalid permission \""
  1039. << args[i] << "\".";
  1040. this->SetError(e.str().c_str());
  1041. return false;
  1042. }
  1043. }
  1044. else
  1045. {
  1046. // Unknown argument.
  1047. cmOStringStream e;
  1048. e << args[0] << " given unknown argument \"" << args[i] << "\".";
  1049. this->SetError(e.str().c_str());
  1050. return false;
  1051. }
  1052. }
  1053. // Support installing an empty directory.
  1054. if(dirs.empty() && destination)
  1055. {
  1056. dirs.push_back("");
  1057. }
  1058. // Check if there is something to do.
  1059. if(dirs.empty())
  1060. {
  1061. return true;
  1062. }
  1063. if(!destination)
  1064. {
  1065. // A destination is required.
  1066. cmOStringStream e;
  1067. e << args[0] << " given no DESTINATION!";
  1068. this->SetError(e.str().c_str());
  1069. return false;
  1070. }
  1071. // Create the directory install generator.
  1072. this->Makefile->AddInstallGenerator(
  1073. new cmInstallDirectoryGenerator(dirs, destination,
  1074. permissions_file.c_str(),
  1075. permissions_dir.c_str(),
  1076. configurations,
  1077. component.c_str(),
  1078. literal_args.c_str(),
  1079. optional));
  1080. // Tell the global generator about any installation component names
  1081. // specified.
  1082. this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
  1083. ->AddInstallComponent(component.c_str());
  1084. return true;
  1085. }
  1086. //----------------------------------------------------------------------------
  1087. bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
  1088. {
  1089. // This is the EXPORT mode.
  1090. cmInstallCommandArguments ica;
  1091. cmCAString exp(&ica.Parser, "EXPORT");
  1092. cmCAString name_space(&ica.Parser, "NAMESPACE", &ica.ArgumentGroup);
  1093. cmCAString filename(&ica.Parser, "FILE", &ica.ArgumentGroup);
  1094. exp.Follows(0);
  1095. ica.ArgumentGroup.Follows(&exp);
  1096. std::vector<std::string> unknownArgs;
  1097. ica.Parse(&args, &unknownArgs);
  1098. if (!unknownArgs.empty())
  1099. {
  1100. // Unknown argument.
  1101. cmOStringStream e;
  1102. e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
  1103. this->SetError(e.str().c_str());
  1104. return false;
  1105. }
  1106. if (!ica.Finalize())
  1107. {
  1108. return false;
  1109. }
  1110. // Make sure there is a destination.
  1111. if(ica.GetDestination().empty())
  1112. {
  1113. // A destination is required.
  1114. cmOStringStream e;
  1115. e << args[0] << " given no DESTINATION!";
  1116. this->SetError(e.str().c_str());
  1117. return false;
  1118. }
  1119. // Check the file name.
  1120. std::string fname = filename.GetString();
  1121. if(fname.find_first_of(":/\\") != fname.npos)
  1122. {
  1123. cmOStringStream e;
  1124. e << args[0] << " given invalid export file name \"" << fname << "\". "
  1125. << "The FILE argument may not contain a path. "
  1126. << "Specify the path in the DESTINATION argument.";
  1127. this->SetError(e.str().c_str());
  1128. return false;
  1129. }
  1130. // Check the file extension.
  1131. if(!fname.empty() &&
  1132. cmSystemTools::GetFilenameLastExtension(fname) != ".cmake")
  1133. {
  1134. cmOStringStream e;
  1135. e << args[0] << " given invalid export file name \"" << fname << "\". "
  1136. << "The FILE argument must specify a name ending in \".cmake\".";
  1137. this->SetError(e.str().c_str());
  1138. return false;
  1139. }
  1140. // Construct the file name.
  1141. if(fname.empty())
  1142. {
  1143. fname = exp.GetString();
  1144. fname += ".cmake";
  1145. if(fname.find_first_of(":/\\") != fname.npos)
  1146. {
  1147. cmOStringStream e;
  1148. e << args[0] << " given export name \"" << exp.GetString() << "\". "
  1149. << "This name cannot be safely converted to a file name. "
  1150. << "Specify a different export name or use the FILE option to set "
  1151. << "a file name explicitly.";
  1152. this->SetError(e.str().c_str());
  1153. return false;
  1154. }
  1155. }
  1156. // Create the export install generator.
  1157. cmInstallExportGenerator* exportGenerator =
  1158. new cmInstallExportGenerator(
  1159. exp.GetCString(), ica.GetDestination().c_str(),
  1160. ica.GetPermissions().c_str(), ica.GetConfigurations(),
  1161. ica.GetComponent().c_str(), fname.c_str(),
  1162. name_space.GetCString(), this->Makefile);
  1163. this->Makefile->AddInstallGenerator(exportGenerator);
  1164. return true;
  1165. }
  1166. bool cmInstallCommand::MakeFilesFullPath(const char* modeName,
  1167. const std::vector<std::string>& relFiles,
  1168. std::vector<std::string>& absFiles)
  1169. {
  1170. for(std::vector<std::string>::const_iterator fileIt = relFiles.begin();
  1171. fileIt != relFiles.end();
  1172. ++fileIt)
  1173. {
  1174. std::string file = (*fileIt);
  1175. if(!cmSystemTools::FileIsFullPath(file.c_str()))
  1176. {
  1177. file = this->Makefile->GetCurrentDirectory();
  1178. file += "/";
  1179. file += *fileIt;
  1180. }
  1181. // Make sure the file is not a directory.
  1182. if(cmSystemTools::FileIsDirectory(file.c_str()))
  1183. {
  1184. cmOStringStream e;
  1185. e << modeName << " given directory \"" << (*fileIt) << "\" to install.";
  1186. this->SetError(e.str().c_str());
  1187. return false;
  1188. }
  1189. // Store the file for installation.
  1190. absFiles.push_back(file);
  1191. }
  1192. return true;
  1193. }
  1194. //----------------------------------------------------------------------------
  1195. bool cmInstallCommand::CheckCMP0006(bool& failure)
  1196. {
  1197. switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0006))
  1198. {
  1199. case cmPolicies::WARN:
  1200. {
  1201. this->Makefile->IssueMessage(
  1202. cmake::AUTHOR_WARNING,
  1203. this->Makefile->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0006)
  1204. );
  1205. }
  1206. case cmPolicies::OLD:
  1207. // OLD behavior is to allow compatibility
  1208. return true;
  1209. case cmPolicies::NEW:
  1210. // NEW behavior is to disallow compatibility
  1211. break;
  1212. case cmPolicies::REQUIRED_IF_USED:
  1213. case cmPolicies::REQUIRED_ALWAYS:
  1214. failure = true;
  1215. this->Makefile->IssueMessage(
  1216. cmake::FATAL_ERROR,
  1217. this->Makefile->GetPolicies()
  1218. ->GetRequiredPolicyError(cmPolicies::CMP0006)
  1219. );
  1220. break;
  1221. }
  1222. return false;
  1223. }