cmakemain.cxx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 "cmakewizard.h"
  14. #include "cmake.h"
  15. #include "cmCacheManager.h"
  16. #include "cmDynamicLoader.h"
  17. #include "cmListFileCache.h"
  18. #include "cmDocumentation.h"
  19. //----------------------------------------------------------------------------
  20. static const cmDocumentationEntry cmDocumentationName[] =
  21. {
  22. {"cmake",
  23. "- Cross-Platform Makefile Generator.", 0},
  24. {0,0,0}
  25. };
  26. //----------------------------------------------------------------------------
  27. static const cmDocumentationEntry cmDocumentationUsage[] =
  28. {
  29. {0,
  30. "cmake <path-to-source>", 0},
  31. {0,0,0}
  32. };
  33. //----------------------------------------------------------------------------
  34. static const cmDocumentationEntry cmDocumentationDescription[] =
  35. {
  36. {0,
  37. "CMake reads ... ", 0},
  38. {0,0,0}
  39. };
  40. int do_cmake(int ac, char** av);
  41. void updateProgress(const char *msg, float prog, void *cd);
  42. int main(int ac, char** av)
  43. {
  44. cmSystemTools::EnableMSVCDebugHook();
  45. int ret = do_cmake(ac, av);
  46. #ifdef CMAKE_BUILD_WITH_CMAKE
  47. cmDynamicLoader::FlushCache();
  48. #endif
  49. cmListFileCache::GetInstance()->ClearCache();
  50. return ret;
  51. }
  52. int do_cmake(int ac, char** av)
  53. {
  54. cmDocumentation doc;
  55. if(cmDocumentation::Type ht = doc.CheckOptions(ac, av))
  56. {
  57. cmake hcm;
  58. std::vector<cmDocumentationEntry> commands;
  59. hcm.GetCommandDocumentation(commands);
  60. doc.SetName(cmDocumentationName);
  61. doc.SetUsage(cmDocumentationUsage);
  62. doc.SetDescription(cmDocumentationDescription);
  63. doc.SetCommands(&commands[0]);
  64. doc.Print(ht, std::cout);
  65. return 0;
  66. }
  67. bool wiz = false;
  68. bool command = false;
  69. std::vector<std::string> args;
  70. for(int i =0; i < ac; ++i)
  71. {
  72. if(strcmp(av[i], "-i") == 0)
  73. {
  74. wiz = true;
  75. }
  76. else if (strcmp(av[i], "-E") == 0)
  77. {
  78. command = true;
  79. }
  80. else
  81. {
  82. args.push_back(av[i]);
  83. }
  84. }
  85. if(command)
  86. {
  87. int ret = cmake::CMakeCommand(args);
  88. return ret;
  89. }
  90. if (wiz)
  91. {
  92. cmakewizard wizard;
  93. wizard.RunWizard(args);
  94. return 0;
  95. }
  96. cmake cm;
  97. cm.SetProgressCallback(updateProgress, 0);
  98. return cm.Run(args);
  99. }
  100. void updateProgress(const char *msg, float prog, void*)
  101. {
  102. if ( prog < 0 )
  103. {
  104. std::cout << "-- " << msg << std::endl;
  105. }
  106. //else
  107. //{
  108. //std::cout << "-- " << msg << " " << prog << std::endl;
  109. //}
  110. }