| 354 | } |
| 355 | |
| 356 | bool HandleCompareCommand(std::vector<std::string> const& args, |
| 357 | cmExecutionStatus& status) |
| 358 | { |
| 359 | if (args.size() < 2) { |
| 360 | status.SetError("sub-command COMPARE requires a mode to be specified."); |
| 361 | return false; |
| 362 | } |
| 363 | std::string const& mode = args[1]; |
| 364 | if ((mode == "EQUAL") || (mode == "NOTEQUAL") || (mode == "LESS") || |
| 365 | (mode == "LESS_EQUAL") || (mode == "GREATER") || |
| 366 | (mode == "GREATER_EQUAL")) { |
| 367 | if (args.size() < 5) { |
| 368 | std::string e = |
| 369 | cmStrCat("sub-command COMPARE, mode ", mode, |
| 370 | " needs at least 5 arguments total to command."); |
| 371 | status.SetError(e); |
| 372 | return false; |
| 373 | } |
| 374 | |
| 375 | std::string const& left = args[2]; |
| 376 | std::string const& right = args[3]; |
| 377 | std::string const& outvar = args[4]; |
| 378 | bool result; |
| 379 | cm::CMakeString::CompOperator op = cm::CMakeString::CompOperator::EQUAL; |
| 380 | if (mode == "LESS") { |
| 381 | op = cm::CMakeString::CompOperator::LESS; |
| 382 | } else if (mode == "LESS_EQUAL") { |
| 383 | op = cm::CMakeString::CompOperator::LESS_EQUAL; |
| 384 | } else if (mode == "GREATER") { |
| 385 | op = cm::CMakeString::CompOperator::GREATER; |
| 386 | } else if (mode == "GREATER_EQUAL") { |
| 387 | op = cm::CMakeString::CompOperator::GREATER_EQUAL; |
| 388 | } |
| 389 | result = cm::CMakeString{ left }.Compare(op, right); |
| 390 | if (mode == "NOTEQUAL") { |
| 391 | result = !result; |
| 392 | } |
| 393 | |
| 394 | status.GetMakefile().AddDefinition(outvar, result ? "1" : "0"); |
| 395 | return true; |
| 396 | } |
| 397 | std::string e = "sub-command COMPARE does not recognize mode " + mode; |
| 398 | status.SetError(e); |
| 399 | return false; |
| 400 | } |
| 401 | |
| 402 | bool HandleReplaceCommand(std::vector<std::string> const& args, |
| 403 | cmExecutionStatus& status) |
nothing calls this directly
no test coverage detected
searching dependent graphs…