Setup cmake-tools for cross-compile but native unit tests #3599
-
Hi all, I have a small embedded C++ project, for which I use VS Code and cmake-tools to develop. I want to add unit tests to the project, but I don't want to run the tests on the embedded device, it's enough to run it locally. Does anyone know how to setup the project for this? I know that CMake doesn't support multiple toolchains in one configuration, but there is a workaround with I tried CMakePresets which works really nicely, with the tests explorer view I can easily debug/test the unit tests, and for the embedded device I use the regaular launch/debug view. The only downside is, this is a pain to always switch back and forth between the two types of builds. My other idea was to set up multi-root workspaces with two separate CMakeLists.txt files, but in my current directory structure it's not easy to do. If this could work, I'll give it a try, but I'm not sure about this. What is the best approach here? I can create a minimal example for this if it's required. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I echoed this on another discussion post, but the most confident suggestion I can make is to use CMakePresets.json. While this does still require switching between configurations and preset options, it is the officially supported way to configure and control your configurations with CMake. |
Beta Was this translation helpful? Give feedback.
I echoed this on another discussion post, but the most confident suggestion I can make is to use CMakePresets.json. While this does still require switching between configurations and preset options, it is the officially supported way to configure and control your configurations with CMake.