cmInstallGenerator.cxx 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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::AddInstallRule(std::ostream& os,
  42. const char* dest,
  43. int type,
  44. const char* file,
  45. bool optional /* = false */,
  46. const char* properties /* = 0 */,
  47. const char* permissions /* = 0 */,
  48. const char* component /* = 0 */,
  49. const char* rename /* = 0 */)
  50. {
  51. // Use the FILE command to install the file.
  52. std::string stype;
  53. switch(type)
  54. {
  55. case cmTarget::INSTALL_DIRECTORY:stype = "DIRECTORY"; break;
  56. case cmTarget::INSTALL_PROGRAMS: stype = "PROGRAM"; break;
  57. case cmTarget::EXECUTABLE: stype = "EXECUTABLE"; break;
  58. case cmTarget::STATIC_LIBRARY: stype = "STATIC_LIBRARY"; break;
  59. case cmTarget::SHARED_LIBRARY: stype = "SHARED_LIBRARY"; break;
  60. case cmTarget::MODULE_LIBRARY: stype = "MODULE"; break;
  61. case cmTarget::INSTALL_FILES:
  62. default: stype = "FILE"; break;
  63. }
  64. os << "FILE(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str();
  65. if(optional)
  66. {
  67. os << " OPTIONAL";
  68. }
  69. if(properties && *properties)
  70. {
  71. os << " PROPERTIES" << properties;
  72. }
  73. if(permissions && *permissions)
  74. {
  75. os << " PERMISSIONS" << permissions;
  76. }
  77. if(rename && *rename)
  78. {
  79. os << " RENAME \"" << rename << "\"";
  80. }
  81. if(component && *component)
  82. {
  83. os << " COMPONENTS \"" << component << "\"";
  84. }
  85. os << " FILES \"" << file << "\")\n";
  86. }