Ninja: LINK_OPTIONS property should support newlines

Fixes: #25513
This commit is contained in:
Marc Chevrier
2023-12-20 16:28:53 +01:00
parent 158316dc0c
commit 255c2e1430
7 changed files with 36 additions and 1 deletions
+1
View File
@@ -564,6 +564,7 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm)
this->Comspec = "cmd.exe"; this->Comspec = "cmd.exe";
} }
#endif #endif
cm->GetState()->SetNinja(true);
this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake"; this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake";
} }
+9
View File
@@ -275,6 +275,9 @@ std::string cmOutputConverter::EscapeForShell(cm::string_view str,
if (this->GetState()->UseNMake()) { if (this->GetState()->UseNMake()) {
flags |= Shell_Flag_NMake; flags |= Shell_Flag_NMake;
} }
if (this->GetState()->UseNinja()) {
flags |= Shell_Flag_Ninja;
}
if (!this->GetState()->UseWindowsShell()) { if (!this->GetState()->UseWindowsShell()) {
flags |= Shell_Flag_IsUnix; flags |= Shell_Flag_IsUnix;
} }
@@ -677,6 +680,12 @@ std::string cmOutputConverter::Shell_GetArgument(cm::string_view in, int flags)
/* Otherwise a semicolon is written just ;. */ /* Otherwise a semicolon is written just ;. */
out += ';'; out += ';';
} }
} else if (*cit == '\n') {
if (flags & Shell_Flag_Ninja) {
out += "$\n";
} else {
out += '\n';
}
} else { } else {
/* Store this character. */ /* Store this character. */
out += *cit; out += *cit;
+4 -1
View File
@@ -100,7 +100,10 @@ public:
Shell_Flag_UnescapeNinjaConfiguration = (1 << 9), Shell_Flag_UnescapeNinjaConfiguration = (1 << 9),
Shell_Flag_IsResponse = (1 << 10) Shell_Flag_IsResponse = (1 << 10),
/** The target shell is in a Ninja build file. */
Shell_Flag_Ninja = (1 << 11)
}; };
std::string EscapeForShell(cm::string_view str, bool makeVars = false, std::string EscapeForShell(cm::string_view str, bool makeVars = false,
+10
View File
@@ -752,6 +752,16 @@ bool cmState::UseMSYSShell() const
return this->MSYSShell; return this->MSYSShell;
} }
void cmState::SetNinja(bool ninja)
{
this->Ninja = ninja;
}
bool cmState::UseNinja() const
{
return this->Ninja;
}
void cmState::SetNinjaMulti(bool ninjaMulti) void cmState::SetNinjaMulti(bool ninjaMulti)
{ {
this->NinjaMulti = ninjaMulti; this->NinjaMulti = ninjaMulti;
+3
View File
@@ -220,6 +220,8 @@ public:
bool UseNMake() const; bool UseNMake() const;
void SetMSYSShell(bool mSYSShell); void SetMSYSShell(bool mSYSShell);
bool UseMSYSShell() const; bool UseMSYSShell() const;
void SetNinja(bool ninja);
bool UseNinja() const;
void SetNinjaMulti(bool ninjaMulti); void SetNinjaMulti(bool ninjaMulti);
bool UseNinjaMulti() const; bool UseNinjaMulti() const;
@@ -297,6 +299,7 @@ private:
bool MinGWMake = false; bool MinGWMake = false;
bool NMake = false; bool NMake = false;
bool MSYSShell = false; bool MSYSShell = false;
bool Ninja = false;
bool NinjaMulti = false; bool NinjaMulti = false;
Mode StateMode = Unknown; Mode StateMode = Unknown;
ProjectKind StateProjectKind = ProjectKind::Normal; ProjectKind StateProjectKind = ProjectKind::Normal;
@@ -0,0 +1,7 @@
enable_language(C)
add_library(hello STATIC hello.c)
target_link_options(hello PRIVATE "-FLAGS=[
FLAG1,
FLAG2]")
+2
View File
@@ -405,3 +405,5 @@ endfunction()
if(CMake_TEST_Qt_version) if(CMake_TEST_Qt_version)
run_QtAutoMocSkipPch() run_QtAutoMocSkipPch()
endif() endif()
run_cmake(LINK_OPTIONSWithNewlines)