# Project with Native & Cross-compile Targets

**URL:** <https://discourse.cmake.org/t/project-with-native-cross-compile-targets/6343>\
**Category:** Code\
**Created:** [August 25, 2022, 4:39pm UTC](https://discourse.cmake.org/t/project-with-native-cross-compile-targets/6343 "2022-08-25T16:39:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sampsont](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/fbc32d/32.png) [@sampsont](https://discourse.cmake.org/u/sampsont)\
**Post date:** [August 25, 2022, 4:39pm UTC](https://discourse.cmake.org/t/project-with-native-cross-compile-targets/6343/1 "2022-08-25T16:39:52Z")

</div>

My C++ VS Code project has multiple native executables & multiple cross-compiled executables. Some of the executables are compiled native and cross-compiled. All executables use the same library.

Is it possible to do this with one project? I would like to do it in one project because I don’t want the same source code in two places. Also, all of the executables are part of the same physical product.

**I’d like to end up with something like:**

- foo - compiled with native compiler
- foo - compiled with PowerPC compiler
- bar - native
- baz - PowerPC

I’d like to be able to edit a cpp file and just compile the specified target and then run it, for a quick debug cycle.

I’m using Ubuntu 20.04, Visual Studio Code, make. I would consider using Ninja if that would help.

Is this possible??? Can you give me any pointers?

Thanks!

---

<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:** [August 25, 2022, 11:00pm UTC](https://discourse.cmake.org/t/project-with-native-cross-compile-targets/6343/2 "2022-08-25T23:00:32Z")

</div>

CMake doesn’t support targeting multiple platforms in the same build (with the exception of the Xcode generator for Apple platforms). You can however use [ExternalProject](https://cmake.org/cmake/help/latest/module/ExternalProject.html) to coordinate sub-builds where you compile for the native platform in one sub-build and the PowerPC platform in another. Each sub-build will effectively act like its own isolated sub-build, unaware of the other. The top level project would just be a relatively lean co-ordination layer. This is typically referred to as a superbuild and is generally the recommended approach for your scenario.
