Am 18.01.2011 19:24, schrieb T. Modes:
>
> But I found an issue: I can not access the image variables of
> SrcPanoImage like getImage(0).getYaw() and so on
Thats probably because these functions are defined using some macros
inside Panorama.h. Maybe swig needs to call the C preprocessor or we
need to call swig on an already preprocessed Panorama.h.
ciao
Pablo
Sorry, there is no such rule as in makefile. You have to add_custom_commad() for each .h file.
If you have a list of files, then you could achieve the effect of ".h.i" rule like this:
file(GLOB hlist ${CMAKE_CURRENT_SOURCE_DIR}*.h)
foreach(hfile ${hlist})
get_filename_component(hbase ${hfile} NAME_WE)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${hbase}.i"
COMMAND ${CMAKE_CXX_COMPILER}
ARGS -E ${hfile} > "${CMAKE_CURRENT_BINARY_DIR}/${hbase}.i"
DEPENDS ${hfile}
)
SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_BINARY_DIR}/${hbase}.i" GENERATED)
endforeach()
But, why not rename xx.h into xx.cpp?
> I'd also appreciate a link to documentation that explains the concepts
> behind cmake. I get the feeling that the online documentation for
> cmake is deliberately sketchy to promote the sales of the book which
> is featured on the main page. It's either making hello-world-type
> projects with three source files and a bit of configuration or
> extremely terse 'Documentation' which has no conceptual explanations
> or examples. You know what cmake syntax reminds me of? Lisp. and that
> has always been good for giving me a headache. There's a down side to
> a simple syntax: it's all in semantics.
I don't have that either.
> Kay
>
Kornel
Am Mittwoch, 26. Januar 2011 schrieb kfj:
> On 26 Jan., 12:37, Kornel Benko <Kornel.Be...@berlin.de> wrote:
> > But, why not rename xx.h into xx.cpp?
>
> Hey, no problem, I can rename it into anything. So let's assume I have
> zz.cpp in my source directory and I want it to be C-preprocessed into
> a file z.i in my binary directory, from where it's included into
to "zz.i"
> another file. What do I have to tell cmake to do this?
You have to define a dependency
e.g.
add_custom_command(
...
DEPENDS zz.i ....
)
> My problem is
> really very basic, it should be a one-liner. Please excuse my
> ignorance. It would then be equivalent to the make rule of
>
> .i .c
You mean ".c.i" here, don't you?
> which I know cmake can do.
>
> Kay
Kornel
Am Donnerstag, 27. Januar 2011 schrieb kfj:
> On 26 Jan., 21:34, Kornel Benko <Kornel.Be...@berlin.de> 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
Am Donnerstag, 27. Januar 2011 schrieb kfj:
> On 27 Jan., 11:04, Kornel Benko <Kornel.Be...@berlin.de> wrote:
> > You have always to learn. 'lazy' is valid for simple tasks only.
>
> Kornel, thank you for your help. Now I think I can set it up to my
> satisfaction.
Nice to hear ...
> I hope you don't mind me moaning about cmake, in the end
> it can be persuaded to do the right thing and once it's set up
> properly, it does it's job really nicely. Once I'm through with
> setting up cmake, I think it'll soon be time to upload a new revision
> of hsi/hpi with even more functionality. I really want to USE the
> thing, but first things first...
Yes it's nice once mastered :)
> Kay
Kornel