[CMake] Problem of dependencies

Guillaume Damiand damiand at sic.univ-poitiers.fr
Wed Feb 27 04:59:16 EST 2008


Hello,

I have discovered cmake one week ago and I am very impressed by its
powerful and facility of using.

However, I have a problem concerning dependencies and I have not found
any solutions in forums or documentations.


I use 3 types of files .hh et .cc (as usual) and .icc for inline
fonctions. I have two macros INCLUDE_INLINE and INCLUDE_NON_INLINE which
allow, given a compilation option, to include an .icc file into a .hh or
a .cc depending if we want to inline fonctions or not.

This allows to speed up the compiling time for debug project, and speed
up the execution for release projects.

=========================================================================
These fonctions can be used for example like that :

in foo.hh : #include INCLUDE_INLINE("bar.icc")
and in foo.cc : #include INCLUDE_NON_INLINE("bar.icc")

Only one of both macro will include the file bar.icc, the other
one do nothing.
=========================================================================

I have used several distributions into cmake to allow users to chose
inlining or not, and my project compile and everything is fine... except
the dependencies.

Indeed, .icc files need to be included into dependencies differently
depending if we are in inline mode or not.

1) If we are in non-inline mode, .cc files need to depend on included .icc. I
think this can be achieved by scanning all .cc files, searching the
regexp #include INCLUDE_NON_INLINE( and add a dependency by using
SET_SOURCE_FILES_PROPERTIES with OBJECT_DEPENDS.

My first question is about the validity of this solution ? When I try
this, I have an error about the fact that there is no rule to
manage coordinate.icc.


2) However, I think the problem is more complex for inline mode, since
in this case, all files that include foo.hh need to depend on all
included icc info foo.hh. 

I have no idea if such thing can be achieved with cmake. In my opinion,
to solve this problem, we need to build a cache which associates to
each .hh file the list of included .icc, and use this list to add
dependencies. But this seems complicated...

I hope there is a solution to this problem, otherwise i think I will go
back, with regrets, to classical makefile (where dependencies work
perfectly by using option -MM of compiler. Why do not uses this system
with cmake ?)

Thank you for your help.

Best regards

--
Guillaume Damiand




More information about the CMake mailing list