CMakeSetup.cxx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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 "QCMake.h" // include to disable MS warnings
  14. #include <QApplication>
  15. #include <QFileInfo>
  16. #include <QDir>
  17. #include "CMakeSetupDialog.h"
  18. #include "cmDocumentation.h"
  19. #include "cmSystemTools.h"
  20. #include "cmake.h"
  21. //----------------------------------------------------------------------------
  22. static const char * cmDocumentationName[][3] =
  23. {
  24. {0,
  25. " CMakeSetup - CMake GUI.", 0},
  26. {0,0,0}
  27. };
  28. //----------------------------------------------------------------------------
  29. static const char * cmDocumentationUsage[][3] =
  30. {
  31. {0,
  32. " CMakeSetup [options]\n"
  33. " CMakeSetup [options] <path-to-source>\n"
  34. " CMakeSetup [options] <path-to-existing-build>", 0},
  35. {0,0,0}
  36. };
  37. //----------------------------------------------------------------------------
  38. static const char * cmDocumentationDescription[][3] =
  39. {
  40. {0,
  41. "The \"CMakeSetup\" executable is the CMake GUI. Project "
  42. "configuration settings may be specified interactively. "
  43. "Brief instructions are provided at the bottom of the "
  44. "window when the program is running.", 0},
  45. CMAKE_STANDARD_INTRODUCTION,
  46. {0,0,0}
  47. };
  48. //----------------------------------------------------------------------------
  49. static const char * cmDocumentationOptions[][3] =
  50. {
  51. {0,0,0}
  52. };
  53. int main(int argc, char** argv)
  54. {
  55. cmSystemTools::FindExecutableDirectory(argv[0]);
  56. QApplication app(argc, argv);
  57. app.setApplicationName("CMakeSetup");
  58. app.setOrganizationName("Kitware");
  59. app.setWindowIcon(QIcon(":/Icons/CMakeSetup.png"));
  60. cmDocumentation doc;
  61. if(app.arguments().size() > 1 &&
  62. doc.CheckOptions(app.argc(), app.argv()))
  63. {
  64. // Construct and print requested documentation.
  65. cmake hcm;
  66. hcm.AddCMakePaths();
  67. doc.SetCMakeRoot(hcm.GetCacheDefinition("CMAKE_ROOT"));
  68. std::vector<cmDocumentationEntry> commands;
  69. std::vector<cmDocumentationEntry> compatCommands;
  70. std::map<std::string,cmDocumentationSection *> propDocs;
  71. std::vector<cmDocumentationEntry> generators;
  72. hcm.GetCommandDocumentation(commands, true, false);
  73. hcm.GetCommandDocumentation(compatCommands, false, true);
  74. hcm.GetGeneratorDocumentation(generators);
  75. hcm.GetPropertiesDocumentation(propDocs);
  76. doc.SetName("cmake");
  77. doc.SetSection("Name",cmDocumentationName);
  78. doc.SetSection("Usage",cmDocumentationUsage);
  79. doc.SetSection("Description",cmDocumentationDescription);
  80. doc.AppendSection("Generators",generators);
  81. doc.PrependSection("Options",cmDocumentationOptions);
  82. doc.SetSection("Commands",commands);
  83. doc.SetSection("Compatilbility Commands", compatCommands);
  84. doc.SetSections(propDocs);
  85. return (doc.PrintRequestedDocumentation(std::cout)? 0:1);
  86. }
  87. CMakeSetupDialog dialog;
  88. dialog.setWindowTitle("CMakeSetup");
  89. dialog.show();
  90. // for now: args support specifying build and/or source directory
  91. QStringList args = app.arguments();
  92. if(args.count() == 2)
  93. {
  94. QFileInfo buildFileInfo(args[1], "CMakeCache.txt");
  95. QFileInfo srcFileInfo(args[1], "CMakeLists.txt");
  96. if(buildFileInfo.exists())
  97. {
  98. dialog.setBinaryDirectory(buildFileInfo.absolutePath());
  99. }
  100. else if(srcFileInfo.exists())
  101. {
  102. dialog.setSourceDirectory(srcFileInfo.absolutePath());
  103. dialog.setBinaryDirectory(QDir::currentPath());
  104. }
  105. }
  106. return app.exec();
  107. }