Add a pkg-config file for header-only usage - #3634
Merged
Merged
Conversation
Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a dedicated pkg-config file for spdlog_header_only to avoid leaking compiled-library flags (-DSPDLOG_COMPILED_LIB) and link requirements (-lspdlog) into header-only consumers using pkg-config.
Changes:
- Generate and install a new
spdlog_header_only.pcalongside the existingspdlog.pc. - Derive header-only
CFlagscompile definitions from thespdlog_header_onlyINTERFACE target when generating the new.pc.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| CMakeLists.txt | Generates and installs a new header-only pkg-config file during SPDLOG_INSTALL. |
| cmake/spdlog_header_only.pc.in | New pkg-config template for header-only consumption (include dir + flags, no -lspdlog). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| URL: https://github.com/gabime/@PROJECT_NAME@ | ||
| Version: @SPDLOG_VERSION@ | ||
| CFlags: -I${includedir} @PKG_CONFIG_HO_DEFINES@ | ||
| Libs: -L${libdir} -pthread |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Owner
|
Thanks @c-tonneslan |
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.
Closes #3106.
spdlog.pcdescribes the compiled library: itsCFlagsinclude-DSPDLOG_COMPILED_LIBand itsLibslink-lspdlog. A header-only consumer that pulls flags frompkg-config --cflags --libs spdlogtherefore gets-DSPDLOG_COMPILED_LIB(which makes the headers expect a library to link) and-lspdlog(which may not be built), breaking the build.This installs a companion
spdlog_header_only.pc, generated from thespdlog_header_onlyINTERFACE target, so its defines and libs match header-only use: no-DSPDLOG_COMPILED_LIB, no-lspdlog(just the include dir and-pthread, plusSPDLOG_FMT_EXTERNAL/Requires: fmtwhen external fmt is selected, mirroring the existing.pc).Verified the generated files with
cmake -DSPDLOG_INSTALL=ON:spdlog.pc— unchanged.spdlog_header_only.pc—CFlags: -I${includedir},Libs: -L${libdir} -pthread.