cmInstallCommand.cxx 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmInstallCommand.h"
  4. #include "cm_static_string_view.hxx"
  5. #include "cmsys/Glob.hxx"
  6. #include <set>
  7. #include <sstream>
  8. #include <stddef.h>
  9. #include <utility>
  10. #include "cmAlgorithms.h"
  11. #include "cmArgumentParser.h"
  12. #include "cmExportSet.h"
  13. #include "cmExportSetMap.h"
  14. #include "cmGeneratorExpression.h"
  15. #include "cmGlobalGenerator.h"
  16. #include "cmInstallCommandArguments.h"
  17. #include "cmInstallDirectoryGenerator.h"
  18. #include "cmInstallExportGenerator.h"
  19. #include "cmInstallFilesGenerator.h"
  20. #include "cmInstallGenerator.h"
  21. #include "cmInstallScriptGenerator.h"
  22. #include "cmInstallTargetGenerator.h"
  23. #include "cmListFileCache.h"
  24. #include "cmMakefile.h"
  25. #include "cmMessageType.h"
  26. #include "cmPolicies.h"
  27. #include "cmStateTypes.h"
  28. #include "cmSystemTools.h"
  29. #include "cmTarget.h"
  30. #include "cmTargetExport.h"
  31. class cmExecutionStatus;
  32. static cmInstallTargetGenerator* CreateInstallTargetGenerator(
  33. cmTarget& target, const cmInstallCommandArguments& args, bool impLib,
  34. cmListFileBacktrace const& backtrace, const std::string& destination,
  35. bool forceOpt = false, bool namelink = false)
  36. {
  37. cmInstallGenerator::MessageLevel message =
  38. cmInstallGenerator::SelectMessageLevel(target.GetMakefile());
  39. target.SetHaveInstallRule(true);
  40. const char* component = namelink ? args.GetNamelinkComponent().c_str()
  41. : args.GetComponent().c_str();
  42. auto g = new cmInstallTargetGenerator(
  43. target.GetName(), destination.c_str(), impLib,
  44. args.GetPermissions().c_str(), args.GetConfigurations(), component,
  45. message, args.GetExcludeFromAll(), args.GetOptional() || forceOpt,
  46. backtrace);
  47. target.AddInstallGenerator(g);
  48. return g;
  49. }
  50. static cmInstallTargetGenerator* CreateInstallTargetGenerator(
  51. cmTarget& target, const cmInstallCommandArguments& args, bool impLib,
  52. cmListFileBacktrace const& backtrace, bool forceOpt = false,
  53. bool namelink = false)
  54. {
  55. return CreateInstallTargetGenerator(target, args, impLib, backtrace,
  56. args.GetDestination(), forceOpt,
  57. namelink);
  58. }
  59. static cmInstallFilesGenerator* CreateInstallFilesGenerator(
  60. cmMakefile* mf, const std::vector<std::string>& absFiles,
  61. const cmInstallCommandArguments& args, bool programs,
  62. const std::string& destination)
  63. {
  64. cmInstallGenerator::MessageLevel message =
  65. cmInstallGenerator::SelectMessageLevel(mf);
  66. return new cmInstallFilesGenerator(
  67. absFiles, destination.c_str(), programs, args.GetPermissions().c_str(),
  68. args.GetConfigurations(), args.GetComponent().c_str(), message,
  69. args.GetExcludeFromAll(), args.GetRename().c_str(), args.GetOptional());
  70. }
  71. static cmInstallFilesGenerator* CreateInstallFilesGenerator(
  72. cmMakefile* mf, const std::vector<std::string>& absFiles,
  73. const cmInstallCommandArguments& args, bool programs)
  74. {
  75. return CreateInstallFilesGenerator(mf, absFiles, args, programs,
  76. args.GetDestination());
  77. }
  78. static const std::set<std::string> allowedTypes{
  79. "BIN", "SBIN", "LIB", "INCLUDE", "SYSCONF",
  80. "SHAREDSTATE", "LOCALSTATE", "RUNSTATE", "DATA", "INFO",
  81. "LOCALE", "MAN", "DOC",
  82. };
  83. // cmInstallCommand
  84. bool cmInstallCommand::InitialPass(std::vector<std::string> const& args,
  85. cmExecutionStatus&)
  86. {
  87. // Allow calling with no arguments so that arguments may be built up
  88. // using a variable that may be left empty.
  89. if (args.empty()) {
  90. return true;
  91. }
  92. // Enable the install target.
  93. this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
  94. this->DefaultComponentName =
  95. this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME");
  96. if (this->DefaultComponentName.empty()) {
  97. this->DefaultComponentName = "Unspecified";
  98. }
  99. std::string const& mode = args[0];
  100. // Switch among the command modes.
  101. if (mode == "SCRIPT") {
  102. return this->HandleScriptMode(args);
  103. }
  104. if (mode == "CODE") {
  105. return this->HandleScriptMode(args);
  106. }
  107. if (mode == "TARGETS") {
  108. return this->HandleTargetsMode(args);
  109. }
  110. if (mode == "FILES") {
  111. return this->HandleFilesMode(args);
  112. }
  113. if (mode == "PROGRAMS") {
  114. return this->HandleFilesMode(args);
  115. }
  116. if (mode == "DIRECTORY") {
  117. return this->HandleDirectoryMode(args);
  118. }
  119. if (mode == "EXPORT") {
  120. return this->HandleExportMode(args);
  121. }
  122. if (mode == "EXPORT_ANDROID_MK") {
  123. return this->HandleExportAndroidMKMode(args);
  124. }
  125. // Unknown mode.
  126. std::string e = "called with unknown mode ";
  127. e += args[0];
  128. this->SetError(e);
  129. return false;
  130. }
  131. bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
  132. {
  133. std::string component = this->DefaultComponentName;
  134. int componentCount = 0;
  135. bool doing_script = false;
  136. bool doing_code = false;
  137. bool exclude_from_all = false;
  138. // Scan the args once for COMPONENT. Only allow one.
  139. //
  140. for (size_t i = 0; i < args.size(); ++i) {
  141. if (args[i] == "COMPONENT" && i + 1 < args.size()) {
  142. ++componentCount;
  143. ++i;
  144. component = args[i];
  145. }
  146. if (args[i] == "EXCLUDE_FROM_ALL") {
  147. exclude_from_all = true;
  148. }
  149. }
  150. if (componentCount > 1) {
  151. this->SetError("given more than one COMPONENT for the SCRIPT or CODE "
  152. "signature of the INSTALL command. "
  153. "Use multiple INSTALL commands with one COMPONENT each.");
  154. return false;
  155. }
  156. // Scan the args again, this time adding install generators each time we
  157. // encounter a SCRIPT or CODE arg:
  158. //
  159. for (std::string const& arg : args) {
  160. if (arg == "SCRIPT") {
  161. doing_script = true;
  162. doing_code = false;
  163. } else if (arg == "CODE") {
  164. doing_script = false;
  165. doing_code = true;
  166. } else if (arg == "COMPONENT") {
  167. doing_script = false;
  168. doing_code = false;
  169. } else if (doing_script) {
  170. doing_script = false;
  171. std::string script = arg;
  172. if (!cmSystemTools::FileIsFullPath(script)) {
  173. script = this->Makefile->GetCurrentSourceDirectory();
  174. script += "/";
  175. script += arg;
  176. }
  177. if (cmSystemTools::FileIsDirectory(script)) {
  178. this->SetError("given a directory as value of SCRIPT argument.");
  179. return false;
  180. }
  181. this->Makefile->AddInstallGenerator(new cmInstallScriptGenerator(
  182. script.c_str(), false, component.c_str(), exclude_from_all));
  183. } else if (doing_code) {
  184. doing_code = false;
  185. std::string const& code = arg;
  186. this->Makefile->AddInstallGenerator(new cmInstallScriptGenerator(
  187. code.c_str(), true, component.c_str(), exclude_from_all));
  188. }
  189. }
  190. if (doing_script) {
  191. this->SetError("given no value for SCRIPT argument.");
  192. return false;
  193. }
  194. if (doing_code) {
  195. this->SetError("given no value for CODE argument.");
  196. return false;
  197. }
  198. // Tell the global generator about any installation component names
  199. // specified.
  200. this->Makefile->GetGlobalGenerator()->AddInstallComponent(component);
  201. return true;
  202. }
  203. bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
  204. {
  205. // This is the TARGETS mode.
  206. std::vector<cmTarget*> targets;
  207. struct ArgVectors
  208. {
  209. std::vector<std::string> Archive;
  210. std::vector<std::string> Library;
  211. std::vector<std::string> Runtime;
  212. std::vector<std::string> Object;
  213. std::vector<std::string> Framework;
  214. std::vector<std::string> Bundle;
  215. std::vector<std::string> Includes;
  216. std::vector<std::string> PrivateHeader;
  217. std::vector<std::string> PublicHeader;
  218. std::vector<std::string> Resource;
  219. };
  220. static auto const argHelper =
  221. cmArgumentParser<ArgVectors>{}
  222. .Bind("ARCHIVE"_s, &ArgVectors::Archive)
  223. .Bind("LIBRARY"_s, &ArgVectors::Library)
  224. .Bind("RUNTIME"_s, &ArgVectors::Runtime)
  225. .Bind("OBJECTS"_s, &ArgVectors::Object)
  226. .Bind("FRAMEWORK"_s, &ArgVectors::Framework)
  227. .Bind("BUNDLE"_s, &ArgVectors::Bundle)
  228. .Bind("INCLUDES"_s, &ArgVectors::Includes)
  229. .Bind("PRIVATE_HEADER"_s, &ArgVectors::PrivateHeader)
  230. .Bind("PUBLIC_HEADER"_s, &ArgVectors::PublicHeader)
  231. .Bind("RESOURCE"_s, &ArgVectors::Resource);
  232. std::vector<std::string> genericArgVector;
  233. ArgVectors const argVectors = argHelper.Parse(args, &genericArgVector);
  234. // now parse the generic args (i.e. the ones not specialized on LIBRARY/
  235. // ARCHIVE, RUNTIME etc. (see above)
  236. // These generic args also contain the targets and the export stuff
  237. std::vector<std::string> targetList;
  238. std::string exports;
  239. std::vector<std::string> unknownArgs;
  240. cmInstallCommandArguments genericArgs(this->DefaultComponentName);
  241. genericArgs.Bind("TARGETS"_s, targetList);
  242. genericArgs.Bind("EXPORT"_s, exports);
  243. genericArgs.Parse(genericArgVector, &unknownArgs);
  244. bool success = genericArgs.Finalize();
  245. cmInstallCommandArguments archiveArgs(this->DefaultComponentName);
  246. cmInstallCommandArguments libraryArgs(this->DefaultComponentName);
  247. cmInstallCommandArguments runtimeArgs(this->DefaultComponentName);
  248. cmInstallCommandArguments objectArgs(this->DefaultComponentName);
  249. cmInstallCommandArguments frameworkArgs(this->DefaultComponentName);
  250. cmInstallCommandArguments bundleArgs(this->DefaultComponentName);
  251. cmInstallCommandArguments privateHeaderArgs(this->DefaultComponentName);
  252. cmInstallCommandArguments publicHeaderArgs(this->DefaultComponentName);
  253. cmInstallCommandArguments resourceArgs(this->DefaultComponentName);
  254. cmInstallCommandIncludesArgument includesArgs;
  255. // now parse the args for specific parts of the target (e.g. LIBRARY,
  256. // RUNTIME, ARCHIVE etc.
  257. archiveArgs.Parse(argVectors.Archive, &unknownArgs);
  258. libraryArgs.Parse(argVectors.Library, &unknownArgs);
  259. runtimeArgs.Parse(argVectors.Runtime, &unknownArgs);
  260. objectArgs.Parse(argVectors.Object, &unknownArgs);
  261. frameworkArgs.Parse(argVectors.Framework, &unknownArgs);
  262. bundleArgs.Parse(argVectors.Bundle, &unknownArgs);
  263. privateHeaderArgs.Parse(argVectors.PrivateHeader, &unknownArgs);
  264. publicHeaderArgs.Parse(argVectors.PublicHeader, &unknownArgs);
  265. resourceArgs.Parse(argVectors.Resource, &unknownArgs);
  266. includesArgs.Parse(&argVectors.Includes, &unknownArgs);
  267. if (!unknownArgs.empty()) {
  268. // Unknown argument.
  269. std::ostringstream e;
  270. e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\".";
  271. this->SetError(e.str());
  272. return false;
  273. }
  274. // apply generic args
  275. archiveArgs.SetGenericArguments(&genericArgs);
  276. libraryArgs.SetGenericArguments(&genericArgs);
  277. runtimeArgs.SetGenericArguments(&genericArgs);
  278. objectArgs.SetGenericArguments(&genericArgs);
  279. frameworkArgs.SetGenericArguments(&genericArgs);
  280. bundleArgs.SetGenericArguments(&genericArgs);
  281. privateHeaderArgs.SetGenericArguments(&genericArgs);
  282. publicHeaderArgs.SetGenericArguments(&genericArgs);
  283. resourceArgs.SetGenericArguments(&genericArgs);
  284. success = success && archiveArgs.Finalize();
  285. success = success && libraryArgs.Finalize();
  286. success = success && runtimeArgs.Finalize();
  287. success = success && objectArgs.Finalize();
  288. success = success && frameworkArgs.Finalize();
  289. success = success && bundleArgs.Finalize();
  290. success = success && privateHeaderArgs.Finalize();
  291. success = success && publicHeaderArgs.Finalize();
  292. success = success && resourceArgs.Finalize();
  293. if (!success) {
  294. return false;
  295. }
  296. // Enforce argument rules too complex to specify for the
  297. // general-purpose parser.
  298. if (archiveArgs.GetNamelinkOnly() || runtimeArgs.GetNamelinkOnly() ||
  299. objectArgs.GetNamelinkOnly() || frameworkArgs.GetNamelinkOnly() ||
  300. bundleArgs.GetNamelinkOnly() || privateHeaderArgs.GetNamelinkOnly() ||
  301. publicHeaderArgs.GetNamelinkOnly() || resourceArgs.GetNamelinkOnly()) {
  302. this->SetError(
  303. "TARGETS given NAMELINK_ONLY option not in LIBRARY group. "
  304. "The NAMELINK_ONLY option may be specified only following LIBRARY.");
  305. return false;
  306. }
  307. if (archiveArgs.GetNamelinkSkip() || runtimeArgs.GetNamelinkSkip() ||
  308. objectArgs.GetNamelinkSkip() || frameworkArgs.GetNamelinkSkip() ||
  309. bundleArgs.GetNamelinkSkip() || privateHeaderArgs.GetNamelinkSkip() ||
  310. publicHeaderArgs.GetNamelinkSkip() || resourceArgs.GetNamelinkSkip()) {
  311. this->SetError(
  312. "TARGETS given NAMELINK_SKIP option not in LIBRARY group. "
  313. "The NAMELINK_SKIP option may be specified only following LIBRARY.");
  314. return false;
  315. }
  316. if (archiveArgs.HasNamelinkComponent() ||
  317. runtimeArgs.HasNamelinkComponent() ||
  318. objectArgs.HasNamelinkComponent() ||
  319. frameworkArgs.HasNamelinkComponent() ||
  320. bundleArgs.HasNamelinkComponent() ||
  321. privateHeaderArgs.HasNamelinkComponent() ||
  322. publicHeaderArgs.HasNamelinkComponent() ||
  323. resourceArgs.HasNamelinkComponent()) {
  324. this->SetError(
  325. "TARGETS given NAMELINK_COMPONENT option not in LIBRARY group. "
  326. "The NAMELINK_COMPONENT option may be specified only following "
  327. "LIBRARY.");
  328. return false;
  329. }
  330. if (libraryArgs.GetNamelinkOnly() && libraryArgs.GetNamelinkSkip()) {
  331. this->SetError("TARGETS given NAMELINK_ONLY and NAMELINK_SKIP. "
  332. "At most one of these two options may be specified.");
  333. return false;
  334. }
  335. if (!genericArgs.GetType().empty() || !archiveArgs.GetType().empty() ||
  336. !libraryArgs.GetType().empty() || !runtimeArgs.GetType().empty() ||
  337. !objectArgs.GetType().empty() || !frameworkArgs.GetType().empty() ||
  338. !bundleArgs.GetType().empty() || !privateHeaderArgs.GetType().empty() ||
  339. !publicHeaderArgs.GetType().empty() || !resourceArgs.GetType().empty()) {
  340. std::ostringstream e;
  341. e << "TARGETS given TYPE option. The TYPE option may only be specified in "
  342. " install(FILES) and install(DIRECTORIES).";
  343. this->SetError(e.str());
  344. return false;
  345. }
  346. // Select the mode for installing symlinks to versioned shared libraries.
  347. cmInstallTargetGenerator::NamelinkModeType namelinkMode =
  348. cmInstallTargetGenerator::NamelinkModeNone;
  349. if (libraryArgs.GetNamelinkOnly()) {
  350. namelinkMode = cmInstallTargetGenerator::NamelinkModeOnly;
  351. } else if (libraryArgs.GetNamelinkSkip()) {
  352. namelinkMode = cmInstallTargetGenerator::NamelinkModeSkip;
  353. }
  354. // Check if there is something to do.
  355. if (targetList.empty()) {
  356. return true;
  357. }
  358. // Check whether this is a DLL platform.
  359. bool dll_platform =
  360. !this->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty();
  361. for (std::string const& tgt : targetList) {
  362. if (this->Makefile->IsAlias(tgt)) {
  363. std::ostringstream e;
  364. e << "TARGETS given target \"" << tgt << "\" which is an alias.";
  365. this->SetError(e.str());
  366. return false;
  367. }
  368. // Lookup this target in the current directory.
  369. cmTarget* target = this->Makefile->FindLocalNonAliasTarget(tgt);
  370. if (!target) {
  371. // If no local target has been found, find it in the global scope.
  372. cmTarget* const global_target =
  373. this->Makefile->GetGlobalGenerator()->FindTarget(tgt, true);
  374. if (global_target && !global_target->IsImported()) {
  375. target = global_target;
  376. }
  377. }
  378. if (target) {
  379. // Found the target. Check its type.
  380. if (target->GetType() != cmStateEnums::EXECUTABLE &&
  381. target->GetType() != cmStateEnums::STATIC_LIBRARY &&
  382. target->GetType() != cmStateEnums::SHARED_LIBRARY &&
  383. target->GetType() != cmStateEnums::MODULE_LIBRARY &&
  384. target->GetType() != cmStateEnums::OBJECT_LIBRARY &&
  385. target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
  386. std::ostringstream e;
  387. e << "TARGETS given target \"" << tgt
  388. << "\" which is not an executable, library, or module.";
  389. this->SetError(e.str());
  390. return false;
  391. }
  392. // Store the target in the list to be installed.
  393. targets.push_back(target);
  394. } else {
  395. // Did not find the target.
  396. std::ostringstream e;
  397. e << "TARGETS given target \"" << tgt << "\" which does not exist.";
  398. this->SetError(e.str());
  399. return false;
  400. }
  401. }
  402. // Keep track of whether we will be performing an installation of
  403. // any files of the given type.
  404. bool installsArchive = false;
  405. bool installsLibrary = false;
  406. bool installsNamelink = false;
  407. bool installsRuntime = false;
  408. bool installsObject = false;
  409. bool installsFramework = false;
  410. bool installsBundle = false;
  411. bool installsPrivateHeader = false;
  412. bool installsPublicHeader = false;
  413. bool installsResource = false;
  414. // Generate install script code to install the given targets.
  415. for (cmTarget* ti : targets) {
  416. // Handle each target type.
  417. cmTarget& target = *ti;
  418. cmInstallTargetGenerator* archiveGenerator = nullptr;
  419. cmInstallTargetGenerator* libraryGenerator = nullptr;
  420. cmInstallTargetGenerator* namelinkGenerator = nullptr;
  421. cmInstallTargetGenerator* runtimeGenerator = nullptr;
  422. cmInstallTargetGenerator* objectGenerator = nullptr;
  423. cmInstallTargetGenerator* frameworkGenerator = nullptr;
  424. cmInstallTargetGenerator* bundleGenerator = nullptr;
  425. cmInstallFilesGenerator* privateHeaderGenerator = nullptr;
  426. cmInstallFilesGenerator* publicHeaderGenerator = nullptr;
  427. cmInstallFilesGenerator* resourceGenerator = nullptr;
  428. // Avoid selecting default destinations for PUBLIC_HEADER and
  429. // PRIVATE_HEADER if any artifacts are specified.
  430. bool artifactsSpecified = false;
  431. // Track whether this is a namelink-only rule.
  432. bool namelinkOnly = false;
  433. switch (target.GetType()) {
  434. case cmStateEnums::SHARED_LIBRARY: {
  435. // Shared libraries are handled differently on DLL and non-DLL
  436. // platforms. All windows platforms are DLL platforms including
  437. // cygwin. Currently no other platform is a DLL platform.
  438. if (dll_platform) {
  439. // When in namelink only mode skip all libraries on Windows.
  440. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) {
  441. continue;
  442. }
  443. // This is a DLL platform.
  444. if (!archiveArgs.GetDestination().empty()) {
  445. // The import library uses the ARCHIVE properties.
  446. archiveGenerator = CreateInstallTargetGenerator(
  447. target, archiveArgs, true, this->Makefile->GetBacktrace());
  448. artifactsSpecified = true;
  449. }
  450. if (!runtimeArgs.GetDestination().empty()) {
  451. // The DLL uses the RUNTIME properties.
  452. runtimeGenerator = CreateInstallTargetGenerator(
  453. target, runtimeArgs, false, this->Makefile->GetBacktrace());
  454. artifactsSpecified = true;
  455. }
  456. if ((archiveGenerator == nullptr) && (runtimeGenerator == nullptr)) {
  457. archiveGenerator = CreateInstallTargetGenerator(
  458. target, archiveArgs, true, this->Makefile->GetBacktrace(),
  459. this->GetArchiveDestination(nullptr));
  460. runtimeGenerator = CreateInstallTargetGenerator(
  461. target, runtimeArgs, false, this->Makefile->GetBacktrace(),
  462. this->GetRuntimeDestination(nullptr));
  463. }
  464. } else {
  465. // This is a non-DLL platform.
  466. // If it is marked with FRAMEWORK property use the FRAMEWORK set of
  467. // INSTALL properties. Otherwise, use the LIBRARY properties.
  468. if (target.IsFrameworkOnApple()) {
  469. // When in namelink only mode skip frameworks.
  470. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) {
  471. continue;
  472. }
  473. // Use the FRAMEWORK properties.
  474. if (!frameworkArgs.GetDestination().empty()) {
  475. frameworkGenerator = CreateInstallTargetGenerator(
  476. target, frameworkArgs, false, this->Makefile->GetBacktrace());
  477. } else {
  478. std::ostringstream e;
  479. e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
  480. "FRAMEWORK target \""
  481. << target.GetName() << "\".";
  482. this->SetError(e.str());
  483. return false;
  484. }
  485. } else {
  486. // The shared library uses the LIBRARY properties.
  487. if (!libraryArgs.GetDestination().empty()) {
  488. artifactsSpecified = true;
  489. }
  490. if (namelinkMode != cmInstallTargetGenerator::NamelinkModeOnly) {
  491. libraryGenerator = CreateInstallTargetGenerator(
  492. target, libraryArgs, false, this->Makefile->GetBacktrace(),
  493. this->GetLibraryDestination(&libraryArgs));
  494. libraryGenerator->SetNamelinkMode(
  495. cmInstallTargetGenerator::NamelinkModeSkip);
  496. }
  497. if (namelinkMode != cmInstallTargetGenerator::NamelinkModeSkip) {
  498. namelinkGenerator = CreateInstallTargetGenerator(
  499. target, libraryArgs, false, this->Makefile->GetBacktrace(),
  500. this->GetLibraryDestination(&libraryArgs), false, true);
  501. namelinkGenerator->SetNamelinkMode(
  502. cmInstallTargetGenerator::NamelinkModeOnly);
  503. }
  504. namelinkOnly =
  505. (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
  506. }
  507. }
  508. } break;
  509. case cmStateEnums::STATIC_LIBRARY: {
  510. // If it is marked with FRAMEWORK property use the FRAMEWORK set of
  511. // INSTALL properties. Otherwise, use the LIBRARY properties.
  512. if (target.IsFrameworkOnApple()) {
  513. // When in namelink only mode skip frameworks.
  514. if (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly) {
  515. continue;
  516. }
  517. // Use the FRAMEWORK properties.
  518. if (!frameworkArgs.GetDestination().empty()) {
  519. frameworkGenerator = CreateInstallTargetGenerator(
  520. target, frameworkArgs, false, this->Makefile->GetBacktrace());
  521. } else {
  522. std::ostringstream e;
  523. e << "TARGETS given no FRAMEWORK DESTINATION for static library "
  524. "FRAMEWORK target \""
  525. << target.GetName() << "\".";
  526. this->SetError(e.str());
  527. return false;
  528. }
  529. } else {
  530. // Static libraries use ARCHIVE properties.
  531. if (!archiveArgs.GetDestination().empty()) {
  532. artifactsSpecified = true;
  533. }
  534. archiveGenerator = CreateInstallTargetGenerator(
  535. target, archiveArgs, false, this->Makefile->GetBacktrace(),
  536. this->GetArchiveDestination(&archiveArgs));
  537. }
  538. } break;
  539. case cmStateEnums::MODULE_LIBRARY: {
  540. // Modules use LIBRARY properties.
  541. if (!libraryArgs.GetDestination().empty()) {
  542. libraryGenerator = CreateInstallTargetGenerator(
  543. target, libraryArgs, false, this->Makefile->GetBacktrace());
  544. libraryGenerator->SetNamelinkMode(namelinkMode);
  545. namelinkOnly =
  546. (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
  547. } else {
  548. std::ostringstream e;
  549. e << "TARGETS given no LIBRARY DESTINATION for module target \""
  550. << target.GetName() << "\".";
  551. this->SetError(e.str());
  552. return false;
  553. }
  554. } break;
  555. case cmStateEnums::OBJECT_LIBRARY: {
  556. // Objects use OBJECT properties.
  557. if (!objectArgs.GetDestination().empty()) {
  558. // Verify that we know where the objects are to install them.
  559. std::string reason;
  560. if (!this->Makefile->GetGlobalGenerator()
  561. ->HasKnownObjectFileLocation(&reason)) {
  562. std::ostringstream e;
  563. e << "TARGETS given OBJECT library \"" << target.GetName()
  564. << "\" whose objects may not be installed" << reason << ".";
  565. this->SetError(e.str());
  566. return false;
  567. }
  568. objectGenerator = CreateInstallTargetGenerator(
  569. target, objectArgs, false, this->Makefile->GetBacktrace());
  570. } else {
  571. // Installing an OBJECT library without a destination transforms
  572. // it to an INTERFACE library. It installs no files but can be
  573. // exported.
  574. }
  575. } break;
  576. case cmStateEnums::EXECUTABLE: {
  577. if (target.IsAppBundleOnApple()) {
  578. // Application bundles use the BUNDLE properties.
  579. if (!bundleArgs.GetDestination().empty()) {
  580. bundleGenerator = CreateInstallTargetGenerator(
  581. target, bundleArgs, false, this->Makefile->GetBacktrace());
  582. } else if (!runtimeArgs.GetDestination().empty()) {
  583. bool failure = false;
  584. if (this->CheckCMP0006(failure)) {
  585. // For CMake 2.4 compatibility fallback to the RUNTIME
  586. // properties.
  587. bundleGenerator = CreateInstallTargetGenerator(
  588. target, runtimeArgs, false, this->Makefile->GetBacktrace());
  589. } else if (failure) {
  590. return false;
  591. }
  592. }
  593. if (!bundleGenerator) {
  594. std::ostringstream e;
  595. e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE "
  596. "executable target \""
  597. << target.GetName() << "\".";
  598. this->SetError(e.str());
  599. return false;
  600. }
  601. } else {
  602. // Executables use the RUNTIME properties.
  603. if (!runtimeArgs.GetDestination().empty()) {
  604. artifactsSpecified = true;
  605. }
  606. runtimeGenerator = CreateInstallTargetGenerator(
  607. target, runtimeArgs, false, this->Makefile->GetBacktrace(),
  608. this->GetRuntimeDestination(&runtimeArgs));
  609. }
  610. // On DLL platforms an executable may also have an import
  611. // library. Install it to the archive destination if it
  612. // exists.
  613. if (dll_platform && !archiveArgs.GetDestination().empty() &&
  614. target.IsExecutableWithExports()) {
  615. // The import library uses the ARCHIVE properties.
  616. artifactsSpecified = true;
  617. archiveGenerator = CreateInstallTargetGenerator(
  618. target, archiveArgs, true, this->Makefile->GetBacktrace(), true);
  619. }
  620. } break;
  621. case cmStateEnums::INTERFACE_LIBRARY:
  622. // Nothing to do. An INTERFACE_LIBRARY can be installed, but the
  623. // only effect of that is to make it exportable. It installs no
  624. // other files itself.
  625. break;
  626. default:
  627. // This should never happen due to the above type check.
  628. // Ignore the case.
  629. break;
  630. }
  631. // These well-known sets of files are installed *automatically* for
  632. // FRAMEWORK SHARED library targets on the Mac as part of installing the
  633. // FRAMEWORK. For other target types or on other platforms, they are not
  634. // installed automatically and so we need to create install files
  635. // generators for them.
  636. bool createInstallGeneratorsForTargetFileSets = true;
  637. if (target.IsFrameworkOnApple()) {
  638. createInstallGeneratorsForTargetFileSets = false;
  639. }
  640. if (createInstallGeneratorsForTargetFileSets && !namelinkOnly) {
  641. const char* files = target.GetProperty("PRIVATE_HEADER");
  642. if ((files) && (*files)) {
  643. std::vector<std::string> relFiles;
  644. cmSystemTools::ExpandListArgument(files, relFiles);
  645. std::vector<std::string> absFiles;
  646. if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles)) {
  647. return false;
  648. }
  649. // Create the files install generator.
  650. if (!artifactsSpecified ||
  651. !privateHeaderArgs.GetDestination().empty()) {
  652. privateHeaderGenerator = CreateInstallFilesGenerator(
  653. this->Makefile, absFiles, privateHeaderArgs, false,
  654. this->GetIncludeDestination(&privateHeaderArgs));
  655. } else {
  656. std::ostringstream e;
  657. e << "INSTALL TARGETS - target " << target.GetName() << " has "
  658. << "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.";
  659. cmSystemTools::Message(e.str(), "Warning");
  660. }
  661. }
  662. files = target.GetProperty("PUBLIC_HEADER");
  663. if ((files) && (*files)) {
  664. std::vector<std::string> relFiles;
  665. cmSystemTools::ExpandListArgument(files, relFiles);
  666. std::vector<std::string> absFiles;
  667. if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles)) {
  668. return false;
  669. }
  670. // Create the files install generator.
  671. if (!artifactsSpecified ||
  672. !publicHeaderArgs.GetDestination().empty()) {
  673. publicHeaderGenerator = CreateInstallFilesGenerator(
  674. this->Makefile, absFiles, publicHeaderArgs, false,
  675. this->GetIncludeDestination(&publicHeaderArgs));
  676. } else {
  677. std::ostringstream e;
  678. e << "INSTALL TARGETS - target " << target.GetName() << " has "
  679. << "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.";
  680. cmSystemTools::Message(e.str(), "Warning");
  681. }
  682. }
  683. files = target.GetProperty("RESOURCE");
  684. if ((files) && (*files)) {
  685. std::vector<std::string> relFiles;
  686. cmSystemTools::ExpandListArgument(files, relFiles);
  687. std::vector<std::string> absFiles;
  688. if (!this->MakeFilesFullPath("RESOURCE", relFiles, absFiles)) {
  689. return false;
  690. }
  691. // Create the files install generator.
  692. if (!resourceArgs.GetDestination().empty()) {
  693. resourceGenerator = CreateInstallFilesGenerator(
  694. this->Makefile, absFiles, resourceArgs, false);
  695. } else {
  696. std::ostringstream e;
  697. e << "INSTALL TARGETS - target " << target.GetName() << " has "
  698. << "RESOURCE files but no RESOURCE DESTINATION.";
  699. cmSystemTools::Message(e.str(), "Warning");
  700. }
  701. }
  702. }
  703. // Keep track of whether we're installing anything in each category
  704. installsArchive = installsArchive || archiveGenerator != nullptr;
  705. installsLibrary = installsLibrary || libraryGenerator != nullptr;
  706. installsNamelink = installsNamelink || namelinkGenerator != nullptr;
  707. installsRuntime = installsRuntime || runtimeGenerator != nullptr;
  708. installsObject = installsObject || objectGenerator != nullptr;
  709. installsFramework = installsFramework || frameworkGenerator != nullptr;
  710. installsBundle = installsBundle || bundleGenerator != nullptr;
  711. installsPrivateHeader =
  712. installsPrivateHeader || privateHeaderGenerator != nullptr;
  713. installsPublicHeader =
  714. installsPublicHeader || publicHeaderGenerator != nullptr;
  715. installsResource = installsResource || resourceGenerator;
  716. this->Makefile->AddInstallGenerator(archiveGenerator);
  717. this->Makefile->AddInstallGenerator(libraryGenerator);
  718. this->Makefile->AddInstallGenerator(namelinkGenerator);
  719. this->Makefile->AddInstallGenerator(runtimeGenerator);
  720. this->Makefile->AddInstallGenerator(objectGenerator);
  721. this->Makefile->AddInstallGenerator(frameworkGenerator);
  722. this->Makefile->AddInstallGenerator(bundleGenerator);
  723. this->Makefile->AddInstallGenerator(privateHeaderGenerator);
  724. this->Makefile->AddInstallGenerator(publicHeaderGenerator);
  725. this->Makefile->AddInstallGenerator(resourceGenerator);
  726. // Add this install rule to an export if one was specified and
  727. // this is not a namelink-only rule.
  728. if (!exports.empty() && !namelinkOnly) {
  729. cmTargetExport* te = new cmTargetExport;
  730. te->TargetName = target.GetName();
  731. te->ArchiveGenerator = archiveGenerator;
  732. te->BundleGenerator = bundleGenerator;
  733. te->FrameworkGenerator = frameworkGenerator;
  734. te->HeaderGenerator = publicHeaderGenerator;
  735. te->LibraryGenerator = libraryGenerator;
  736. te->RuntimeGenerator = runtimeGenerator;
  737. te->ObjectsGenerator = objectGenerator;
  738. this->Makefile->GetGlobalGenerator()
  739. ->GetExportSets()[exports]
  740. ->AddTargetExport(te);
  741. te->InterfaceIncludeDirectories =
  742. cmJoin(includesArgs.GetIncludeDirs(), ";");
  743. }
  744. }
  745. // Tell the global generator about any installation component names
  746. // specified
  747. if (installsArchive) {
  748. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  749. archiveArgs.GetComponent());
  750. }
  751. if (installsLibrary) {
  752. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  753. libraryArgs.GetComponent());
  754. }
  755. if (installsNamelink) {
  756. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  757. libraryArgs.GetNamelinkComponent());
  758. }
  759. if (installsRuntime) {
  760. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  761. runtimeArgs.GetComponent());
  762. }
  763. if (installsObject) {
  764. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  765. objectArgs.GetComponent());
  766. }
  767. if (installsFramework) {
  768. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  769. frameworkArgs.GetComponent());
  770. }
  771. if (installsBundle) {
  772. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  773. bundleArgs.GetComponent());
  774. }
  775. if (installsPrivateHeader) {
  776. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  777. privateHeaderArgs.GetComponent());
  778. }
  779. if (installsPublicHeader) {
  780. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  781. publicHeaderArgs.GetComponent());
  782. }
  783. if (installsResource) {
  784. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  785. resourceArgs.GetComponent());
  786. }
  787. return true;
  788. }
  789. bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
  790. {
  791. // This is the FILES mode.
  792. bool programs = (args[0] == "PROGRAMS");
  793. cmInstallCommandArguments ica(this->DefaultComponentName);
  794. std::vector<std::string> files;
  795. ica.Bind(programs ? "PROGRAMS"_s : "FILES"_s, files);
  796. std::vector<std::string> unknownArgs;
  797. ica.Parse(args, &unknownArgs);
  798. if (!unknownArgs.empty()) {
  799. // Unknown argument.
  800. std::ostringstream e;
  801. e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
  802. this->SetError(e.str());
  803. return false;
  804. }
  805. std::string type = ica.GetType();
  806. if (!type.empty() && allowedTypes.count(type) == 0) {
  807. std::ostringstream e;
  808. e << args[0] << " given non-type \"" << type << "\" with TYPE argument.";
  809. this->SetError(e.str());
  810. return false;
  811. }
  812. const std::vector<std::string>& filesVector = files;
  813. // Check if there is something to do.
  814. if (filesVector.empty()) {
  815. return true;
  816. }
  817. if (!ica.GetRename().empty() && filesVector.size() > 1) {
  818. // The rename option works only with one file.
  819. std::ostringstream e;
  820. e << args[0] << " given RENAME option with more than one file.";
  821. this->SetError(e.str());
  822. return false;
  823. }
  824. std::vector<std::string> absFiles;
  825. if (!this->MakeFilesFullPath(args[0].c_str(), filesVector, absFiles)) {
  826. return false;
  827. }
  828. cmPolicies::PolicyStatus status =
  829. this->Makefile->GetPolicyStatus(cmPolicies::CMP0062);
  830. cmGlobalGenerator* gg = this->Makefile->GetGlobalGenerator();
  831. for (std::string const& file : filesVector) {
  832. if (gg->IsExportedTargetsFile(file)) {
  833. const char* modal = nullptr;
  834. std::ostringstream e;
  835. MessageType messageType = MessageType::AUTHOR_WARNING;
  836. switch (status) {
  837. case cmPolicies::WARN:
  838. e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0062) << "\n";
  839. modal = "should";
  840. case cmPolicies::OLD:
  841. break;
  842. case cmPolicies::REQUIRED_IF_USED:
  843. case cmPolicies::REQUIRED_ALWAYS:
  844. case cmPolicies::NEW:
  845. modal = "may";
  846. messageType = MessageType::FATAL_ERROR;
  847. }
  848. if (modal) {
  849. e << "The file\n " << file
  850. << "\nwas generated by the export() "
  851. "command. It "
  852. << modal
  853. << " not be installed with the "
  854. "install() command. Use the install(EXPORT) mechanism "
  855. "instead. See the cmake-packages(7) manual for more.\n";
  856. this->Makefile->IssueMessage(messageType, e.str());
  857. if (messageType == MessageType::FATAL_ERROR) {
  858. return false;
  859. }
  860. }
  861. }
  862. }
  863. if (!ica.Finalize()) {
  864. return false;
  865. }
  866. if (!type.empty() && !ica.GetDestination().empty()) {
  867. std::ostringstream e;
  868. e << args[0]
  869. << " given both TYPE and DESTINATION arguments. You may only specify "
  870. "one.";
  871. this->SetError(e.str());
  872. return false;
  873. }
  874. std::string destination = this->GetDestinationForType(&ica, type);
  875. if (destination.empty()) {
  876. // A destination is required.
  877. std::ostringstream e;
  878. e << args[0] << " given no DESTINATION!";
  879. this->SetError(e.str());
  880. return false;
  881. }
  882. // Create the files install generator.
  883. this->Makefile->AddInstallGenerator(CreateInstallFilesGenerator(
  884. this->Makefile, absFiles, ica, programs, destination));
  885. // Tell the global generator about any installation component names
  886. // specified.
  887. this->Makefile->GetGlobalGenerator()->AddInstallComponent(
  888. ica.GetComponent());
  889. return true;
  890. }
  891. bool cmInstallCommand::HandleDirectoryMode(
  892. std::vector<std::string> const& args)
  893. {
  894. enum Doing
  895. {
  896. DoingNone,
  897. DoingDirs,
  898. DoingDestination,
  899. DoingPattern,
  900. DoingRegex,
  901. DoingPermsFile,
  902. DoingPermsDir,
  903. DoingPermsMatch,
  904. DoingConfigurations,
  905. DoingComponent,
  906. DoingType
  907. };
  908. Doing doing = DoingDirs;
  909. bool in_match_mode = false;
  910. bool optional = false;
  911. bool exclude_from_all = false;
  912. bool message_never = false;
  913. std::vector<std::string> dirs;
  914. const char* destination = nullptr;
  915. std::string permissions_file;
  916. std::string permissions_dir;
  917. std::vector<std::string> configurations;
  918. std::string component = this->DefaultComponentName;
  919. std::string literal_args;
  920. std::string type;
  921. for (unsigned int i = 1; i < args.size(); ++i) {
  922. if (args[i] == "DESTINATION") {
  923. if (in_match_mode) {
  924. std::ostringstream e;
  925. e << args[0] << " does not allow \"" << args[i]
  926. << "\" after PATTERN or REGEX.";
  927. this->SetError(e.str());
  928. return false;
  929. }
  930. // Switch to setting the destination property.
  931. doing = DoingDestination;
  932. } else if (args[i] == "TYPE") {
  933. if (in_match_mode) {
  934. std::ostringstream e;
  935. e << args[0] << " does not allow \"" << args[i]
  936. << "\" after PATTERN or REGEX.";
  937. this->SetError(e.str());
  938. return false;
  939. }
  940. // Switch to setting the type.
  941. doing = DoingType;
  942. } else if (args[i] == "OPTIONAL") {
  943. if (in_match_mode) {
  944. std::ostringstream e;
  945. e << args[0] << " does not allow \"" << args[i]
  946. << "\" after PATTERN or REGEX.";
  947. this->SetError(e.str());
  948. return false;
  949. }
  950. // Mark the rule as optional.
  951. optional = true;
  952. doing = DoingNone;
  953. } else if (args[i] == "MESSAGE_NEVER") {
  954. if (in_match_mode) {
  955. std::ostringstream e;
  956. e << args[0] << " does not allow \"" << args[i]
  957. << "\" after PATTERN or REGEX.";
  958. this->SetError(e.str());
  959. return false;
  960. }
  961. // Mark the rule as quiet.
  962. message_never = true;
  963. doing = DoingNone;
  964. } else if (args[i] == "PATTERN") {
  965. // Switch to a new pattern match rule.
  966. doing = DoingPattern;
  967. in_match_mode = true;
  968. } else if (args[i] == "REGEX") {
  969. // Switch to a new regex match rule.
  970. doing = DoingRegex;
  971. in_match_mode = true;
  972. } else if (args[i] == "EXCLUDE") {
  973. // Add this property to the current match rule.
  974. if (!in_match_mode || doing == DoingPattern || doing == DoingRegex) {
  975. std::ostringstream e;
  976. e << args[0] << " does not allow \"" << args[i]
  977. << "\" before a PATTERN or REGEX is given.";
  978. this->SetError(e.str());
  979. return false;
  980. }
  981. literal_args += " EXCLUDE";
  982. doing = DoingNone;
  983. } else if (args[i] == "PERMISSIONS") {
  984. if (!in_match_mode) {
  985. std::ostringstream e;
  986. e << args[0] << " does not allow \"" << args[i]
  987. << "\" before a PATTERN or REGEX is given.";
  988. this->SetError(e.str());
  989. return false;
  990. }
  991. // Switch to setting the current match permissions property.
  992. literal_args += " PERMISSIONS";
  993. doing = DoingPermsMatch;
  994. } else if (args[i] == "FILE_PERMISSIONS") {
  995. if (in_match_mode) {
  996. std::ostringstream e;
  997. e << args[0] << " does not allow \"" << args[i]
  998. << "\" after PATTERN or REGEX.";
  999. this->SetError(e.str());
  1000. return false;
  1001. }
  1002. // Switch to setting the file permissions property.
  1003. doing = DoingPermsFile;
  1004. } else if (args[i] == "DIRECTORY_PERMISSIONS") {
  1005. if (in_match_mode) {
  1006. std::ostringstream e;
  1007. e << args[0] << " does not allow \"" << args[i]
  1008. << "\" after PATTERN or REGEX.";
  1009. this->SetError(e.str());
  1010. return false;
  1011. }
  1012. // Switch to setting the directory permissions property.
  1013. doing = DoingPermsDir;
  1014. } else if (args[i] == "USE_SOURCE_PERMISSIONS") {
  1015. if (in_match_mode) {
  1016. std::ostringstream e;
  1017. e << args[0] << " does not allow \"" << args[i]
  1018. << "\" after PATTERN or REGEX.";
  1019. this->SetError(e.str());
  1020. return false;
  1021. }
  1022. // Add this option literally.
  1023. literal_args += " USE_SOURCE_PERMISSIONS";
  1024. doing = DoingNone;
  1025. } else if (args[i] == "FILES_MATCHING") {
  1026. if (in_match_mode) {
  1027. std::ostringstream e;
  1028. e << args[0] << " does not allow \"" << args[i]
  1029. << "\" after PATTERN or REGEX.";
  1030. this->SetError(e.str());
  1031. return false;
  1032. }
  1033. // Add this option literally.
  1034. literal_args += " FILES_MATCHING";
  1035. doing = DoingNone;
  1036. } else if (args[i] == "CONFIGURATIONS") {
  1037. if (in_match_mode) {
  1038. std::ostringstream e;
  1039. e << args[0] << " does not allow \"" << args[i]
  1040. << "\" after PATTERN or REGEX.";
  1041. this->SetError(e.str());
  1042. return false;
  1043. }
  1044. // Switch to setting the configurations property.
  1045. doing = DoingConfigurations;
  1046. } else if (args[i] == "COMPONENT") {
  1047. if (in_match_mode) {
  1048. std::ostringstream e;
  1049. e << args[0] << " does not allow \"" << args[i]
  1050. << "\" after PATTERN or REGEX.";
  1051. this->SetError(e.str());
  1052. return false;
  1053. }
  1054. // Switch to setting the component property.
  1055. doing = DoingComponent;
  1056. } else if (args[i] == "EXCLUDE_FROM_ALL") {
  1057. if (in_match_mode) {
  1058. std::ostringstream e;
  1059. e << args[0] << " does not allow \"" << args[i]
  1060. << "\" after PATTERN or REGEX.";
  1061. this->SetError(e.str());
  1062. return false;
  1063. }
  1064. exclude_from_all = true;
  1065. doing = DoingNone;
  1066. } else if (doing == DoingDirs) {
  1067. // Convert this directory to a full path.
  1068. std::string dir = args[i];
  1069. std::string::size_type gpos = cmGeneratorExpression::Find(dir);
  1070. if (gpos != 0 && !cmSystemTools::FileIsFullPath(dir)) {
  1071. dir = this->Makefile->GetCurrentSourceDirectory();
  1072. dir += "/";
  1073. dir += args[i];
  1074. }
  1075. // Make sure the name is a directory.
  1076. if (cmSystemTools::FileExists(dir) &&
  1077. !cmSystemTools::FileIsDirectory(dir)) {
  1078. std::ostringstream e;
  1079. e << args[0] << " given non-directory \"" << args[i]
  1080. << "\" to install.";
  1081. this->SetError(e.str());
  1082. return false;
  1083. }
  1084. // Store the directory for installation.
  1085. dirs.push_back(std::move(dir));
  1086. } else if (doing == DoingConfigurations) {
  1087. configurations.push_back(args[i]);
  1088. } else if (doing == DoingDestination) {
  1089. destination = args[i].c_str();
  1090. doing = DoingNone;
  1091. } else if (doing == DoingType) {
  1092. if (allowedTypes.count(args[i]) == 0) {
  1093. std::ostringstream e;
  1094. e << args[0] << " given non-type \"" << args[i]
  1095. << "\" with TYPE argument.";
  1096. this->SetError(e.str());
  1097. return false;
  1098. }
  1099. type = args[i];
  1100. doing = DoingNone;
  1101. } else if (doing == DoingPattern) {
  1102. // Convert the pattern to a regular expression. Require a
  1103. // leading slash and trailing end-of-string in the matched
  1104. // string to make sure the pattern matches only whole file
  1105. // names.
  1106. literal_args += " REGEX \"/";
  1107. std::string regex = cmsys::Glob::PatternToRegex(args[i], false);
  1108. cmSystemTools::ReplaceString(regex, "\\", "\\\\");
  1109. literal_args += regex;
  1110. literal_args += "$\"";
  1111. doing = DoingNone;
  1112. } else if (doing == DoingRegex) {
  1113. literal_args += " REGEX \"";
  1114. // Match rules are case-insensitive on some platforms.
  1115. #if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
  1116. std::string regex = cmSystemTools::LowerCase(args[i]);
  1117. #else
  1118. std::string regex = args[i];
  1119. #endif
  1120. cmSystemTools::ReplaceString(regex, "\\", "\\\\");
  1121. literal_args += regex;
  1122. literal_args += "\"";
  1123. doing = DoingNone;
  1124. } else if (doing == DoingComponent) {
  1125. component = args[i];
  1126. doing = DoingNone;
  1127. } else if (doing == DoingPermsFile) {
  1128. // Check the requested permission.
  1129. if (!cmInstallCommandArguments::CheckPermissions(args[i],
  1130. permissions_file)) {
  1131. std::ostringstream e;
  1132. e << args[0] << " given invalid file permission \"" << args[i]
  1133. << "\".";
  1134. this->SetError(e.str());
  1135. return false;
  1136. }
  1137. } else if (doing == DoingPermsDir) {
  1138. // Check the requested permission.
  1139. if (!cmInstallCommandArguments::CheckPermissions(args[i],
  1140. permissions_dir)) {
  1141. std::ostringstream e;
  1142. e << args[0] << " given invalid directory permission \"" << args[i]
  1143. << "\".";
  1144. this->SetError(e.str());
  1145. return false;
  1146. }
  1147. } else if (doing == DoingPermsMatch) {
  1148. // Check the requested permission.
  1149. if (!cmInstallCommandArguments::CheckPermissions(args[i],
  1150. literal_args)) {
  1151. std::ostringstream e;
  1152. e << args[0] << " given invalid permission \"" << args[i] << "\".";
  1153. this->SetError(e.str());
  1154. return false;
  1155. }
  1156. } else {
  1157. // Unknown argument.
  1158. std::ostringstream e;
  1159. e << args[0] << " given unknown argument \"" << args[i] << "\".";
  1160. this->SetError(e.str());
  1161. return false;
  1162. }
  1163. }
  1164. // Support installing an empty directory.
  1165. if (dirs.empty() && destination) {
  1166. dirs.emplace_back();
  1167. }
  1168. // Check if there is something to do.
  1169. if (dirs.empty()) {
  1170. return true;
  1171. }
  1172. std::string destinationStr;
  1173. if (!destination) {
  1174. if (type.empty()) {
  1175. // A destination is required.
  1176. std::ostringstream e;
  1177. e << args[0] << " given no DESTINATION!";
  1178. this->SetError(e.str());
  1179. return false;
  1180. }
  1181. destinationStr = this->GetDestinationForType(nullptr, type);
  1182. destination = destinationStr.c_str();
  1183. } else if (!type.empty()) {
  1184. std::ostringstream e;
  1185. e << args[0]
  1186. << " given both TYPE and DESTINATION arguments. You may only specify "
  1187. "one.";
  1188. this->SetError(e.str());
  1189. return false;
  1190. }
  1191. cmInstallGenerator::MessageLevel message =
  1192. cmInstallGenerator::SelectMessageLevel(this->Makefile, message_never);
  1193. // Create the directory install generator.
  1194. this->Makefile->AddInstallGenerator(new cmInstallDirectoryGenerator(
  1195. dirs, destination, permissions_file.c_str(), permissions_dir.c_str(),
  1196. configurations, component.c_str(), message, exclude_from_all,
  1197. literal_args.c_str(), optional));
  1198. // Tell the global generator about any installation component names
  1199. // specified.
  1200. this->Makefile->GetGlobalGenerator()->AddInstallComponent(component);
  1201. return true;
  1202. }
  1203. bool cmInstallCommand::HandleExportAndroidMKMode(
  1204. std::vector<std::string> const& args)
  1205. {
  1206. #ifdef CMAKE_BUILD_WITH_CMAKE
  1207. // This is the EXPORT mode.
  1208. cmInstallCommandArguments ica(this->DefaultComponentName);
  1209. std::string exp;
  1210. std::string name_space;
  1211. bool exportOld = false;
  1212. std::string filename;
  1213. ica.Bind("EXPORT_ANDROID_MK"_s, exp);
  1214. ica.Bind("NAMESPACE"_s, name_space);
  1215. ica.Bind("EXPORT_LINK_INTERFACE_LIBRARIES"_s, exportOld);
  1216. ica.Bind("FILE"_s, filename);
  1217. std::vector<std::string> unknownArgs;
  1218. ica.Parse(args, &unknownArgs);
  1219. if (!unknownArgs.empty()) {
  1220. // Unknown argument.
  1221. std::ostringstream e;
  1222. e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
  1223. this->SetError(e.str());
  1224. return false;
  1225. }
  1226. if (!ica.Finalize()) {
  1227. return false;
  1228. }
  1229. // Make sure there is a destination.
  1230. if (ica.GetDestination().empty()) {
  1231. // A destination is required.
  1232. std::ostringstream e;
  1233. e << args[0] << " given no DESTINATION!";
  1234. this->SetError(e.str());
  1235. return false;
  1236. }
  1237. // Check the file name.
  1238. std::string fname = filename;
  1239. if (fname.find_first_of(":/\\") != std::string::npos) {
  1240. std::ostringstream e;
  1241. e << args[0] << " given invalid export file name \"" << fname << "\". "
  1242. << "The FILE argument may not contain a path. "
  1243. << "Specify the path in the DESTINATION argument.";
  1244. this->SetError(e.str());
  1245. return false;
  1246. }
  1247. // Check the file extension.
  1248. if (!fname.empty() &&
  1249. cmSystemTools::GetFilenameLastExtension(fname) != ".mk") {
  1250. std::ostringstream e;
  1251. e << args[0] << " given invalid export file name \"" << fname << "\". "
  1252. << "The FILE argument must specify a name ending in \".mk\".";
  1253. this->SetError(e.str());
  1254. return false;
  1255. }
  1256. if (fname.find_first_of(":/\\") != std::string::npos) {
  1257. std::ostringstream e;
  1258. e << args[0] << " given export name \"" << exp << "\". "
  1259. << "This name cannot be safely converted to a file name. "
  1260. << "Specify a different export name or use the FILE option to set "
  1261. << "a file name explicitly.";
  1262. this->SetError(e.str());
  1263. return false;
  1264. }
  1265. // Use the default name
  1266. if (fname.empty()) {
  1267. fname = "Android.mk";
  1268. }
  1269. cmExportSet* exportSet =
  1270. this->Makefile->GetGlobalGenerator()->GetExportSets()[exp];
  1271. cmInstallGenerator::MessageLevel message =
  1272. cmInstallGenerator::SelectMessageLevel(this->Makefile);
  1273. // Create the export install generator.
  1274. cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
  1275. exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
  1276. ica.GetConfigurations(), ica.GetComponent().c_str(), message,
  1277. ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
  1278. true);
  1279. this->Makefile->AddInstallGenerator(exportGenerator);
  1280. return true;
  1281. #else
  1282. static_cast<void>(args);
  1283. this->SetError("EXPORT_ANDROID_MK not supported in bootstrap cmake");
  1284. return false;
  1285. #endif
  1286. }
  1287. bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
  1288. {
  1289. // This is the EXPORT mode.
  1290. cmInstallCommandArguments ica(this->DefaultComponentName);
  1291. std::string exp;
  1292. std::string name_space;
  1293. bool exportOld = false;
  1294. std::string filename;
  1295. ica.Bind("EXPORT"_s, exp);
  1296. ica.Bind("NAMESPACE"_s, name_space);
  1297. ica.Bind("EXPORT_LINK_INTERFACE_LIBRARIES"_s, exportOld);
  1298. ica.Bind("FILE"_s, filename);
  1299. std::vector<std::string> unknownArgs;
  1300. ica.Parse(args, &unknownArgs);
  1301. if (!unknownArgs.empty()) {
  1302. // Unknown argument.
  1303. std::ostringstream e;
  1304. e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
  1305. this->SetError(e.str());
  1306. return false;
  1307. }
  1308. if (!ica.Finalize()) {
  1309. return false;
  1310. }
  1311. // Make sure there is a destination.
  1312. if (ica.GetDestination().empty()) {
  1313. // A destination is required.
  1314. std::ostringstream e;
  1315. e << args[0] << " given no DESTINATION!";
  1316. this->SetError(e.str());
  1317. return false;
  1318. }
  1319. // Check the file name.
  1320. std::string fname = filename;
  1321. if (fname.find_first_of(":/\\") != std::string::npos) {
  1322. std::ostringstream e;
  1323. e << args[0] << " given invalid export file name \"" << fname << "\". "
  1324. << "The FILE argument may not contain a path. "
  1325. << "Specify the path in the DESTINATION argument.";
  1326. this->SetError(e.str());
  1327. return false;
  1328. }
  1329. // Check the file extension.
  1330. if (!fname.empty() &&
  1331. cmSystemTools::GetFilenameLastExtension(fname) != ".cmake") {
  1332. std::ostringstream e;
  1333. e << args[0] << " given invalid export file name \"" << fname << "\". "
  1334. << "The FILE argument must specify a name ending in \".cmake\".";
  1335. this->SetError(e.str());
  1336. return false;
  1337. }
  1338. // Construct the file name.
  1339. if (fname.empty()) {
  1340. fname = exp;
  1341. fname += ".cmake";
  1342. if (fname.find_first_of(":/\\") != std::string::npos) {
  1343. std::ostringstream e;
  1344. e << args[0] << " given export name \"" << exp << "\". "
  1345. << "This name cannot be safely converted to a file name. "
  1346. << "Specify a different export name or use the FILE option to set "
  1347. << "a file name explicitly.";
  1348. this->SetError(e.str());
  1349. return false;
  1350. }
  1351. }
  1352. cmExportSet* exportSet =
  1353. this->Makefile->GetGlobalGenerator()->GetExportSets()[exp];
  1354. if (exportOld) {
  1355. for (cmTargetExport* te : *exportSet->GetTargetExports()) {
  1356. cmTarget* tgt =
  1357. this->Makefile->GetGlobalGenerator()->FindTarget(te->TargetName);
  1358. const bool newCMP0022Behavior =
  1359. (tgt && tgt->GetPolicyStatusCMP0022() != cmPolicies::WARN &&
  1360. tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD);
  1361. if (!newCMP0022Behavior) {
  1362. std::ostringstream e;
  1363. e << "INSTALL(EXPORT) given keyword \""
  1364. << "EXPORT_LINK_INTERFACE_LIBRARIES"
  1365. << "\", but target \"" << te->TargetName
  1366. << "\" does not have policy CMP0022 set to NEW.";
  1367. this->SetError(e.str());
  1368. return false;
  1369. }
  1370. }
  1371. }
  1372. cmInstallGenerator::MessageLevel message =
  1373. cmInstallGenerator::SelectMessageLevel(this->Makefile);
  1374. // Create the export install generator.
  1375. cmInstallExportGenerator* exportGenerator = new cmInstallExportGenerator(
  1376. exportSet, ica.GetDestination().c_str(), ica.GetPermissions().c_str(),
  1377. ica.GetConfigurations(), ica.GetComponent().c_str(), message,
  1378. ica.GetExcludeFromAll(), fname.c_str(), name_space.c_str(), exportOld,
  1379. false);
  1380. this->Makefile->AddInstallGenerator(exportGenerator);
  1381. return true;
  1382. }
  1383. bool cmInstallCommand::MakeFilesFullPath(
  1384. const char* modeName, const std::vector<std::string>& relFiles,
  1385. std::vector<std::string>& absFiles)
  1386. {
  1387. for (std::string const& relFile : relFiles) {
  1388. std::string file = relFile;
  1389. std::string::size_type gpos = cmGeneratorExpression::Find(file);
  1390. if (gpos != 0 && !cmSystemTools::FileIsFullPath(file)) {
  1391. file = this->Makefile->GetCurrentSourceDirectory();
  1392. file += "/";
  1393. file += relFile;
  1394. }
  1395. // Make sure the file is not a directory.
  1396. if (gpos == std::string::npos && cmSystemTools::FileIsDirectory(file)) {
  1397. std::ostringstream e;
  1398. e << modeName << " given directory \"" << relFile << "\" to install.";
  1399. this->SetError(e.str());
  1400. return false;
  1401. }
  1402. // Store the file for installation.
  1403. absFiles.push_back(std::move(file));
  1404. }
  1405. return true;
  1406. }
  1407. bool cmInstallCommand::CheckCMP0006(bool& failure)
  1408. {
  1409. switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0006)) {
  1410. case cmPolicies::WARN:
  1411. this->Makefile->IssueMessage(
  1412. MessageType::AUTHOR_WARNING,
  1413. cmPolicies::GetPolicyWarning(cmPolicies::CMP0006));
  1414. CM_FALLTHROUGH;
  1415. case cmPolicies::OLD:
  1416. // OLD behavior is to allow compatibility
  1417. return true;
  1418. case cmPolicies::NEW:
  1419. // NEW behavior is to disallow compatibility
  1420. break;
  1421. case cmPolicies::REQUIRED_IF_USED:
  1422. case cmPolicies::REQUIRED_ALWAYS:
  1423. failure = true;
  1424. this->Makefile->IssueMessage(
  1425. MessageType::FATAL_ERROR,
  1426. cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0006));
  1427. break;
  1428. }
  1429. return false;
  1430. }
  1431. std::string cmInstallCommand::GetDestination(
  1432. const cmInstallCommandArguments* args, const std::string& varName,
  1433. const std::string& guess)
  1434. {
  1435. if (args && !args->GetDestination().empty()) {
  1436. return args->GetDestination();
  1437. }
  1438. std::string val = this->Makefile->GetSafeDefinition(varName);
  1439. if (!val.empty()) {
  1440. return val;
  1441. }
  1442. return guess;
  1443. }
  1444. std::string cmInstallCommand::GetRuntimeDestination(
  1445. const cmInstallCommandArguments* args)
  1446. {
  1447. return this->GetDestination(args, "CMAKE_INSTALL_BINDIR", "bin");
  1448. }
  1449. std::string cmInstallCommand::GetSbinDestination(
  1450. const cmInstallCommandArguments* args)
  1451. {
  1452. return this->GetDestination(args, "CMAKE_INSTALL_SBINDIR", "sbin");
  1453. }
  1454. std::string cmInstallCommand::GetArchiveDestination(
  1455. const cmInstallCommandArguments* args)
  1456. {
  1457. return this->GetDestination(args, "CMAKE_INSTALL_LIBDIR", "lib");
  1458. }
  1459. std::string cmInstallCommand::GetLibraryDestination(
  1460. const cmInstallCommandArguments* args)
  1461. {
  1462. return this->GetDestination(args, "CMAKE_INSTALL_LIBDIR", "lib");
  1463. }
  1464. std::string cmInstallCommand::GetIncludeDestination(
  1465. const cmInstallCommandArguments* args)
  1466. {
  1467. return this->GetDestination(args, "CMAKE_INSTALL_INCLUDEDIR", "include");
  1468. }
  1469. std::string cmInstallCommand::GetSysconfDestination(
  1470. const cmInstallCommandArguments* args)
  1471. {
  1472. return this->GetDestination(args, "CMAKE_INSTALL_SYSCONFDIR", "etc");
  1473. }
  1474. std::string cmInstallCommand::GetSharedStateDestination(
  1475. const cmInstallCommandArguments* args)
  1476. {
  1477. return this->GetDestination(args, "CMAKE_INSTALL_SHAREDSTATEDIR", "com");
  1478. }
  1479. std::string cmInstallCommand::GetLocalStateDestination(
  1480. const cmInstallCommandArguments* args)
  1481. {
  1482. return this->GetDestination(args, "CMAKE_INSTALL_LOCALSTATEDIR", "var");
  1483. }
  1484. std::string cmInstallCommand::GetRunStateDestination(
  1485. const cmInstallCommandArguments* args)
  1486. {
  1487. return this->GetDestination(args, "CMAKE_INSTALL_RUNSTATEDIR",
  1488. this->GetLocalStateDestination(nullptr) +
  1489. "/run");
  1490. }
  1491. std::string cmInstallCommand::GetDataRootDestination(
  1492. const cmInstallCommandArguments* args)
  1493. {
  1494. return this->GetDestination(args, "CMAKE_INSTALL_DATAROOTDIR", "share");
  1495. }
  1496. std::string cmInstallCommand::GetDataDestination(
  1497. const cmInstallCommandArguments* args)
  1498. {
  1499. return this->GetDestination(args, "CMAKE_INSTALL_DATADIR",
  1500. this->GetDataRootDestination(nullptr));
  1501. }
  1502. std::string cmInstallCommand::GetInfoDestination(
  1503. const cmInstallCommandArguments* args)
  1504. {
  1505. return this->GetDestination(args, "CMAKE_INSTALL_INFODIR",
  1506. this->GetDataRootDestination(nullptr) + "/info");
  1507. }
  1508. std::string cmInstallCommand::GetLocaleDestination(
  1509. const cmInstallCommandArguments* args)
  1510. {
  1511. return this->GetDestination(args, "CMAKE_INSTALL_LOCALEDIR",
  1512. this->GetDataRootDestination(nullptr) +
  1513. "/locale");
  1514. }
  1515. std::string cmInstallCommand::GetManDestination(
  1516. const cmInstallCommandArguments* args)
  1517. {
  1518. return this->GetDestination(args, "CMAKE_INSTALL_MANDIR",
  1519. this->GetDataRootDestination(nullptr) + "/man");
  1520. }
  1521. std::string cmInstallCommand::GetDocDestination(
  1522. const cmInstallCommandArguments* args)
  1523. {
  1524. return this->GetDestination(args, "CMAKE_INSTALL_DOCDIR",
  1525. this->GetDataRootDestination(nullptr) + "/doc");
  1526. }
  1527. std::string cmInstallCommand::GetDestinationForType(
  1528. const cmInstallCommandArguments* args, const std::string& type)
  1529. {
  1530. if (args && !args->GetDestination().empty()) {
  1531. return args->GetDestination();
  1532. }
  1533. if (type == "BIN") {
  1534. return this->GetRuntimeDestination(nullptr);
  1535. }
  1536. if (type == "SBIN") {
  1537. return this->GetSbinDestination(nullptr);
  1538. }
  1539. if (type == "SYSCONF") {
  1540. return this->GetSysconfDestination(nullptr);
  1541. }
  1542. if (type == "SHAREDSTATE") {
  1543. return this->GetSharedStateDestination(nullptr);
  1544. }
  1545. if (type == "LOCALSTATE") {
  1546. return this->GetLocalStateDestination(nullptr);
  1547. }
  1548. if (type == "RUNSTATE") {
  1549. return this->GetRunStateDestination(nullptr);
  1550. }
  1551. if (type == "LIB") {
  1552. return this->GetLibraryDestination(nullptr);
  1553. }
  1554. if (type == "INCLUDE") {
  1555. return this->GetIncludeDestination(nullptr);
  1556. }
  1557. if (type == "DATA") {
  1558. return this->GetDataDestination(nullptr);
  1559. }
  1560. if (type == "INFO") {
  1561. return this->GetInfoDestination(nullptr);
  1562. }
  1563. if (type == "LOCALE") {
  1564. return this->GetLocaleDestination(nullptr);
  1565. }
  1566. if (type == "MAN") {
  1567. return this->GetManDestination(nullptr);
  1568. }
  1569. if (type == "DOC") {
  1570. return this->GetDocDestination(nullptr);
  1571. }
  1572. return "";
  1573. }