vcpkg should provide an official strategy for library config headers #49652
JonTheBurger
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
|
Why is your "Config Header" not simply a port? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Use Case
I am currently working on rolling out vcpkg for an embedded project and have been busy packaging repositories like
FreeRTOS-Kernelandlvglfor consumption. While my current workarounds are okay, I think this is the main thing preventing vcpkg from being the choice for serious C/C++ package management for microcontrollers.Current State of Affairs
At time of writing, the most proper way I have found to handle this is for the
tripletfile to specify aVCPKG_CMAKE_CONFIGURE_OPTIONSthat contains-D<project-specific-var>=<path-to>/somelib_config.h, and then add that same path toVCPKG_HASH_ADDITIONAL_FILES. This often requires also patching projects to use$<BUILD_INTERFACE:...>for thesomelib_config.h, as well as add the file to itsPUBLIC_HEADERtarget property (assuming the correspondinginstallcommand correctly specifiesPUBLIC_HEADER, which I have a separate helper for. The config header must of course be installed so that consumers can find it.)Where Can We Go
For my purposes, I wrote a helper function to use in
portfile.cmakethat:VCPKG_HASH_ADDITIONAL_FILES-D${VAR}=<path-to-header-dir>toVCPKG_CMAKE_CONFIGURE_OPTIONS(eventually, I decided that if a port didn't officially support a header variable I'd just useCOM_VCPKG_CONFIG_HEADER_DIRby default and patch itsCMakeLists.txt)This is of course tailored to my use case, and requires more workarounds if the project specifically expects a
CONFIG_FILE(not directory) variable, but it at least provides an opinionated strategy for handling config files that my group can follow.I think it would be great for vcpkg to at the very least take a stance on how to handle config headers, specifically a stance other than "we don't support them" (which would be a shame, since all of the great machinery to do so is already present).
I've included the docs for my helper function below - I can add more details if need be, but it's just a wrapper over the above concerns for convenience:
com_install_config_header
Some libraries, especially for embedded systems, require users to provide a configuration header. This function ensures the user has supplied the header, and installs it alongside the project's bundled headers. Lastly, the config header
VARis added toVCPKG_CMAKE_CONFIGURE_OPTIONSfor use in the port'sCMakeLists.txt$<BUILD_INTERFACE:...>include directories.Signatures:
com_install_config_header( HEADER <header> [DEST <install-destination>] [VAR <containing-directory-variable>] [OPTIONAL] )The options are:
Example usage:
com_install_config_header( DEST coreMQTT HEADER core_mqtt_config.h OPTIONAL )Beta Was this translation helpful? Give feedback.
All reactions