cmInstallTargetGenerator.cxx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  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 "cmInstallTargetGenerator.h"
  11. #include "cmComputeLinkInformation.h"
  12. #include "cmGlobalGenerator.h"
  13. #include "cmLocalGenerator.h"
  14. #include "cmMakefile.h"
  15. #include "cmake.h"
  16. #include <assert.h>
  17. //----------------------------------------------------------------------------
  18. cmInstallTargetGenerator
  19. ::cmInstallTargetGenerator(cmTarget& t, const char* dest, bool implib,
  20. const char* file_permissions,
  21. std::vector<std::string> const& configurations,
  22. const char* component, bool optional):
  23. cmInstallGenerator(dest, configurations, component), Target(&t),
  24. ImportLibrary(implib), FilePermissions(file_permissions), Optional(optional)
  25. {
  26. this->ActionsPerConfig = true;
  27. this->NamelinkMode = NamelinkModeNone;
  28. this->Target->SetHaveInstallRule(true);
  29. }
  30. //----------------------------------------------------------------------------
  31. cmInstallTargetGenerator
  32. ::~cmInstallTargetGenerator()
  33. {
  34. }
  35. //----------------------------------------------------------------------------
  36. void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
  37. {
  38. // Warn if installing an exclude-from-all target.
  39. if(this->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
  40. {
  41. cmOStringStream msg;
  42. msg << "WARNING: Target \"" << this->Target->GetName()
  43. << "\" has EXCLUDE_FROM_ALL set and will not be built by default "
  44. << "but an install rule has been provided for it. CMake does "
  45. << "not define behavior for this case.";
  46. cmSystemTools::Message(msg.str().c_str(), "Warning");
  47. }
  48. // Perform the main install script generation.
  49. this->cmInstallGenerator::GenerateScript(os);
  50. }
  51. //----------------------------------------------------------------------------
  52. void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
  53. const char* config,
  54. Indent const& indent)
  55. {
  56. // Compute the build tree directory from which to copy the target.
  57. std::string fromDirConfig;
  58. if(this->Target->NeedRelinkBeforeInstall(config))
  59. {
  60. fromDirConfig = this->Target->GetMakefile()->GetStartOutputDirectory();
  61. fromDirConfig += cmake::GetCMakeFilesDirectory();
  62. fromDirConfig += "/CMakeRelink.dir/";
  63. }
  64. else
  65. {
  66. fromDirConfig = this->Target->GetDirectory(config, this->ImportLibrary);
  67. fromDirConfig += "/";
  68. }
  69. std::string toDir = this->GetInstallDestination();
  70. toDir += "/";
  71. // Compute the list of files to install for this target.
  72. std::vector<std::string> filesFrom;
  73. std::vector<std::string> filesTo;
  74. std::string literal_args;
  75. cmTarget::TargetType type = this->Target->GetType();
  76. if(type == cmTarget::EXECUTABLE)
  77. {
  78. // There is a bug in cmInstallCommand if this fails.
  79. assert(this->NamelinkMode == NamelinkModeNone);
  80. std::string targetName;
  81. std::string targetNameReal;
  82. std::string targetNameImport;
  83. std::string targetNamePDB;
  84. this->Target->GetExecutableNames(targetName, targetNameReal,
  85. targetNameImport, targetNamePDB,
  86. config);
  87. if(this->ImportLibrary)
  88. {
  89. std::string from1 = fromDirConfig + targetNameImport;
  90. std::string to1 = toDir + targetNameImport;
  91. filesFrom.push_back(from1);
  92. filesTo.push_back(to1);
  93. std::string targetNameImportLib;
  94. if(this->Target->GetImplibGNUtoMS(targetNameImport,
  95. targetNameImportLib))
  96. {
  97. filesFrom.push_back(fromDirConfig + targetNameImportLib);
  98. filesTo.push_back(toDir + targetNameImportLib);
  99. }
  100. // An import library looks like a static library.
  101. type = cmTarget::STATIC_LIBRARY;
  102. }
  103. else
  104. {
  105. std::string from1 = fromDirConfig + targetName;
  106. std::string to1 = toDir + targetName;
  107. // Handle OSX Bundles.
  108. if(this->Target->IsAppBundleOnApple())
  109. {
  110. // Install the whole app bundle directory.
  111. type = cmTarget::INSTALL_DIRECTORY;
  112. literal_args += " USE_SOURCE_PERMISSIONS";
  113. from1 += ".app";
  114. // Tweaks apply to the binary inside the bundle.
  115. to1 += ".app/Contents/MacOS/";
  116. to1 += targetName;
  117. }
  118. else
  119. {
  120. // Tweaks apply to the real file, so list it first.
  121. if(targetNameReal != targetName)
  122. {
  123. std::string from2 = fromDirConfig + targetNameReal;
  124. std::string to2 = toDir += targetNameReal;
  125. filesFrom.push_back(from2);
  126. filesTo.push_back(to2);
  127. }
  128. }
  129. filesFrom.push_back(from1);
  130. filesTo.push_back(to1);
  131. }
  132. }
  133. else
  134. {
  135. std::string targetName;
  136. std::string targetNameSO;
  137. std::string targetNameReal;
  138. std::string targetNameImport;
  139. std::string targetNamePDB;
  140. this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal,
  141. targetNameImport, targetNamePDB,
  142. config);
  143. if(this->ImportLibrary)
  144. {
  145. // There is a bug in cmInstallCommand if this fails.
  146. assert(this->NamelinkMode == NamelinkModeNone);
  147. std::string from1 = fromDirConfig + targetNameImport;
  148. std::string to1 = toDir + targetNameImport;
  149. filesFrom.push_back(from1);
  150. filesTo.push_back(to1);
  151. std::string targetNameImportLib;
  152. if(this->Target->GetImplibGNUtoMS(targetNameImport,
  153. targetNameImportLib))
  154. {
  155. filesFrom.push_back(fromDirConfig + targetNameImportLib);
  156. filesTo.push_back(toDir + targetNameImportLib);
  157. }
  158. // An import library looks like a static library.
  159. type = cmTarget::STATIC_LIBRARY;
  160. }
  161. else if(this->Target->IsFrameworkOnApple())
  162. {
  163. // There is a bug in cmInstallCommand if this fails.
  164. assert(this->NamelinkMode == NamelinkModeNone);
  165. // Install the whole framework directory.
  166. type = cmTarget::INSTALL_DIRECTORY;
  167. literal_args += " USE_SOURCE_PERMISSIONS";
  168. std::string from1 = fromDirConfig + targetName + ".framework";
  169. // Tweaks apply to the binary inside the bundle.
  170. std::string to1 = toDir + targetName;
  171. to1 += ".framework/Versions/";
  172. to1 += this->Target->GetFrameworkVersion();
  173. to1 += "/";
  174. to1 += targetName;
  175. filesFrom.push_back(from1);
  176. filesTo.push_back(to1);
  177. }
  178. else
  179. {
  180. bool haveNamelink = false;
  181. // Library link name.
  182. std::string fromName = fromDirConfig + targetName;
  183. std::string toName = toDir + targetName;
  184. // Library interface name.
  185. std::string fromSOName;
  186. std::string toSOName;
  187. if(targetNameSO != targetName)
  188. {
  189. haveNamelink = true;
  190. fromSOName = fromDirConfig + targetNameSO;
  191. toSOName = toDir + targetNameSO;
  192. }
  193. // Library implementation name.
  194. std::string fromRealName;
  195. std::string toRealName;
  196. if(targetNameReal != targetName &&
  197. targetNameReal != targetNameSO)
  198. {
  199. haveNamelink = true;
  200. fromRealName = fromDirConfig + targetNameReal;
  201. toRealName = toDir + targetNameReal;
  202. }
  203. // Add the names based on the current namelink mode.
  204. if(haveNamelink)
  205. {
  206. // With a namelink we need to check the mode.
  207. if(this->NamelinkMode == NamelinkModeOnly)
  208. {
  209. // Install the namelink only.
  210. filesFrom.push_back(fromName);
  211. filesTo.push_back(toName);
  212. }
  213. else
  214. {
  215. // Install the real file if it has its own name.
  216. if(!fromRealName.empty())
  217. {
  218. filesFrom.push_back(fromRealName);
  219. filesTo.push_back(toRealName);
  220. }
  221. // Install the soname link if it has its own name.
  222. if(!fromSOName.empty())
  223. {
  224. filesFrom.push_back(fromSOName);
  225. filesTo.push_back(toSOName);
  226. }
  227. // Install the namelink if it is not to be skipped.
  228. if(this->NamelinkMode != NamelinkModeSkip)
  229. {
  230. filesFrom.push_back(fromName);
  231. filesTo.push_back(toName);
  232. }
  233. }
  234. }
  235. else
  236. {
  237. // Without a namelink there will be only one file. Install it
  238. // if this is not a namelink-only rule.
  239. if(this->NamelinkMode != NamelinkModeOnly)
  240. {
  241. filesFrom.push_back(fromName);
  242. filesTo.push_back(toName);
  243. }
  244. }
  245. }
  246. }
  247. // If this fails the above code is buggy.
  248. assert(filesFrom.size() == filesTo.size());
  249. // Skip this rule if no files are to be installed for the target.
  250. if(filesFrom.empty())
  251. {
  252. return;
  253. }
  254. // Add pre-installation tweaks.
  255. this->AddTweak(os, indent, config, filesTo,
  256. &cmInstallTargetGenerator::PreReplacementTweaks);
  257. // Write code to install the target file.
  258. const char* no_dir_permissions = 0;
  259. const char* no_rename = 0;
  260. bool optional = this->Optional || this->ImportLibrary;
  261. this->AddInstallRule(os, type, filesFrom,
  262. optional,
  263. this->FilePermissions.c_str(), no_dir_permissions,
  264. no_rename, literal_args.c_str(),
  265. indent);
  266. // Add post-installation tweaks.
  267. this->AddTweak(os, indent, config, filesTo,
  268. &cmInstallTargetGenerator::PostReplacementTweaks);
  269. }
  270. //----------------------------------------------------------------------------
  271. std::string
  272. cmInstallTargetGenerator::GetInstallFilename(const char* config) const
  273. {
  274. NameType nameType = this->ImportLibrary? NameImplib : NameNormal;
  275. return
  276. cmInstallTargetGenerator::GetInstallFilename(this->Target, config,
  277. nameType);
  278. }
  279. //----------------------------------------------------------------------------
  280. std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target,
  281. const char* config,
  282. NameType nameType)
  283. {
  284. std::string fname;
  285. // Compute the name of the library.
  286. if(target->GetType() == cmTarget::EXECUTABLE)
  287. {
  288. std::string targetName;
  289. std::string targetNameReal;
  290. std::string targetNameImport;
  291. std::string targetNamePDB;
  292. target->GetExecutableNames(targetName, targetNameReal,
  293. targetNameImport, targetNamePDB,
  294. config);
  295. if(nameType == NameImplib)
  296. {
  297. // Use the import library name.
  298. if(!target->GetImplibGNUtoMS(targetNameImport, fname,
  299. "${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
  300. {
  301. fname = targetNameImport;
  302. }
  303. }
  304. else if(nameType == NameReal)
  305. {
  306. // Use the canonical name.
  307. fname = targetNameReal;
  308. }
  309. else
  310. {
  311. // Use the canonical name.
  312. fname = targetName;
  313. }
  314. }
  315. else
  316. {
  317. std::string targetName;
  318. std::string targetNameSO;
  319. std::string targetNameReal;
  320. std::string targetNameImport;
  321. std::string targetNamePDB;
  322. target->GetLibraryNames(targetName, targetNameSO, targetNameReal,
  323. targetNameImport, targetNamePDB, config);
  324. if(nameType == NameImplib)
  325. {
  326. // Use the import library name.
  327. if(!target->GetImplibGNUtoMS(targetNameImport, fname,
  328. "${CMAKE_IMPORT_LIBRARY_SUFFIX}"))
  329. {
  330. fname = targetNameImport;
  331. }
  332. }
  333. else if(nameType == NameSO)
  334. {
  335. // Use the soname.
  336. fname = targetNameSO;
  337. }
  338. else if(nameType == NameReal)
  339. {
  340. // Use the real name.
  341. fname = targetNameReal;
  342. }
  343. else
  344. {
  345. // Use the canonical name.
  346. fname = targetName;
  347. }
  348. }
  349. return fname;
  350. }
  351. //----------------------------------------------------------------------------
  352. void
  353. cmInstallTargetGenerator
  354. ::AddTweak(std::ostream& os, Indent const& indent, const char* config,
  355. std::string const& file, TweakMethod tweak)
  356. {
  357. cmOStringStream tw;
  358. (this->*tweak)(tw, indent.Next(), config, file);
  359. std::string tws = tw.str();
  360. if(!tws.empty())
  361. {
  362. os << indent << "IF(EXISTS \"" << file << "\" AND\n"
  363. << indent << " NOT IS_SYMLINK \"" << file << "\")\n";
  364. os << tws;
  365. os << indent << "ENDIF()\n";
  366. }
  367. }
  368. //----------------------------------------------------------------------------
  369. void
  370. cmInstallTargetGenerator
  371. ::AddTweak(std::ostream& os, Indent const& indent, const char* config,
  372. std::vector<std::string> const& files, TweakMethod tweak)
  373. {
  374. if(files.size() == 1)
  375. {
  376. // Tweak a single file.
  377. this->AddTweak(os, indent, config, this->GetDestDirPath(files[0]), tweak);
  378. }
  379. else
  380. {
  381. // Generate a foreach loop to tweak multiple files.
  382. cmOStringStream tw;
  383. this->AddTweak(tw, indent.Next(), config, "${file}", tweak);
  384. std::string tws = tw.str();
  385. if(!tws.empty())
  386. {
  387. Indent indent2 = indent.Next().Next();
  388. os << indent << "FOREACH(file\n";
  389. for(std::vector<std::string>::const_iterator i = files.begin();
  390. i != files.end(); ++i)
  391. {
  392. os << indent2 << "\"" << this->GetDestDirPath(*i) << "\"\n";
  393. }
  394. os << indent2 << ")\n";
  395. os << tws;
  396. os << indent << "ENDFOREACH()\n";
  397. }
  398. }
  399. }
  400. //----------------------------------------------------------------------------
  401. std::string cmInstallTargetGenerator::GetDestDirPath(std::string const& file)
  402. {
  403. // Construct the path of the file on disk after installation on
  404. // which tweaks may be performed.
  405. std::string toDestDirPath = "$ENV{DESTDIR}";
  406. if(file[0] != '/' && file[0] != '$')
  407. {
  408. toDestDirPath += "/";
  409. }
  410. toDestDirPath += file;
  411. return toDestDirPath;
  412. }
  413. //----------------------------------------------------------------------------
  414. void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os,
  415. Indent const& indent,
  416. const char* config,
  417. std::string const& file)
  418. {
  419. this->AddRPathCheckRule(os, indent, config, file);
  420. }
  421. //----------------------------------------------------------------------------
  422. void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os,
  423. Indent const& indent,
  424. const char* config,
  425. std::string const& file)
  426. {
  427. this->AddInstallNamePatchRule(os, indent, config, file);
  428. this->AddChrpathPatchRule(os, indent, config, file);
  429. this->AddRanlibRule(os, indent, file);
  430. this->AddStripRule(os, indent, file);
  431. }
  432. //----------------------------------------------------------------------------
  433. void
  434. cmInstallTargetGenerator
  435. ::AddInstallNamePatchRule(std::ostream& os, Indent const& indent,
  436. const char* config, std::string const& toDestDirPath)
  437. {
  438. if(this->ImportLibrary ||
  439. !(this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
  440. this->Target->GetType() == cmTarget::MODULE_LIBRARY ||
  441. this->Target->GetType() == cmTarget::EXECUTABLE))
  442. {
  443. return;
  444. }
  445. // Fix the install_name settings in installed binaries.
  446. std::string installNameTool =
  447. this->Target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL");
  448. if(!installNameTool.size())
  449. {
  450. return;
  451. }
  452. // Build a map of build-tree install_name to install-tree install_name for
  453. // shared libraries linked to this target.
  454. std::map<cmStdString, cmStdString> install_name_remap;
  455. if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config))
  456. {
  457. std::set<cmTarget*> const& sharedLibs = cli->GetSharedLibrariesLinked();
  458. for(std::set<cmTarget*>::const_iterator j = sharedLibs.begin();
  459. j != sharedLibs.end(); ++j)
  460. {
  461. cmTarget* tgt = *j;
  462. // The install_name of an imported target does not change.
  463. if(tgt->IsImported())
  464. {
  465. continue;
  466. }
  467. // If the build tree and install tree use different path
  468. // components of the install_name field then we need to create a
  469. // mapping to be applied after installation.
  470. std::string for_build = tgt->GetInstallNameDirForBuildTree(config);
  471. std::string for_install = tgt->GetInstallNameDirForInstallTree(config);
  472. if(for_build != for_install)
  473. {
  474. // The directory portions differ. Append the filename to
  475. // create the mapping.
  476. std::string fname =
  477. this->GetInstallFilename(tgt, config, NameSO);
  478. // Map from the build-tree install_name.
  479. for_build += fname;
  480. // Map to the install-tree install_name.
  481. for_install += fname;
  482. // Store the mapping entry.
  483. install_name_remap[for_build] = for_install;
  484. }
  485. }
  486. }
  487. // Edit the install_name of the target itself if necessary.
  488. std::string new_id;
  489. if(this->Target->GetType() == cmTarget::SHARED_LIBRARY)
  490. {
  491. std::string for_build =
  492. this->Target->GetInstallNameDirForBuildTree(config);
  493. std::string for_install =
  494. this->Target->GetInstallNameDirForInstallTree(config);
  495. if(this->Target->IsFrameworkOnApple() && for_install.empty())
  496. {
  497. // Frameworks seem to have an id corresponding to their own full
  498. // path.
  499. // ...
  500. // for_install = fullDestPath_without_DESTDIR_or_name;
  501. }
  502. // If the install name will change on installation set the new id
  503. // on the installed file.
  504. if(for_build != for_install)
  505. {
  506. // Prepare to refer to the install-tree install_name.
  507. new_id = for_install;
  508. new_id += this->GetInstallFilename(this->Target, config, NameSO);
  509. }
  510. }
  511. // Write a rule to run install_name_tool to set the install-tree
  512. // install_name value and references.
  513. if(!new_id.empty() || !install_name_remap.empty())
  514. {
  515. os << indent << "EXECUTE_PROCESS(COMMAND \"" << installNameTool;
  516. os << "\"";
  517. if(!new_id.empty())
  518. {
  519. os << "\n" << indent << " -id \"" << new_id << "\"";
  520. }
  521. for(std::map<cmStdString, cmStdString>::const_iterator
  522. i = install_name_remap.begin();
  523. i != install_name_remap.end(); ++i)
  524. {
  525. os << "\n" << indent << " -change \""
  526. << i->first << "\" \"" << i->second << "\"";
  527. }
  528. os << "\n" << indent << " \"" << toDestDirPath << "\")\n";
  529. }
  530. }
  531. //----------------------------------------------------------------------------
  532. void
  533. cmInstallTargetGenerator
  534. ::AddRPathCheckRule(std::ostream& os, Indent const& indent,
  535. const char* config, std::string const& toDestDirPath)
  536. {
  537. // Skip the chrpath if the target does not need it.
  538. if(this->ImportLibrary || !this->Target->IsChrpathUsed(config))
  539. {
  540. return;
  541. }
  542. // Get the link information for this target.
  543. // It can provide the RPATH.
  544. cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config);
  545. if(!cli)
  546. {
  547. return;
  548. }
  549. // Get the install RPATH from the link information.
  550. std::string newRpath = cli->GetChrpathString();
  551. // Write a rule to remove the installed file if its rpath is not the
  552. // new rpath. This is needed for existing build/install trees when
  553. // the installed rpath changes but the file is not rebuilt.
  554. os << indent << "FILE(RPATH_CHECK\n"
  555. << indent << " FILE \"" << toDestDirPath << "\"\n"
  556. << indent << " RPATH \"" << newRpath << "\")\n";
  557. }
  558. //----------------------------------------------------------------------------
  559. void
  560. cmInstallTargetGenerator
  561. ::AddChrpathPatchRule(std::ostream& os, Indent const& indent,
  562. const char* config, std::string const& toDestDirPath)
  563. {
  564. // Skip the chrpath if the target does not need it.
  565. if(this->ImportLibrary || !this->Target->IsChrpathUsed(config))
  566. {
  567. return;
  568. }
  569. // Get the link information for this target.
  570. // It can provide the RPATH.
  571. cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config);
  572. if(!cli)
  573. {
  574. return;
  575. }
  576. // Construct the original rpath string to be replaced.
  577. std::string oldRpath = cli->GetRPathString(false);
  578. // Get the install RPATH from the link information.
  579. std::string newRpath = cli->GetChrpathString();
  580. // Skip the rule if the paths are identical
  581. if(oldRpath == newRpath)
  582. {
  583. return;
  584. }
  585. // Write a rule to run chrpath to set the install-tree RPATH
  586. if(newRpath.empty())
  587. {
  588. os << indent << "FILE(RPATH_REMOVE\n"
  589. << indent << " FILE \"" << toDestDirPath << "\")\n";
  590. }
  591. else
  592. {
  593. os << indent << "FILE(RPATH_CHANGE\n"
  594. << indent << " FILE \"" << toDestDirPath << "\"\n"
  595. << indent << " OLD_RPATH \"" << oldRpath << "\"\n"
  596. << indent << " NEW_RPATH \"" << newRpath << "\")\n";
  597. }
  598. }
  599. //----------------------------------------------------------------------------
  600. void
  601. cmInstallTargetGenerator::AddStripRule(std::ostream& os,
  602. Indent const& indent,
  603. const std::string& toDestDirPath)
  604. {
  605. // don't strip static libraries, because it removes the only symbol table
  606. // they have so you can't link to them anymore
  607. if(this->Target->GetType() == cmTarget::STATIC_LIBRARY)
  608. {
  609. return;
  610. }
  611. // Don't handle OSX Bundles.
  612. if(this->Target->GetMakefile()->IsOn("APPLE") &&
  613. this->Target->GetPropertyAsBool("MACOSX_BUNDLE"))
  614. {
  615. return;
  616. }
  617. if(! this->Target->GetMakefile()->IsSet("CMAKE_STRIP"))
  618. {
  619. return;
  620. }
  621. os << indent << "IF(CMAKE_INSTALL_DO_STRIP)\n";
  622. os << indent << " EXECUTE_PROCESS(COMMAND \""
  623. << this->Target->GetMakefile()->GetDefinition("CMAKE_STRIP")
  624. << "\" \"" << toDestDirPath << "\")\n";
  625. os << indent << "ENDIF(CMAKE_INSTALL_DO_STRIP)\n";
  626. }
  627. //----------------------------------------------------------------------------
  628. void
  629. cmInstallTargetGenerator::AddRanlibRule(std::ostream& os,
  630. Indent const& indent,
  631. const std::string& toDestDirPath)
  632. {
  633. // Static libraries need ranlib on this platform.
  634. if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
  635. {
  636. return;
  637. }
  638. // Perform post-installation processing on the file depending
  639. // on its type.
  640. if(!this->Target->GetMakefile()->IsOn("APPLE"))
  641. {
  642. return;
  643. }
  644. std::string ranlib =
  645. this->Target->GetMakefile()->GetRequiredDefinition("CMAKE_RANLIB");
  646. if(ranlib.empty())
  647. {
  648. return;
  649. }
  650. os << indent << "EXECUTE_PROCESS(COMMAND \""
  651. << ranlib << "\" \"" << toDestDirPath << "\")\n";
  652. }