mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-09 16:50:01 -06:00
autogen: Fix MOC_PREDEFS_CMD if CXX env var contains multiple values
Since commit 429a4527 we inject the C++ standard argument into
MOC_PREDEFS_CMD. That failed if the CXX environment variable was set to
a value like "ccache c++", because the argument was inserted between
"ccache" and "c++".
Fix this by taking CMAKE_CXX_COMPILER_ARG1 into account that contains
the compiler arguments in CXX.
Fixes: #27445
This commit is contained in:
@@ -2027,9 +2027,23 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
|
|||||||
this->GenTarget->Makefile->GetSafeDefinition(CompileOptionFlag);
|
this->GenTarget->Makefile->GetSafeDefinition(CompileOptionFlag);
|
||||||
|
|
||||||
if (!CompileOptionValue.empty()) {
|
if (!CompileOptionValue.empty()) {
|
||||||
if (this->Moc.PredefsCmd.size() >= 3) {
|
// Determine where to insert the compile option (e.g., -std=gnu++23).
|
||||||
this->Moc.PredefsCmd.insert(this->Moc.PredefsCmd.begin() + 1,
|
// CMAKE_CXX_COMPILER_PREDEFINES_COMMAND is built as:
|
||||||
CompileOptionValue);
|
// [CMAKE_CXX_COMPILER, CMAKE_CXX_COMPILER_ARG1, predefs_flags...]
|
||||||
|
// We need to insert after all compiler elements, before predefs flags.
|
||||||
|
size_t compilerElements = 1; // CMAKE_CXX_COMPILER
|
||||||
|
|
||||||
|
cmValue compilerArg1 =
|
||||||
|
this->Makefile->GetDefinition("CMAKE_CXX_COMPILER_ARG1");
|
||||||
|
if (compilerArg1 && !compilerArg1->empty()) {
|
||||||
|
std::vector<std::string> arg1List;
|
||||||
|
cmSystemTools::ParseUnixCommandLine(compilerArg1->c_str(), arg1List);
|
||||||
|
compilerElements += arg1List.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->Moc.PredefsCmd.size() > compilerElements) {
|
||||||
|
this->Moc.PredefsCmd.insert(
|
||||||
|
this->Moc.PredefsCmd.begin() + compilerElements, CompileOptionValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.SetArray("MOC_PREDEFS_CMD", this->Moc.PredefsCmd);
|
info.SetArray("MOC_PREDEFS_CMD", this->Moc.PredefsCmd);
|
||||||
|
|||||||
Reference in New Issue
Block a user