Is it possible to build 32 bit and 64 bit projects in single root project

I have projectMain which is root cmake , which add project32bit and project64bit

Problem is i am unable to change target build architecture of project64bit to 64

If i use -T target option that chaging entire project not individual target or sub directories,

I also tried CMAKE_GENERATOR_PLATFORM In project64bit but that not helping

Note : we generate sln from projectMain use that for building

No, it’s not possible unless the compiler supports generating both with a single command (like clang with macOS universal binaries). CMake has deeply-rooted assumptions about how many targets for each language exist (that is, 1). For example, things like CMAKE_SYSTEM_PROCESSOR are single-valued and not actually all that useful in a build targeting said universal binaries.

Is there any alternative to handle above situation

ExternalProject should work. There have been similar questions asked here about it before, but I don’t have the time right now to find them. I’ll try and circle back later though if you don’t have any luck.

I use ExternalProject for an analog of this: building both Release and Debug binaries with a single command and no multi-config generator.

Targeting multiple architectures, or to paraphrase using multiple toolchains in a single project is a shortcoming of CMake. ExternalProject works because it externalizes the build to separate configurations, thus allowing to pick multiple toolchains. This solution works well enough for automation scenarios, but it does trip a lot of tooling, one will lose CTest integration in IDEs, display of target names and automatic discoverability for debugging…