CMakeCommandLineInfo.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. if (sParam[1] == '=' || sParam[1] == ':')
  50. {
  51. CString value(sParam.Right(sParam.GetLength() - 2));
  52. int res;
  53. switch (sParam[0])
  54. {
  55. case 'A':
  56. res = CMakeCommandLineInfo::GetBoolValue(value);
  57. if (res == 1)
  58. {
  59. m_AdvancedValues = TRUE;
  60. }
  61. else if (res == -1)
  62. {
  63. m_AdvancedValues = FALSE;
  64. }
  65. break;
  66. case 'B':
  67. m_WhereBuild = value;
  68. break;
  69. case 'G':
  70. m_GeneratorChoiceString = value;
  71. break;
  72. case 'H':
  73. m_WhereSource = value;
  74. break;
  75. }
  76. }
  77. }
  78. // Call the base class to ensure proper command line processing
  79. CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
  80. }