On 06/27/2011 12:00 PM, Maxime Lecourt wrote:
> 
> 
> 2011/6/27 Michael Wild <them...@gmail.com <mailto:them...@gmail.com>>
> 
>     On 06/27/2011 11:31 AM, Maxime Lecourt wrote:
>     > Hello,
>     >
>     > I'm using CMake to build OCaml libraries.
>     > For that, I use a macro that I call in my CMakeLists.txt
>     >
>     > As I have dependencies between my different libraries, I wrote my
>     > CMakeLists.txt so the build happens in the right order, but when
>     > building, libraries are built depending on alphabetical order.
>     >
>     > add_ocaml_library(cabs SOURCES cabs.ml <http://cabs.ml>
>     <http://cabs.ml>)
>     > add_ocaml_library(algo SOURCES algo.ml <http://algo.ml>
>     <http://algo.ml>)
>     >
>     > (algo depends on cabs being already built)
>     >
>     > How can I create a "add_ocaml_dependencies" macro ?
>     > Or is there a way to force CMake to follow the build order in the
>     > CMakeLists.txt ?
>     >
>     > Regards
>     >
>     > Maxime Lecourt
>     >
> 
>     Well, if cabs and algo are top-level targets (i.e. created via
>     add_library(), add_executable() or add_custom_target()), you can simply
>     call add_dependencies(algo cabs).
> 
>     Michael
> 
> 
> algo and cabs are created using add_custom_command()
> 
> I tried add_dependencies(algo cabs), but it did not work.
> Would it work if i create a fake target (can I force cabs and algo as
> top-level targets, or as valid parameters for add_custom_target ?) ?
> 
> add_custom_target(target1 depends cabs)
> add_custom_target(algo depends target1)
> 
> 
> Or something like that.
> 
> Maxime Lecourt

Yes, you should create a custom target with add_custom_target(). In
CMake you have to distinguish between top-level and file-level targets.
add_custom_command() only creates a file-level target, so you need the
add_custom_target() call. Also, this will make it possible to build the
targets selectively from the command line or the IDE.

However, your above shown code is semantically wrong. Your
add_ocaml_library() macro (you probably should make it a function
instead) should contain the add_custom_target() call and give it the
name passed to the add_ocaml_library function.

Michael
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to