I have read the answers in the questions:
- Using CMake with multiple compilers for the same language
- CMake: how to change compiler for individual target
But I still don't understand the proper solution for cmake. The answer in (2) works only with Ninja, not cmake. The answer in (1) concerns the basic concept without example. So for me, as a beginner in cmake, the solution using process_execute() is unclear in the terms of implementation.
Is it possible to create a top-level CMakeLists.txt with process_execute(), which can be used in the follow way:
- Single
cmake
command in shell. - Single
make
command aftercmake
command for the project build. - Multiple targets with different compilers in one build.
What is the simple scheme of a such solution in this case?
ADDITION
My project consists from libA and libB. The libA is а backend, which emits code. The libB is a runtime support library for emitted code. I want to build the whole project by a standard "single" build command (cmake && make && make install). Of course the cmake command inlcudes parameters.
The libA may emits code for some processors. The libA may works in a cross mode. The libB is used for linking with emitted code. That is why the libB as a runtime library must be compiled in native mode.
When the libA is building in cross mode the build process must uses a one compiler for the libA, and a second compiler for the libB. In my opinion the splitting of the build process into two separated commands ("cmake1 && make1" for libA and "cmake2 && make2" for libB) is a "logical" error.
Also it is useful if the single build command may builds a multiple number of version libB for different processors.
ADDITION2
possible solution: using add_subdirectory()