cmInstallGenerator.cxx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. )
  56. {
  57. // Use the FILE command to install the file.
  58. std::string stype;
  59. switch(type)
  60. {
  61. case cmTarget::INSTALL_DIRECTORY:stype = "DIRECTORY"; break;
  62. case cmTarget::INSTALL_PROGRAMS: stype = "PROGRAM"; break;
  63. case cmTarget::EXECUTABLE: stype = "EXECUTABLE"; break;
  64. case cmTarget::STATIC_LIBRARY: stype = "STATIC_LIBRARY"; break;
  65. case cmTarget::SHARED_LIBRARY: stype = "SHARED_LIBRARY"; break;
  66. case cmTarget::MODULE_LIBRARY: stype = "MODULE"; break;
  67. case cmTarget::INSTALL_FILES:
  68. default: stype = "FILE"; break;
  69. }
  70. os << "FILE(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str();
  71. if(optional)
  72. {
  73. os << " OPTIONAL";
  74. }
  75. if(properties && *properties)
  76. {
  77. os << " PROPERTIES" << properties;
  78. }
  79. if(permissions_file && *permissions_file)
  80. {
  81. os << " PERMISSIONS" << permissions_file;
  82. }
  83. if(permissions_dir && *permissions_dir)
  84. {
  85. os << " DIR_PERMISSIONS" << permissions_dir;
  86. }
  87. if(rename && *rename)
  88. {
  89. os << " RENAME \"" << rename << "\"";
  90. }
  91. if(!configurations.empty())
  92. {
  93. os << " CONFIGURATIONS";
  94. for(std::vector<std::string>::const_iterator c = configurations.begin();
  95. c != configurations.end(); ++c)
  96. {
  97. os << " \"" << *c << "\"";
  98. }
  99. }
  100. if(component && *component)
  101. {
  102. os << " COMPONENTS \"" << component << "\"";
  103. }
  104. os << " FILES";
  105. if(files.size() == 1)
  106. {
  107. os << " \"" << files[0] << "\"";
  108. }
  109. else
  110. {
  111. for(std::vector<std::string>::const_iterator fi = files.begin();
  112. fi != files.end(); ++fi)
  113. {
  114. os << "\n \"" << *fi << "\"";
  115. }
  116. os << "\n ";
  117. if(!(literal_args && *literal_args))
  118. {
  119. os << " ";
  120. }
  121. }
  122. if(literal_args && *literal_args)
  123. {
  124. os << literal_args;
  125. }
  126. os << ")\n";
  127. }