Skip to content

experimental: move platform preprocessor definitions to cmake#1738

Draft
antoinevg wants to merge 3 commits intogreatscottgadgets:mainfrom
antoinevg:antoinevg/move-platform-defs-to-cmake
Draft

experimental: move platform preprocessor definitions to cmake#1738
antoinevg wants to merge 3 commits intogreatscottgadgets:mainfrom
antoinevg:antoinevg/move-platform-defs-to-cmake

Conversation

@antoinevg
Copy link
Copy Markdown
Member

@antoinevg antoinevg commented Apr 24, 2026

This PR moves the platform definitions (e.g. IS_PRALINE, IS_HACKRF_ONE etc.) into cmake.

The specific issues it addresses are:

  • The include order of platform_detect.h matters whenever #ifdef IS_<some_board> is used. If it is not included first it can result in compile errors that are not immediately obvious.
  • This causes false negatives with include-what-you-use resulting in a sprinkling of IWYU pragma: keep across the sources.

These have caused some friction for me recently.

The downsides are:

  • Moving things into cmake.
  • It uses add_compile_definitions() which is only available in cmake >= 3.12. Though it could be implemented using add_definitions() which would just look uglier.
  • switch (detected_platform()) can no longer evaluate that a given check is exhaustive. That said, we don't have too many of those left.
  • The optional introduction of IS_UNIVERSAL (see 3rd commit). An argument can be made that this helps to annotate portions of the code that are affected when building a universal binary but it's been nice to not have it so far.

The main advantage I see is that it generally makes the usage of platform_detect.h a little less fraught.

Would love to hear feedback!

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