cmake: optionally generate tweakme header - #3647
Open
fyrsta7 wants to merge 1 commit into
Open
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.
Fixes #3077.
Motivation
Several spdlog build options are represented both as CMake target definitions
and as settings in
tweakme.h. Consumers that do not use the exported CMake orpkg-config metadata cannot recover the configuration used to build an
installed spdlog library and currently need downstream patches to the header.
Solution
Add an opt-in
SPDLOG_GENERATE_TWEAKME_HCMake option, disabled by default.When enabled, CMake generates
include/spdlog/tweakme.hfrom the existingspdlog configuration options. Source-tree compiled and header-only targets use
the generated header, and installation selects it in place of the editable
source header.
When generation is disabled, the existing source header and installation
behavior are unchanged. The option does not change the existing exported
target definitions, C++11 support, or pkg-config metadata.
Validation
The CMake integration test covers source-tree and installed consumers for both
compiled and header-only targets, static and shared builds, and a raw installed
header-only consumer that does not use a spdlog CMake target or pkg-config
metadata. It also checks that generated-header include precedence is effective.
The default and generated configurations both pass the official compiled and
header-only test suites. Static and shared C++11 source-tree consumers,
installed package consumers, and the raw installed-header consumer pass
locally. I also verified separately that a default installation produces a
tweakme.hbyte-for-byte identical to the source header. The nested host-runintegration test is omitted while cross-compiling.