-
Notifications
You must be signed in to change notification settings - Fork 918
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for CMake find_package and imported targets #1476
Comments
We are certainly interested in being more standards compliant.... seems like it might be a bit of a backwards incompatibility so positing a 2.0 SDK release |
2.0 seems fine to me. What's the process to get this contributed? There'll need to be some decisions made on where/how installation is performed (e.g., src or binary distribution, installation path). |
A few random thoughts about how things could work better.
|
Compiler flags are typically set up on the exported library target that you set up in the the pico-sdk CMakeLists.txt. These flags will continue on with the target when the user imports the target via the Regarding a mechanism to perform initialization when the user |
Most (non-capatably?) we do select (default) the toolchain file based on the |
I think it's typical to specify toolchain files when invoking the cmake executable with |
Does that mean that everywhere in https://datasheets.raspberrypi.com/pico/getting-started-with-pico.pdf where we do |
Or setting the |
I've had a look into this, and I don't think we'd want to switch to this being the recommended way to do things due to needing to specify the toolchain file, but it should be possible to support doing it this way (with a toolchain file, and then a |
I'm curious and wondering if the maintainers are open to adopting a more standard approach to pico-sdk's CMake integration based on the CMake's guides for package maintainers, including Using Dependencies, Import and Exporting, and Finding Packages. Finding and linking to libraries in a modern CMake project typically utilizes
find_package(...)
calls, linking to namespaced imported targets, and doesn't require library-specific CMake macro/function calls to "fully initialize" the dependency likepico_sdk_init()
. A limited example would look like this:As I see it, only one change is required to get this to work with some lifting on the user's part. Removing the requirement to include
pico_sdk_init.cmake
before theproject(...)
call allows users to write their ownFindPicoSdk.cmake
, thus gaining a similar experience to pico-sdk shipping CMake configuration files. If anyone knows why, I'd love to know what in that CMake file makes this a requirement; nothing obvious stood out to me when I read through it.Optionally, pico-sdk can fully support CMake conventions with some additional changes:
install(...)
a CMake export set and a package configuration file (version files optional but good too)./usr/local/
) or elsewhere (e.g.,/opt
or~/.local/
); or ship a system packagepico-sdk-dev
that installs sources to system paths directly (/usr/
)Let me know what you think about this proposal. I have experience writing and maintaining CMake packages and would be happy to jump in to making improvements and fixes.
The text was updated successfully, but these errors were encountered: