I’m working on a project with Visual Studio Code and CMake where I’m compiling / cross-compiling different targets for different platforms. Currently the project has three platforms, each of which uses a different toolchain. I’m going to simplify the names of the platforms and toolchains for the purposes of explaining:
- Platform1 uses a toolchain defined in
platform1.cmake
and builds fromplatform1/CMakeLists.txt
- Platform2_native uses a toolchain defined in
platform2.cmake
and builds fromplatform2/CMakeLists.txt
- Platform2_emulated uses the system’s native toolchain, and also builds from
platform2/CMakeLists.txt
If I individually configure and build each of these using the command line and manually specify the correct toolchain, then they all build correctly. But what I really want to do is be able to do the building in Visual Studio Code, and specify which target I’m building.
However, I’m still new to CMake and I’m hitting a brick wall as I try to figure out how to set this up. From what I’m reading, CMake assumes that all targets will use the same toolchain, and it looks like Visual Studio Code only works with one CMake project at a time.
Is there a way to do this in a single Visual Studio Code workspace?
1