experimental: move platform preprocessor definitions to cmake#1738
Draft
antoinevg wants to merge 3 commits intogreatscottgadgets:mainfrom
Draft
experimental: move platform preprocessor definitions to cmake#1738antoinevg wants to merge 3 commits intogreatscottgadgets:mainfrom
antoinevg wants to merge 3 commits intogreatscottgadgets:mainfrom
Conversation
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.
This PR moves the platform definitions (e.g.
IS_PRALINE,IS_HACKRF_ONEetc.) intocmake.The specific issues it addresses are:
platform_detect.hmatters whenever#ifdef IS_<some_board>is used. If it is not included first it can result in compile errors that are not immediately obvious.include-what-you-useresulting in a sprinkling ofIWYU pragma: keepacross the sources.These have caused some friction for me recently.
The downsides are:
cmake.add_compile_definitions()which is only available incmake >= 3.12. Though it could be implemented usingadd_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.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.ha little less fraught.Would love to hear feedback!