[Refactor]: Cleanup CMake & separate libconky for all builds #2138
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 does a lot and is a pain to review, I'm making it to "save progress". I'll highlight important changes once I'm done and it's no longer a draft.
Summary
Rationale
Targets instead of variables
Mutating global state with
include_directories
is irreversible and makes it hard to debug/maintain the build files. It also leaks into subprojects and then all projects end up having access to everything which allows including headers (like "logging.h") which shouldn't be accessible from wrong places.Having these stored in targets allows prepending include/library paths to patch things - like
X11/X.h
definingAlways
andNone
, which breaks tests if catch2 is included after some conky headers.Removing config.h
Storing all these variables in
-DFLAG=VALUE
is convenient when targets are used, maintaining two separate lists of options (CMake and config.h.in) doesn't really provide any added benefit and is just annoying. There were already 2/3 options that were left behind and unused. Having theConkyBuildOptions.cmake
populate these automatically is super nice.Also, as all options now use basically the same command:
it's possible to create a
build_options.yaml
that can be used for both docs and actual compile-time configuration.Always using libconky
This comes up in #1899. Basically,
cairo_imlib2_helper
wants to access logging, but it can't because that would require bundling entire conky with it as #1899 adds .cc files (for global static LOGGER).To deal with this, I think it's simplest to always separate libconky with PIC from main executable - this allows lua modules to access conky internals (like color parsing) without having to statically link to and include all conky sources. Alternatively, we could be binding a lot of the functions to Lua in order to make them accessible to modules, but that's a lot of work.
Work left to do
DEPENDENT_OPTION
function doesn't seem to set correct fallback value whenDEPENDS
isn't met.