fix!(cmake): require CMake 3.10 and quote custom command comments - #361
Merged
Merged
Conversation
The generated `cmake_minimum_required(VERSION 2.8.8)` is rejected by
CMake 4.0+, which removed compatibility with versions older than 3.5,
unless `CMAKE_POLICY_VERSION_MINIMUM` is set. CMake 3.31+ also warns for
anything older than 3.10. Require 3.10; it sets the policy version too,
so the separate `cmake_policy()` call is dropped.
`COMMENT` values of actions, rules and copies were written unquoted, so
any message containing spaces was split into several arguments. CMake
3.31+ reports this under CMP0175 (and errors once the policy is NEW).
A `#` or an unbalanced parenthesis in a message would also break
parsing. Quote and escape them like other generated strings; variable
references such as `${RULE_INPUT_NAME}` are still expanded.
Assisted-by: Claude Code
Signed-off-by: gengjiawen <technicalcute@gmail.com>
legendecas
approved these changes
Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The CMake generator's output doesn't work cleanly with current CMake releases:
cmake_minimum_required(VERSION 2.8.8)is a hard error on CMake 4.0+ (compatibility with < 3.5 was removed) unless-DCMAKE_POLICY_VERSION_MINIMUM=3.5is passed, and CMake 3.31+ warns for anything below 3.10.COMMENTfor actions, rules and copies is written unquoted, so a message likeChecking inspector protocol compatibilitybecomes several arguments. CMake 3.31+ warns under CMP0175 (and errors once the policy is NEW). A#or an unbalanced parenthesis in a message would also break parsing.This requires CMake 3.10 (dropping the now redundant
cmake_policy()call) and writesCOMMENTas a quoted, escaped string.${...}references such as${RULE_INPUT_NAME}are still expanded.Tested by generating Node.js with
tools/gyp_node.py -f cmakeand configuring with CMake 4.4:CMAKE_POLICY_VERSION_MINIMUMAdded unit tests in
pylib/gyp/generator/cmake_test.pyand updated the cmake integration test fixtures.BEGIN_COMMIT_OVERRIDE
fix(cmake): require CMake 3.10 and quote custom command comments (#361)
END_COMMIT_OVERRIDE