Makefile: Workaround mingw32-make trailing backslash trouble (#15546)

When given the command line

  tool a\ b c

mingw32-make incorrectly passes "a b" and "c" to the tool.  When given
the command line

  tool a\ b "c"

mingw32-make correctly passes "a\", "b", and "c" to the tool.

Since commit v3.1.0-rc1~861^2 (MSVC: Add properties to configure
compiler PDB files, 2014-02-24) we pass the compiler pdb option to
MS-style compiler tools as "/Fd<dir>\" but mingw32-make may consume
the backslash as escaping a following space as described above.
Workaround this problem by changing the backslash to a forward
slash as had been used prior to the above commit.
This commit is contained in:
Brad King 2015-04-30 15:25:16 -04:00
parent 91d5261b58
commit bb6663ca0a
2 changed files with 11 additions and 0 deletions

View File

@ -95,6 +95,7 @@ public:
* Set to true if the make tool being used is MinGW Make.
*/
void SetMinGWMake(bool v) {this->MinGWMake = v;}
bool IsMinGWMake() const { return this->MinGWMake; }
/**
* Set to true if the make tool being used is NMake.

View File

@ -23,6 +23,7 @@
#include "cmComputeLinkInformation.h"
#include "cmCustomCommandGenerator.h"
#include "cmGeneratorExpression.h"
#include "cmAlgorithms.h"
#include "cmMakefileExecutableTargetGenerator.h"
#include "cmMakefileLibraryTargetGenerator.h"
@ -668,6 +669,15 @@ cmMakefileTargetGenerator
this->Convert(targetFullPathCompilePDB,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
if (this->LocalGenerator->IsMinGWMake() &&
cmHasLiteralSuffix(targetOutPathCompilePDB, "\\"))
{
// mingw32-make incorrectly interprets 'a\ b c' as 'a b' and 'c'
// (but 'a\ b "c"' as 'a\', 'b', and 'c'!). Workaround this by
// avoiding a trailing backslash in the argument.
targetOutPathCompilePDB[targetOutPathCompilePDB.size()-1] = '/';
}
}
cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_COMPILE";