cmake cleanup#136
Conversation
- use dependent options to de-nest some configuration (requires bumping version to 3.22) - further de-nest by inverting MINIFB_USE_WAYLAND_API to make an internal MINIFB_USE_X11_API - change old "UNIX"/"APPLE"/"IOS"/"WIN32" etc to more modern CMAKE_SYSTEM_NAME STREQUAL <name> should hopefully function no different to previous version, which i've verified for x11, but only x11 STILL A WIP, will do more later
- Remove a deprecated flag (/Gm) - Move a flag dependant on MSVC version (/sdl) to always be applied (it would previously be applied in Visual Studio 2015+, which is no longer supported by microsoft) - Clarify the comment for an exsting flag
|
Hello! I see the intention behind these changes (especially around making options more declarative and consistent), but I have a few concerns about the trade-offs introduced here.
The main driver seems to be
Replacing checks like
The new structure introduces more intermediate variables (e.g. MINIFB_USE_X11_API) and more declarative logic. While this can be beneficial in large or highly configurable projects, here it makes the flow harder to follow compared to the more direct conditional structure we had before. Overall, I’m not against improving structure, but I think these changes increase complexity without a clear payoff in this case. I’d prefer to keep a simpler approach unless we have a strong reason (e.g. new platform requirements, real maintenance issues, etc.). |
|
Hi! You can see in the code, lines 287-308, an example of the concept I was trying to implement with these changes, having all the possible build targets be seperated, yet not reliant on each other, so the code can test for them without nesting. While personally I think this is clearer and more readable, I can understand the concerns, and given that the change was only really an experiment to begin with, I could always revert it and go back to the previous structure if you feel that's neccecary. I would ideally like to keep using On point 2, these variables ( e.g line 6, although it's much longer than the alternative Overall, these changes all attempt to move the code toward a different structure that separates all the backends further, and I can understand if that's not the direction you want to take the code, if so, I can close this PR. |
|
Hi, Thanks for the detailed explanation, I understand much better what you were aiming for. On the general idea of separating build targets so they can be reasoned about independently: I’m actually OK with that direction. Having less nesting and clearer separation between backends can be a good thing if it doesn’t make the file harder to follow. Regarding On the platform checks, I don’t think it’s accurate to say that variables like APPLE, UNIX or WIN32 are discouraged in any strong sense. They’re still widely used and idiomatic in most CMake projects. Using About the specific example (the ObjC check): I understand the intention of being explicit about Darwin/iOS, but I find the longer condition harder to read. If the goal is clarity of intent, something like Finally, on the overall structure: I agree that separating the backends more cleanly is a good direction, but I’d like to avoid significantly increasing the cognitive load of the CMakeLists. Right now I feel some of the changes move us in that direction without a clear payoff. So in short: I’m open to some of the structural ideas, but I’d prefer to keep the simpler, more idiomatic approach where the benefits of the new structure aren’t clearly outweighing the added complexity. |
also introduce `LINUX` and `MACOS` variables to check those systems in a more precise way
kept the modern `cmake_dependant_option` code in a seperate path that's still prefered if the available cmake is 3.22 or over (although they should function nearly identically, having both there means that in the future the old path can be removed)
before this, it wouldn't set default values for when options were no longer relevant, and would instead use the irrelevant old values (bad) also add a comment explaining this behavior also fix inconsistancy with default OpenGL enable between the two branches
previous code used lists such as MINIFB_COMPILE_OPTIONS and MINIFB_COMPILE_DEFINITIONS to apply the same options to both the library and examples. change to just apply the options/definitions, and extend them to examples with PUBLIC scoping. (so the examples that link the library also apply these properties) also remove MINIFB_LINK_OPTIONS_LIB and MINIFB_LINK_OPTIONS_EXE, replace with PRIVATE and INTERFACE scoping with target_link_options.
- seperate opengl linking in the same way that it's seperated for source files
- remove old ${X11_Xrandr_LIB} linking, the new X11::Xrandr was added in cmake 3.14, so we're guarenteed to have it
- add a few additional comments
also fix macos source files not being added, which i accedently caused earlier on this branch
previously would specifically specify to use dwarf debugging format on djgpp, despite it being the default for gcc either in djgpp or not also removed -save-temps in the djgpp debug options, i couldn't find out a reason to use this specifically in djgpp. regular gcc compilation and dos compilation are now identical in compile flags
- apply link options correctly - stop unnececarily applying the -g flag in debug mode (as of my testing, it's applied automatically by the toolchain when release type is set to debug)
|
This could probably be merged now; I've tested it's functionally identical on X11 and Emscripten, but can't test other platforms right now. |
some cleanup of the
CMakeLists.txtfile, still a work in progress so don't merge yet. opening this pr now so you can see my progressmore info of the changes can be found in the commit descriptions.
my goal with this is to keep it (nearly) functionally identical to the current cmake