cmInstallGenerator.cxx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. const char* file,
  47. bool optional /* = false */,
  48. const char* properties /* = 0 */,
  49. const char* permissions /* = 0 */,
  50. std::vector<std::string> const& configurations,
  51. const char* component /* = 0 */,
  52. const char* rename /* = 0 */
  53. )
  54. {
  55. // Use the FILE command to install the file.
  56. std::string stype;
  57. switch(type)
  58. {
  59. case cmTarget::INSTALL_DIRECTORY:stype = "DIRECTORY"; break;
  60. case cmTarget::INSTALL_PROGRAMS: stype = "PROGRAM"; break;
  61. case cmTarget::EXECUTABLE: stype = "EXECUTABLE"; break;
  62. case cmTarget::STATIC_LIBRARY: stype = "STATIC_LIBRARY"; break;
  63. case cmTarget::SHARED_LIBRARY: stype = "SHARED_LIBRARY"; break;
  64. case cmTarget::MODULE_LIBRARY: stype = "MODULE"; break;
  65. case cmTarget::INSTALL_FILES:
  66. default: stype = "FILE"; break;
  67. }
  68. os << "FILE(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str();
  69. if(optional)
  70. {
  71. os << " OPTIONAL";
  72. }
  73. if(properties && *properties)
  74. {
  75. os << " PROPERTIES" << properties;
  76. }
  77. if(permissions && *permissions)
  78. {
  79. os << " PERMISSIONS" << permissions;
  80. }
  81. if(rename && *rename)
  82. {
  83. os << " RENAME \"" << rename << "\"";
  84. }
  85. if(!configurations.empty())
  86. {
  87. os << " CONFIGURATIONS";
  88. for(std::vector<std::string>::const_iterator c = configurations.begin();
  89. c != configurations.end(); ++c)
  90. {
  91. os << " \"" << *c << "\"";
  92. }
  93. }
  94. if(component && *component)
  95. {
  96. os << " COMPONENTS \"" << component << "\"";
  97. }
  98. os << " FILES \"" << file << "\")\n";
  99. }