# Is it possible to create several targets with different toolchains in CmakeList.txt?

**URL:** <https://discourse.cmake.org/t/is-it-possible-to-create-several-targets-with-different-toolchains-in-cmakelist-txt/9522>\
**Category:** Code\
**Created:** [November 28, 2023, 3:38pm UTC](https://discourse.cmake.org/t/is-it-possible-to-create-several-targets-with-different-toolchains-in-cmakelist-txt/9522 "2023-11-28T15:38:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![KSergeyP](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/8baadc/32.png) [@KSergeyP](https://discourse.cmake.org/u/KSergeyP)\
**Post date:** [November 28, 2023, 3:38pm UTC](https://discourse.cmake.org/t/is-it-possible-to-create-several-targets-with-different-toolchains-in-cmakelist-txt/9522/1 "2023-11-28T15:38:07Z")

</div>

I know that you can set compiler settings separately for each target. Is it possible to define a different compiler for each target? For example, to build an application for different platforms (Windows Linux, etc.) in one launch

---

<div class="post-metadata">

**Author:** ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)\
**Post date:** [November 28, 2023, 8:42pm UTC](https://discourse.cmake.org/t/is-it-possible-to-create-several-targets-with-different-toolchains-in-cmakelist-txt/9522/2 "2023-11-28T20:42:17Z")

</div>

CMake only supports using a single toolchain throughout the build. You can’t mix different toolchains for different targets. That said, you can use the [ExternalProject](https://cmake.org/cmake/help/latest/module/ExternalProject.html) module to set up sub-builds which can each use a different toolchain.
