CMakeCommandLineInfo.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // CMakeCommandLineInfo.cpp : command line arguments
  2. //
  3. #include "stdafx.h"
  4. #include "CMakeCommandLineInfo.h"
  5. #ifdef _DEBUG
  6. #define new DEBUG_NEW
  7. #undef THIS_FILE
  8. static char THIS_FILE[] = __FILE__;
  9. #endif
  10. ///////////////////////////////////////////////////////////////
  11. // CMakeCommandLineInfo
  12. CMakeCommandLineInfo::CMakeCommandLineInfo()
  13. {
  14. this->m_WhereSource = _T("");
  15. this->m_WhereBuild = _T("");
  16. this->m_AdvancedValues = FALSE;
  17. this->m_GeneratorChoiceString = _T("");
  18. this->m_LastUnknownParameter = _T("");
  19. }
  20. CMakeCommandLineInfo::~CMakeCommandLineInfo()
  21. {
  22. }
  23. int CMakeCommandLineInfo::GetBoolValue(const CString& v) {
  24. CString value = v;
  25. value.MakeLower();
  26. if (value == "1" ||
  27. value == "on" ||
  28. value == "true" ||
  29. value == "yes")
  30. {
  31. return 1;
  32. }
  33. else if (value == "0" ||
  34. value == "off" ||
  35. value == "false" ||
  36. value == "no")
  37. {
  38. return -1;
  39. }
  40. return 0;
  41. }
  42. ///////////////////////////////////////////////////////////////
  43. // Parse param
  44. void CMakeCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
  45. {
  46. if(!bFlag)
  47. {
  48. this->m_LastUnknownParameter = lpszParam;
  49. }
  50. else
  51. {
  52. CString sParam(lpszParam);
  53. // Single letter valued flag like /B=value or /B:value
  54. CString value;
  55. if (sParam[1] == '=' || sParam[1] == ':')
  56. {
  57. value = sParam.Right(sParam.GetLength() - 2);
  58. }
  59. else
  60. {
  61. value = sParam.Right(sParam.GetLength()-1);
  62. }
  63. int res;
  64. switch (sParam[0])
  65. {
  66. case 'A':
  67. res = CMakeCommandLineInfo::GetBoolValue(value);
  68. if (res == 1)
  69. {
  70. this->m_AdvancedValues = TRUE;
  71. }
  72. else if (res == -1)
  73. {
  74. this->m_AdvancedValues = FALSE;
  75. }
  76. break;
  77. case 'B':
  78. this->m_WhereBuild = value;
  79. break;
  80. case 'G':
  81. this->m_GeneratorChoiceString = value;
  82. break;
  83. case 'H':
  84. this->m_WhereSource = value;
  85. break;
  86. }
  87. }
  88. // Call the base class to ensure proper command line processing
  89. CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
  90. }