I am trying to convert a project to use CMake.
In the project, the main part need to be cross compiled, while the unittests need to be compiled with the C compiler for the host.
The Toolchain file sets the CMAKE_C_COMPILER
globally for all the targets. But in this case I need to use a different compiler for the unittests. I am not sure how to use one compiler for one part and another for another.
The solution I have found is to have a separate CMakeLists.txt
file for unittests. It overrides the CMAKE_C_COMPILER
is to the host C compiler. In all other places the C Compiler provided by the Toolchain file is used.
The problem is that when I check the CMAKE_CROSSCOMPILING
it always TRUE. While building unittest this must be FALSE. This hints that may be my technique is not correct.
Looking for suggestions.