[CMake] Building in stages.

Magnus Therning magnus at therning.org
Tue Jun 22 01:27:22 EDT 2010


On Mon, Jun 21, 2010 at 17:46, Aeschbacher, Fabrice
<Fabrice.Aeschbacher at siemens.com> wrote:
> I would try following in foo/CmakeLists.txt:
>
>   add_custom_command(TARGET foo
>      POST_BUILD
>      COMMAND touch bar/CMakeLists.txt
>   )
>
> This will force CMake to re-build the makefiles for 'bar' (because its
> CMakeLists.txt has been modified)
>
> And of course, add_dependencies(bar foo)

It might, but it still feels like a rather strange way to go about it.

I'll make yet another attempt to explain the situation, hopefully better so
that it becomes more clear what the problem is.

There are three tools involved:

  camlp4 - an extensible pre-processor, it makes it possible to modify OCaml
           and even add syntax
  ocamldep - a tool that inspects a source file and tells you what it depends
             on, it can be told to use a preprocessor through its -pp argument
  ocamlc - the OCaml compiler, it can be told to use a preprocessor through
           its -pp argument

Somewhat simplified the project I'm converting to use CMake has two parts:

  foo - an extension to camlp4
  bar - an OCaml module, wich uses the syntax extensions implemented in foo

So if I understand you, these would roughly be the steps I need to take:

1. Call 'cmake' (manual)
    This must skip dependency generation for bar; foo isn't built yet and
    hence ocamldep will not be able to parse the source for bar.
2. Call 'make' (manual)
    Builds foo, and as a last thing touch the CMakeLists.txt for bar.

Now you're saying that because of the post-build step in 2 the following will
happen automatically, right?

3. Call to 'cmake' (automatic)
    Now foo has been built so the correct dependencies for bar can be
    determined.  (I have yet to find out exactly *how* I can determine that
    foo already is built, but that sounds like it shouldn't be too difficult.)

4. Call to 'make' (automatic)
    Now the Makefile for bar contains the correct dependency information and
    the build can continue.

Have I understood you correctly?

/M

-- 
Magnus Therning                        (OpenPGP: 0xAB4DFBA4)
magnus@therning.org          Jabber: magnus@therning.org
http://therning.org/magnus         identi.ca|twitter: magthe


More information about the CMake mailing list