cmInstallGenerator.cxx 3.5 KB

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