cmakemain.cxx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. int do_cmake(int ac, char** av);
  19. void updateProgress(const char *msg, float prog, void *cd);
  20. int main(int ac, char** av)
  21. {
  22. cmSystemTools::EnableMSVCDebugHook();
  23. int ret = do_cmake(ac, av);
  24. #ifdef CMAKE_BUILD_WITH_CMAKE
  25. cmDynamicLoader::FlushCache();
  26. #endif
  27. cmListFileCache::GetInstance()->ClearCache();
  28. return ret;
  29. }
  30. int do_cmake(int ac, char** av)
  31. {
  32. bool wiz = false;
  33. bool command = false;
  34. std::vector<std::string> args;
  35. for(int i =0; i < ac; ++i)
  36. {
  37. if(strcmp(av[i], "-i") == 0)
  38. {
  39. wiz = true;
  40. }
  41. else
  42. {
  43. if (strcmp(av[i], "-E") == 0)
  44. {
  45. command = true;
  46. }
  47. else
  48. {
  49. args.push_back(av[i]);
  50. }
  51. }
  52. }
  53. if(command)
  54. {
  55. int ret = cmake::CMakeCommand(args);
  56. return ret;
  57. }
  58. if (wiz)
  59. {
  60. cmakewizard wizard;
  61. wizard.RunWizard(args);
  62. return 0;
  63. }
  64. cmake cm;
  65. cm.SetProgressCallback(updateProgress, 0);
  66. return cm.Run(args);
  67. }
  68. void updateProgress(const char *msg, float prog, void*)
  69. {
  70. if ( prog < 0 )
  71. {
  72. std::cout << "-- " << msg << std::endl;
  73. }
  74. }