Am Donnerstag, 27. Januar 2011 schrieb kfj:
> On 26 Jan., 21:34, Kornel Benko <[email protected]> wrote:
> > You have to define a dependency
> > 
> > e.g.
> >         add_custom_command(
> >                 ...
> >                 DEPENDS zz.i ....
> >         )
> 
> So I tried this:
> 
> IF(MSVC)
>   SET(PREPROCESSOR_FLAGS "/EP")
> ELSE()
>   SET(PREPROCESSOR_FLAGS "-E")
> ENDIF()

This is btw not needed, even MSVC understands "-".

> SET(C_PREPROCESS ${CMAKE_CXX_COMPILER} ${PREPROCESSOR_FLAGS})
> 
> macro(preprocess in out)
> add_custom_command(OUTPUT ${out}
>     COMMAND ${C_PREPROCESS} ${in} -o ${out}
>     DEPENDS ${in}
> )
> endmacro(preprocess)
> 
> preprocess(${CMAKE_CURRENT_SOURCE_DIR}/Panorama_accessors.h
> Panorama_accessors.i)
> preprocess(${CMAKE_CURRENT_SOURCE_DIR}/SrcPanoImage_accessors.h
> SrcPanoImage_accessors.i)
> 
> ADD_CUSTOM_TARGET(hsi_accessors
>   DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/Panorama_accessors.i"
>           "${CMAKE_CURRENT_BINARY_DIR}/SrcPanoImage_accessors.i"
> )
> 
> now I can make hsi_accessors. It works, but it seems like a rather
> circuitious route to do something very basic.

Yes, I am also not happy with this.

> Now the next step I have
> to do is get the dependency chain to work. I have the following
> dependencies:
> 
> XXX_accessors.h depends on <panodata/image_variables.h>
> XXX_accessors.i  depends on XXX_accessors.h
> hsi.i depends on XXX_accessors.i
> 
> additionally, hsi.i also depends on all the header files it %includes
> to generat the wrapper code from. So I'd like to express that hsi.i
> needs to be processed by SWIG whenever any of the files it depends on
> changes. But hsi.i isn't made from the files it includes, it only has
> to be considered out of date when it's older than any of the files it
> includes. I don't know how to express that in cmake.

There is a construct in cmake for this.
First define a project before creating hsi.i

        project(hsi)
        ...
        add_custom_command()    # to create hsi.i
        ...
        add_custom_target(hsi ALL DEPENDS ${from_whatever})

Then define a project for SWIG

        project(swig)
        ...
        add_custom_commad()     # whatever
        ...
        add_custom_target(swig ALL DEPENDS ${from_whatever})

You may also consider dependencies between targets

        add_dependencies(swig hsi)
        ...

> The 'lazy metaprogramming' is sure turning out expensive when my time
> is concerned... :(

You have always to learn. 'lazy' is valid for simple tasks only.

> Kay

        Kornel

Attachment: signature.asc
Description: This is a digitally signed message part.

Reply via email to