We're writing an application for an embedded ARM/Linux device. Development is performed on a Windows PC, using a crosscompiler, Eclipse and Ninja. CMake currently can create the build scripts that work well for the intended purpose.
We have unit tests that run on the embedded device attached to the net, once the project is pushed (over Git) to the server.
We're trying to implement unit tests, that would run on the PC, before we try them on the device. That means building natively, using MinGW GCC - of course we can't launch the ARM Linux executables on the PC.
Even if we switch the toolchain, launching CMake to rebuild the ruleset for Ninja, or create two build directories, one for PC, one for ARM, the problem remains that CMake will try to run a test executable, and later during build, unit tests will be attempted on the ARM build.
How can we configure the builds (through CMake) to create both - and not attempt to run the crosscompiled ones on the PC?
I have a similar setup in my projects (building from the same sources a simulator, unit tests, and the target binary), and you can check for
CMAKE_CROSSCOMPILING
to differentiate your two use cases. Just puttingaround the particular commands should do the trick.
And you need to have two binary output directories. CMake does not allow to mix toolchains in one directory.
But you don't need to have two IDE projects. In my projects:
COMMAND
parametersExternalProject_Add()
to include your own project for cross-compilingHere are some code snippets for this kind of approach:
References