CMakeCommandLineInfo.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. m_WhereSource = _T("");
  15. m_WhereBuild = _T("");
  16. m_AdvancedValues = FALSE;
  17. m_GeneratorChoiceString = _T("");
  18. }
  19. CMakeCommandLineInfo::~CMakeCommandLineInfo()
  20. {
  21. }
  22. int CMakeCommandLineInfo::GetBoolValue(const CString& v) {
  23. CString value = v;
  24. value.MakeLower();
  25. if (value == "1" ||
  26. value == "on" ||
  27. value == "true" ||
  28. value == "yes")
  29. {
  30. return 1;
  31. }
  32. else if (value == "0" ||
  33. value == "off" ||
  34. value == "false" ||
  35. value == "no")
  36. {
  37. return -1;
  38. }
  39. return 0;
  40. }
  41. ///////////////////////////////////////////////////////////////
  42. // Parse param
  43. void CMakeCommandLineInfo::ParseParam(LPCTSTR lpszParam, BOOL bFlag, BOOL bLast)
  44. {
  45. if(bFlag)
  46. {
  47. CString sParam(lpszParam);
  48. // Single letter valued flag like /B=value or /B:value
  49. CString value;
  50. if (sParam[1] == '=' || sParam[1] == ':')
  51. {
  52. value = sParam.Right(sParam.GetLength() - 2);
  53. }
  54. else
  55. {
  56. value = sParam.Right(sParam.GetLength()-1);
  57. }
  58. int res;
  59. switch (sParam[0])
  60. {
  61. case 'A':
  62. res = CMakeCommandLineInfo::GetBoolValue(value);
  63. if (res == 1)
  64. {
  65. m_AdvancedValues = TRUE;
  66. }
  67. else if (res == -1)
  68. {
  69. m_AdvancedValues = FALSE;
  70. }
  71. break;
  72. case 'B':
  73. m_WhereBuild = value;
  74. break;
  75. case 'G':
  76. m_GeneratorChoiceString = value;
  77. break;
  78. case 'H':
  79. m_WhereSource = value;
  80. break;
  81. }
  82. }
  83. // Call the base class to ensure proper command line processing
  84. CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
  85. }