[CMake] Multiple toolchains in one CMakeList?

Brandon Van Every bvanevery at gmail.com
Tue Feb 5 09:23:50 EST 2008


On Feb 5, 2008 6:50 AM, John Spray <john.c.spray at googlemail.com> wrote:
> Hi,
>
> I'm attempting to use cmake to compile a project which requires code
> for a foreign architecture to be embedded in a library compiled for
> the host architecture.  I can compile for the foreign archtecture by
> setting CMAKE_FIND_ROOT_PATH to the directory containing the
> toolchain, but in this case that toolchain is used for everything in
> the CMakeList file, including things that I want compiled for the host
> arch.
>
> Is it possible to build certain objects for one architecture and
> certain objects for another?

Not in the same build.  You'd need 2 different invocations of CMake.
You could have 1 CMake use an execute_process to call the other CMake.
 The foreign build would need to output a library that the host build
recognizes as usable.  Otherwise you'd have to take over linking
manually with some kind of add_custom_command, however you usually get
it to work.  Why do you need the foreign code embedded in the host
library?  Wouldn't shipping libraries for multiple platforms be
enough?


Cheers,
Brandon Van Every


More information about the CMake mailing list