Move platform preprocessor definitions to cmake#1738
Move platform preprocessor definitions to cmake#1738martinling merged 3 commits intogreatscottgadgets:mainfrom
Conversation
|
If we go ahead with this, I suggest we just bump the firmware CMake requirement to 3.12 to support it. I've pushed a commit with that change to this branch. Note that we can leave the host code requirement at 3.10. My rationale for choosing 3.10 as our last bump was here, and there's no particular requirement to avoid bumping it a little further, particularly for firmware builds. CMake 3.12 was released in 2018. Debian |
e15e05a to
d82357c
Compare
7f11631 to
202fbde
Compare
|
This is getting somewhat cursed. 2252036 is a pretty verbose solution but it does express intent clearly. Unfortunately, this does not work on I've now pushed an alternate approach with 9f3182b which simply passes So the situation now is that we should probably choose one of the following:
I think the overall improvement in ergonomics is worth putting up with the small loss of coverage we get with |
0841bc9 to
9f3182b
Compare
I like this solution. I'm fine with that leaving the possibility of spurious includes of |
mossmann
left a comment
There was a problem hiding this comment.
This looks great but needs a rebase. I like the --keep solution.
|
It occured to me that an alternative to moving these defines to CMake, could be to make |
9f3182b to
f2d72af
Compare
Tempting :-) The main reason I'd rather not do that is my bias towards keeping things as explicit as practical and keeping that include in the sources for now serves as a useful marker that a given translation unit has runtime platform checks present. |
Rebased and squashed 👍 |
6429773 to
23104c7
Compare
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!