cmInstallGenerator.cxx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmInstallGenerator.h"
  14. #include "cmSystemTools.h"
  15. #include "cmTarget.h"
  16. //----------------------------------------------------------------------------
  17. cmInstallGenerator
  18. ::cmInstallGenerator()
  19. {
  20. this->ConfigurationName = 0;
  21. this->ConfigurationTypes = 0;
  22. }
  23. //----------------------------------------------------------------------------
  24. cmInstallGenerator
  25. ::~cmInstallGenerator()
  26. {
  27. }
  28. //----------------------------------------------------------------------------
  29. void
  30. cmInstallGenerator
  31. ::Generate(std::ostream& os, const char* config,
  32. std::vector<std::string> const& configurationTypes)
  33. {
  34. this->ConfigurationName = config;
  35. this->ConfigurationTypes = &configurationTypes;
  36. this->GenerateScript(os);
  37. this->ConfigurationName = 0;
  38. this->ConfigurationTypes = 0;
  39. }
  40. //----------------------------------------------------------------------------
  41. void cmInstallGenerator
  42. ::AddInstallRule(
  43. std::ostream& os,
  44. const char* dest,
  45. int type,
  46. std::vector<std::string> const& files,
  47. bool optional /* = false */,
  48. const char* properties /* = 0 */,
  49. const char* permissions_file /* = 0 */,
  50. const char* permissions_dir /* = 0 */,
  51. std::vector<std::string> const& configurations,
  52. const char* component /* = 0 */,
  53. const char* rename /* = 0 */,
  54. const char* literal_args /* = 0 */,
  55. cmInstallGeneratorIndent const& indent
  56. )
  57. {
  58. // Use the FILE command to install the file.
  59. std::string stype;
  60. switch(type)
  61. {
  62. case cmTarget::INSTALL_DIRECTORY:stype = "DIRECTORY"; break;
  63. case cmTarget::INSTALL_PROGRAMS: stype = "PROGRAM"; break;
  64. case cmTarget::EXECUTABLE: stype = "EXECUTABLE"; break;
  65. case cmTarget::STATIC_LIBRARY: stype = "STATIC_LIBRARY"; break;
  66. case cmTarget::SHARED_LIBRARY: stype = "SHARED_LIBRARY"; break;
  67. case cmTarget::MODULE_LIBRARY: stype = "MODULE"; break;
  68. case cmTarget::INSTALL_FILES:
  69. default: stype = "FILE"; break;
  70. }
  71. os << indent;
  72. os << "FILE(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str();
  73. if(optional)
  74. {
  75. os << " OPTIONAL";
  76. }
  77. if(properties && *properties)
  78. {
  79. os << " PROPERTIES" << properties;
  80. }
  81. if(permissions_file && *permissions_file)
  82. {
  83. os << " PERMISSIONS" << permissions_file;
  84. }
  85. if(permissions_dir && *permissions_dir)
  86. {
  87. os << " DIR_PERMISSIONS" << permissions_dir;
  88. }
  89. if(rename && *rename)
  90. {
  91. os << " RENAME \"" << rename << "\"";
  92. }
  93. if(!configurations.empty())
  94. {
  95. os << " CONFIGURATIONS";
  96. for(std::vector<std::string>::const_iterator c = configurations.begin();
  97. c != configurations.end(); ++c)
  98. {
  99. os << " \"" << *c << "\"";
  100. }
  101. }
  102. if(component && *component)
  103. {
  104. os << " COMPONENTS \"" << component << "\"";
  105. }
  106. os << " FILES";
  107. if(files.size() == 1)
  108. {
  109. os << " \"" << files[0] << "\"";
  110. }
  111. else
  112. {
  113. for(std::vector<std::string>::const_iterator fi = files.begin();
  114. fi != files.end(); ++fi)
  115. {
  116. os << "\n" << indent << " \"" << *fi << "\"";
  117. }
  118. os << "\n" << indent << " ";
  119. if(!(literal_args && *literal_args))
  120. {
  121. os << " ";
  122. }
  123. }
  124. if(literal_args && *literal_args)
  125. {
  126. os << literal_args;
  127. }
  128. os << ")\n";
  129. }