| 350 | } |
| 351 | |
| 352 | std::string cmCommonTargetGenerator::GenerateCodeCheckRules( |
| 353 | cmSourceFile const& source, std::string& compilerLauncher, |
| 354 | std::string const& cmakeCmd, std::string const& config, |
| 355 | std::function<std::string(std::string const&)> const& pathConverter) |
| 356 | { |
| 357 | auto const lang = source.GetLanguage(); |
| 358 | std::string tidy; |
| 359 | std::string iwyu; |
| 360 | std::string cpplint; |
| 361 | std::string cppcheck; |
| 362 | std::string icstat; |
| 363 | std::string pvs; |
| 364 | |
| 365 | auto evaluateProp = [&](std::string const& prop) -> std::string { |
| 366 | auto const value = this->GeneratorTarget->GetProperty(prop); |
| 367 | if (!value) { |
| 368 | return std::string{}; |
| 369 | } |
| 370 | auto evaluatedProp = cmGeneratorExpression::Evaluate( |
| 371 | *value, this->GeneratorTarget->GetLocalGenerator(), config, |
| 372 | this->GeneratorTarget, nullptr, this->GeneratorTarget, lang); |
| 373 | return evaluatedProp; |
| 374 | }; |
| 375 | std::string const tidy_prop = cmStrCat(lang, "_CLANG_TIDY"); |
| 376 | tidy = evaluateProp(tidy_prop); |
| 377 | |
| 378 | if (lang == "C" || lang == "CXX") { |
| 379 | std::string const iwyu_prop = cmStrCat(lang, "_INCLUDE_WHAT_YOU_USE"); |
| 380 | iwyu = evaluateProp(iwyu_prop); |
| 381 | |
| 382 | std::string const cpplint_prop = cmStrCat(lang, "_CPPLINT"); |
| 383 | cpplint = evaluateProp(cpplint_prop); |
| 384 | |
| 385 | std::string const cppcheck_prop = cmStrCat(lang, "_CPPCHECK"); |
| 386 | cppcheck = evaluateProp(cppcheck_prop); |
| 387 | |
| 388 | std::string const icstat_prop = cmStrCat(lang, "_ICSTAT"); |
| 389 | icstat = evaluateProp(icstat_prop); |
| 390 | |
| 391 | std::string const pvs_prop = cmStrCat(lang, "_PVS_STUDIO"); |
| 392 | pvs = evaluateProp(pvs_prop); |
| 393 | } |
| 394 | |
| 395 | if (cmNonempty(iwyu) || cmNonempty(tidy) || cmNonempty(cpplint) || |
| 396 | cmNonempty(cppcheck) || cmNonempty(icstat) || cmNonempty(pvs)) { |
| 397 | std::string code_check = cmakeCmd + " -E __run_co_compile"; |
| 398 | if (!compilerLauncher.empty()) { |
| 399 | // In __run_co_compile case the launcher command is supplied |
| 400 | // via --launcher=<maybe-list> and consumed |
| 401 | code_check = |
| 402 | cmStrCat(std::move(code_check), " --launcher=", |
| 403 | this->GeneratorTarget->GetLocalGenerator()->EscapeForShell( |
| 404 | compilerLauncher)); |
| 405 | compilerLauncher.clear(); |
| 406 | } |
| 407 | if (cmNonempty(iwyu)) { |
| 408 | code_check += " --iwyu="; |
| 409 |
no test coverage detected