Replies: 2 comments
-
I actually pack the toolchain in a zip file and download it with cpm. the CMakeLists.txt has this structure:
and get_toolchain.cmake uses cpm to download the zip file (basically the package from arm) get_toolchain.cmake:
this configuration is static, in the sense that I force the tools to cmake, and it would crash if I tried to use -DCMAKE_TOOLCHAIN_FILE, but it's ok for my use case. the alternative is to bundle the toolchain file with the download, and set CMAKE_TOOLCHAIN_FILE int the if(gcc_arm_ADDED) branch to point to that file and it should work. The usual caveat that cmake does not update on toolchain updates applies also here, the toolchain will be downloaded only at configure time. But one can always keep multiple build directories, one for each toolchain |
Beta Was this translation helpful? Give feedback.
-
About a year later, but I finally had some time to try out some things and came up with the following solution that so far seems to work for us. We have a repository that contains all our different toolchains. This repository has a In the project where we want to use the toolchain:
Just wanted to share this approach here as it might be useful for others as well. |
Beta Was this translation helpful? Give feedback.
-
We are currently looking at our options when it comes to managing packages/dependencies for our projects.
The projects we do are mostly bare-metal/RTOS-based embedded C applications, running on a microcontroller.
A while back we looked at Conan and were really impressed by the possibilities (also a bit overwhelmed perhaps).
Recently we stumbled upon CPM.cmake, which seems to fit most of our use cases as well with a less steep learning curve.
One thing I liked about Conan, was that it allowed you to "package everything", so we could also create reusable packages out of our CMake toolchain file (depending on the microcontroller used, we need a different compiler or compiler configuration, for which we use CMAKE_TOOLCHAIN_FILE).
Although you could package pretty much anything with CPM.cmake as well, so it seems, there is a fundamental problem that prevents the toolchain file from being retrieved by CPM: we need to pass the file to CMake at the configuration phase (which I think is just before CPM.cmake does its magic).
So, I wondered, what are some practices people have in place for sharing toolchain files?
What are our possibilities (with CPM.cmake or standalone)?
What would you recommend?
Beta Was this translation helpful? Give feedback.
All reactions