[CMake] Multiple toolchains in one CMakeList?

Brandon Van Every bvanevery at gmail.com
Tue Feb 5 14:36:06 EST 2008


On Feb 5, 2008 2:15 PM, Hendrik Sattler <post at hendrik-sattler.de> wrote:
> Am Dienstag 05 Februar 2008 schrieb Brandon Van Every:
>
> > On Feb 5, 2008 11:08 AM, Hendrik Sattler <post at hendrik-sattler.de> wrote:
> > > Quoting Brandon Van Every <bvanevery at gmail.com>:
> > > > On Feb 5, 2008 10:05 AM, John Spray <john.c.spray at googlemail.com> wrote:
> > > >> If I were invoking a second CMake, would I be able to make the host
> > > >> CMake aware of the second as a dependency?
> > > >
> > > > Sure.  add_custom_command, add_custom_target.  The subsidiary CMake
> > > > would have to actually output something.  You'd have to know what that
> > > > output is going to be, and how to invoke the build.
> > >
> > > Or a new command
> > >    add_indep_subdirectory()
> > > which does automate that by forgetting about most cmake settings but
> > > targets. Example: compiling a firmware code with a cross-compiler, then
> > > converting that binary into a .c file and including that into a
> > > binary: two compiler chains and one add_custom_command.
> > > It would restrict to using a separate subdirectory for the different
> > > toolchain (else it is probably not complex enough).
> >
> > What's wrong with doing things the usual way?  I'm not seeing a reason
> > to hide the standard mechanisms for calling external tools.  CMake can
> > be an external tool, there's nothing wrong with that.
>
> You don't get the target in the calling cmake environment. You actually loose
> every feature of cmake regarding the connection between the two instances :-(
> Or at least it gets freaky complicated to achieve the same features.

Aren't you over-dramatizing?  You aren't going to get that many CMake
features anyways because you're doing non-standard linking.  You'll be
creating your own configure.h anyways.  "make mytarget" is a trivial
custom command.  The real source of complication is how to call Visual
Studio on the command line.  For build tools other than make and VS,
who cares?  Those 2 tools cover 90% of what people will want to use in
the real world.  If you want to add Watcom or Borland support or
whatever, fine, add if(WATCOM) or whatever when you need to.  This is
a small amount of work compared to implementing a luxurious fully
integrated version in CMake itself.


Cheers,
Brandon Van Every


More information about the CMake mailing list