From b3475ba57bc839125440fe8d21f611198041434e Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 21 May 2015 15:35:45 -0400 Subject: [PATCH] Makefile: Fix _INCLUDE_WHAT_YOU_USE with CTEST_USE_LAUNCHERS The 'ctest --launch' command must be placed before the IWYU launcher on the compiler command line. Extend the RunCMake.IncludeWhatYouUse test to cover this case. The Ninja generator already does it correctly. --- Source/cmMakefileTargetGenerator.cxx | 14 +++++++------- .../IncludeWhatYouUse/C-launch-Build-stdout.txt | 4 ++++ Tests/RunCMake/IncludeWhatYouUse/C-launch.cmake | 3 +++ .../IncludeWhatYouUse/CXX-launch-Build-stdout.txt | 4 ++++ Tests/RunCMake/IncludeWhatYouUse/CXX-launch.cmake | 3 +++ .../RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake | 4 ++++ 6 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 Tests/RunCMake/IncludeWhatYouUse/C-launch-Build-stdout.txt create mode 100644 Tests/RunCMake/IncludeWhatYouUse/C-launch.cmake create mode 100644 Tests/RunCMake/IncludeWhatYouUse/CXX-launch-Build-stdout.txt create mode 100644 Tests/RunCMake/IncludeWhatYouUse/CXX-launch.cmake diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 893b70d0d..b28a701ab 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -761,13 +761,6 @@ cmMakefileTargetGenerator source.GetFullPath(), workingDirectory, compileCommand); } - // Expand placeholders in the commands. - for(std::vector::iterator i = compileCommands.begin(); - i != compileCommands.end(); ++i) - { - this->LocalGenerator->ExpandRuleVariables(*i, vars); - } - // Maybe insert an include-what-you-use runner. if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) { @@ -782,6 +775,13 @@ cmMakefileTargetGenerator } } + // Expand placeholders in the commands. + for(std::vector::iterator i = compileCommands.begin(); + i != compileCommands.end(); ++i) + { + this->LocalGenerator->ExpandRuleVariables(*i, vars); + } + // Change the command working directory to the local build tree. this->LocalGenerator->CreateCDCommand (compileCommands, diff --git a/Tests/RunCMake/IncludeWhatYouUse/C-launch-Build-stdout.txt b/Tests/RunCMake/IncludeWhatYouUse/C-launch-Build-stdout.txt new file mode 100644 index 000000000..cb7467705 --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/C-launch-Build-stdout.txt @@ -0,0 +1,4 @@ +Warning: include-what-you-use reported diagnostics: +should add these lines: +* +#include <\.\.\.> diff --git a/Tests/RunCMake/IncludeWhatYouUse/C-launch.cmake b/Tests/RunCMake/IncludeWhatYouUse/C-launch.cmake new file mode 100644 index 000000000..e66ca203e --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/C-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(C.cmake) diff --git a/Tests/RunCMake/IncludeWhatYouUse/CXX-launch-Build-stdout.txt b/Tests/RunCMake/IncludeWhatYouUse/CXX-launch-Build-stdout.txt new file mode 100644 index 000000000..cb7467705 --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/CXX-launch-Build-stdout.txt @@ -0,0 +1,4 @@ +Warning: include-what-you-use reported diagnostics: +should add these lines: +* +#include <\.\.\.> diff --git a/Tests/RunCMake/IncludeWhatYouUse/CXX-launch.cmake b/Tests/RunCMake/IncludeWhatYouUse/CXX-launch.cmake new file mode 100644 index 000000000..3002c9d68 --- /dev/null +++ b/Tests/RunCMake/IncludeWhatYouUse/CXX-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(CXX.cmake) diff --git a/Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake b/Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake index 68c6bd7d0..8f99eb104 100644 --- a/Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake +++ b/Tests/RunCMake/IncludeWhatYouUse/RunCMakeTest.cmake @@ -16,3 +16,7 @@ endfunction() run_iwyu(C) run_iwyu(CXX) +if (NOT RunCMake_GENERATOR STREQUAL "Watcom WMake") + run_iwyu(C-launch) + run_iwyu(CXX-launch) +endif()