How to target CMake to multiple platforms in a single build
I would like to configure my CMake project so that one build execution targets multiple platforms (in my case, I would like to build for Linux and Windows, x86_32 and x86_64 targets). I am installing and working with cross compiler tools, and for every single target, creation works.
So the challenge is to tune CMake so that the toolchain variables CMAKE_SYSTEM_β¦
are set appropriately for each substring. How can i do this?
source to share
It's impossible at all.
CMake allows you to configure only one target framework at a time. If you want to target a different platform, you need to re-launch CMake from scratch. This is even true for switching only architectures when the rest of the dashboard remains the same (for example, you cannot create x86 and x64 binaries at the same time).
The correct way to automate this would be to have a built in script construct that runs CMake once for each target platform and does multiple builds outside of source for different binaries. This application script can also be written in CMake itself (the module ExternalProject
works well enough for this), although a general-purpose scripting language like Python or Bash may be better suited.
source to share