Skip to content

cmake: parse EXTRAFLAGS with separate_arguments - #20021

Open
r3wretrhy wants to merge 1 commit into
apache:masterfrom
r3wretrhy:cmake-extraflags-separate-arguments
Open

cmake: parse EXTRAFLAGS with separate_arguments#20021
r3wretrhy wants to merge 1 commit into
apache:masterfrom
r3wretrhy:cmake-extraflags-separate-arguments

Conversation

@r3wretrhy

Copy link
Copy Markdown

cmake: parse EXTRAFLAGS with separate_arguments.

Summary

Impact

  • Is new feature added? Is existing feature changed? NO
  • Impact on user (will user need to adapt to change)? NO
  • Impact on build (will build process change)? YES. EXTRAFLAGS is parsed with shell quoting instead of a naive space split.
  • Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO
  • Impact on documentation (is update required / provided)? NO
  • Impact on security (any sort of implications)? NO
  • Impact on compatibility (backward/forward/interoperability)? NO. Unquoted space-separated flags still become one option each.

Testing

I confirm that changes are verified on local setup and works as intended:

  • Build Host(s): Windows 11, CMake 3.29.2
  • Target(s): cmake -P parse check of EXTRAFLAGS (host CMake, no board image)

Testing logs before change:

EXTRAFLAGS=-Wno-cpp -Werror -I"/tmp/path with spaces/include" string(REPLACE " " ";") OLD_LEN=5 OLD_ITEM=[-Wno-cpp] OLD_ITEM=[-Werror] OLD_ITEM=[-I"/tmp/path] OLD_ITEM=[with] OLD_ITEM=[spaces/include"]

Testing logs after change:

separate_arguments(UNIX_COMMAND) NEW_LEN=3 NEW_ITEM=[-Wno-cpp] NEW_ITEM=[-Werror] NEW_ITEM=[-I/tmp/path with spaces/include] EXTRAFLAGS_PARSE_OK

PR verification Self-Check

  • This PR introduces only one functional change.
  • I have updated all required description fields above.
  • My PR adheres to Contributing Guidelines and Documentation (git commit title and message, coding standard, etc).
  • My PR is still work in progress (not ready for review).
  • My PR is ready for review and can be safely merged into a codebase.

@r3wretrhy
r3wretrhy force-pushed the cmake-extraflags-separate-arguments branch 2 times, most recently from baccc68 to e61f060 Compare August 31, 2026 09:00
string(REPLACE) splits on every space, so a flag such as
-I"/path with spaces" becomes several bogus compile options.
Use separate_arguments(UNIX_COMMAND), matching EXTRA_FLAGS.

Signed-off-by: Zhaoqi Xu <lzy00419@outlook.com>
@r3wretrhy
r3wretrhy force-pushed the cmake-extraflags-separate-arguments branch from e61f060 to 8da56b4 Compare August 31, 2026 09:22
@github-actions github-actions Bot added Area: Build system Size: XS The size of the change in this PR is very small labels Aug 31, 2026
@github-actions

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: Build system Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants