CMakeSetupCMD.cxx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2000 National Library of Medicine
  8. All rights reserved.
  9. See COPYRIGHT.txt for copyright details.
  10. =========================================================================*/
  11. #include "cmStandardIncludes.h"
  12. #include "cmMakefile.h"
  13. #include "cmMSProjectGenerator.h"
  14. #include "cmCacheManager.h"
  15. // this is the command line version of CMakeSetup.
  16. // It is called from Visual Studio when a CMakeLists.txt
  17. // file is changed.
  18. // Set the command line arguments
  19. void SetArgs(cmMakefile& builder, int ac, char** av)
  20. {
  21. for(int i =3; i < ac; i++)
  22. {
  23. std::string arg = av[i];
  24. if(arg.find("-H",0) != std::string::npos)
  25. {
  26. std::string path = arg.substr(2);
  27. builder.SetHomeDirectory(path.c_str());
  28. }
  29. if(arg.find("-S",0) != std::string::npos)
  30. {
  31. std::string path = arg.substr(2);
  32. builder.SetStartDirectory(path.c_str());
  33. }
  34. if(arg.find("-O",0) != std::string::npos)
  35. {
  36. std::string path = arg.substr(2);
  37. builder.SetStartOutputDirectory(path.c_str());
  38. }
  39. if(arg.find("-B",0) != std::string::npos)
  40. {
  41. std::string path = arg.substr(2);
  42. builder.SetHomeOutputDirectory(path.c_str());
  43. std::cout << "set output home to " << path.c_str() << std::endl;
  44. }
  45. }
  46. }
  47. int main(int ac, char** av)
  48. {
  49. if(ac < 3)
  50. {
  51. std::cerr << "Usage: " << av[0] <<
  52. " CMakeLists.txt -[DSP|DSW] -Hsource_home -Sstart_source_directory "
  53. " -Ostart_output_directory -Boutput_home" << std::endl;
  54. return -1;
  55. }
  56. std::string arg = av[2];
  57. cmMakefile makefile;
  58. SetArgs(makefile, ac, av);
  59. cmMSProjectGenerator* pg = new cmMSProjectGenerator;
  60. if(arg.find("-DSP", 0) != std::string::npos)
  61. {
  62. pg->BuildDSWOff();
  63. }
  64. else
  65. {
  66. pg->BuildDSWOn();
  67. }
  68. makefile.SetMakefileGenerator(pg);
  69. makefile.MakeStartDirectoriesCurrent();
  70. cmCacheManager::GetInstance()->LoadCache(&makefile);
  71. makefile.ReadListFile(av[1]);
  72. makefile.GenerateMakefile();
  73. cmCacheManager::GetInstance()->SaveCache(&makefile);
  74. return 0;
  75. }