From ba93b9cf49749ef57b2b85f9d9021492cc00a34e Mon Sep 17 00:00:00 2001 From: Alex Overchenko Date: Mon, 3 Aug 2026 11:55:34 +0300 Subject: [PATCH] borland: support long comments for custom commands Fixes: #28013 --- Source/cmLocalUnixMakefileGenerator3.cxx | 10 ++++++++++ Tests/RunCMake/add_custom_command/RunCMakeTest.cmake | 8 ++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 06f03ac474..c140de5281 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1241,6 +1241,16 @@ std::string cmLocalUnixMakefileGenerator3::TrimLongCommand( cm::static_string_view longCommandFinalizer = "..."_s; size_t commandLineLimit = cmSystemTools::CalculateCommandLineLengthLimit(); + + if (this->GetState()->UseBorlandMake()) { + constexpr size_t BORLAND_MAKE_COMMAND_LINE_LIMIT = 4096; + commandLineLimit = + std::min(commandLineLimit, BORLAND_MAKE_COMMAND_LINE_LIMIT); + if (commandLineLimit == 0) { + commandLineLimit = BORLAND_MAKE_COMMAND_LINE_LIMIT; + } + } + if (commandLineLimit == 0) { // No limit, just return the command as is. return cmStrCat(std::move(cmd), this->EscapeForShell(line)); diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake index 79f79fe007..ccefdb550c 100644 --- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake @@ -25,14 +25,10 @@ if(NOT RunCMake_GENERATOR STREQUAL "Xcode") run_configure_and_build(LotsOutputs) endif() # FIXME(#28019): LongCommentAutoGenerated test fails with Xcode generator on macOS 10.15 only. -# FIXME(#28013): LongCommentAutoGenerated test fails with Borland Makefiles generator. -if(NOT RunCMake_GENERATOR STREQUAL "Borland Makefiles" AND NOT RunCMake_GENERATOR STREQUAL "Xcode") +if(NOT RunCMake_GENERATOR STREQUAL "Xcode") run_configure_and_build(LongCommentAutoGenerated) endif() -# FIXME(#28013): LongCommentUserProvided test fails with Borland Makefiles generator. -if(NOT RunCMake_GENERATOR STREQUAL "Borland Makefiles") - run_configure_and_build(LongCommentUserProvided) -endif() +run_configure_and_build(LongCommentUserProvided) run_cmake(NoArguments) run_cmake(NoOutputOrTarget) run_cmake(OutputAndTarget)