Skip to content

Add custom preprocessor defines and a macOS/iOS renderer selector - #651

Merged
danoli3 merged 1 commit into
openframeworks:masterfrom
danoli3:macos-renderer-defines
Sep 18, 2026
Merged

danoli3 merged 1 commit into
openframeworks:masterfrom
danoli3:macos-renderer-defines

Conversation

@danoli3

@danoli3 danoli3 commented Sep 12, 2026

Copy link
Copy Markdown
Member

Adds CLI/GUI support for custom preprocessor defines, plus an Xcode-only Renderer selector for OpenGL, ANGLE, and Dawn.
Also fixes a pre-existing Xcode JSON bug that corrupted array-valued build settings, verified across CLI, addons, Debug/Release, and Electron GUI.

@danoli3
danoli3 force-pushed the macos-renderer-defines branch from f2784e5 to 1661486 Compare September 14, 2026 07:41
New -D/--defines CLI flag (comma-separated KEY[=VALUE] list) applies
project-level preprocessor defines via a new public addProjectDefine()
wrapper around the existing (protected) addDefine(). GUI: a "Custom
defines" text field on all platforms, plus a Renderer dropdown shown
for the Xcode-based osx/ios/macos targets that writes OF_USE_ANGLE=1
or OF_USE_DAWN=1 alongside any manually-entered defines.

Found and fixed a real pre-existing bug while wiring this up:
xcodeProject::saveProjectFile()'s "fixing XCode one item array" logic
used `auto v { j[p] }` (brace-init) instead of `auto v = j[p]`
(copy-init). nlohmann::json's initializer_list constructor wraps a
single json value in an array, so on a freshly-created key (j[p] ==
null) this made v == [null] instead of null, and that got pushed into
the array instead of being correctly skipped - corrupting the first
element of *every* freshly-created array-valued Xcode build setting
with a leading [null], including GCC_PREPROCESSOR_DEFINITIONS for any
addon using ADDON_DEFINES, not just this new feature.

Verified with a real build: generated an osx project with -D and
confirmed GCC_PREPROCESSOR_DEFINITIONS ends up correct and duplicate-
free for both Debug and Release; regression-tested against an addon
using ADDON_DEFINES to confirm the existing addon-defines path also
now works correctly (it was silently broken by the same bug before).
@danoli3
danoli3 force-pushed the macos-renderer-defines branch from 1661486 to 11279ed Compare September 14, 2026 14:11
@danoli3
danoli3 merged commit ffba707 into openframeworks:master Sep 18, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant