Is it possible to have in CMakeLists.txt
add_subdirectory(foo)
combined with custom CMAKE_TOOLCHAIN_FILE
which is to be used only for this foo
subdirectory?
The idea is to use a different compiler / toolchain for the sources under foo
directory regardless of which compiler is used for the rest of the project.
The point is to have some sort of solid solution which avoids wrapping cmake
/ make
/ etc invocation by a custom command (e.g. in order to avoid breaking IDE support, incremental builds, etc).
Possible use cases could be:
- Cross-compiling modules for different target platforms as part of a single build system.
- Cross-compilation of test binaries.
- Testing this custom toolchain as a part of build process.