[CMake] Include-Dir order problem

Andreas Pakulat apaku at gmx.de
Tue Feb 15 13:36:45 EST 2011


On 15.02.11 17:54:29, Michael Hertling wrote:
> On 02/13/2011 01:27 AM, Andreas Pakulat wrote:
> > Hi,
> > 
> > I've got a somewhat tricky problem here with include directories. I'm
> > building a couple of source files and for some of them I need to add an
> > include-directory to the front of the list that cmake passes to the
> > compiler. At the same time other source files in that directory need to
> > not have that include-dir in front of the list.
> > 
> > I can't see a way to do this, except by using COMPILE_FLAGS source file
> > properties for each and every file to specify include-dirs and not use
> > include_directories at all, as COMPILE_FLAGS always end up behind the
> > includes.
> > 
> > So, am I missing something here? If not I guess I'll have to find that
> > bugreport about making include-dirs a source-file property and vote for
> > it so it gets included into 2.8.5...
> 
> Currently, AFAIK, it's not possible to set source-file-specific include
> directories unless one (mis)uses COMPILE_FLAGS which is accompanied by
> the shortcoming you've mentioned. Probably, the really clean solution
> ATM would be a reorganisation of the sources, but I doubt if the need
> for different include directories is an appropriate criterion for a
> project's directory layout.

Well, all those sources need to be in the same target, so I can't quite
see how moving some of the sources into subdirs wuld help with that.

> If there're only a few affected files, another possible workaround
> consists of file-specific configured headers, i.e. find the special
> include directories and inject them into config'd headers that are
> included by the concerned source files, or even modify the latters
> themselves in this manner. Of course, the sources must be touched
> to do that.

Thats probably the route I'm going to take as indeed there are only few
files needing the extra include at the front and it'll also solve the
problem of new developers in the team not realizing that the header that
is included is not the one they think it is...

> IMO, from a conceptual point of view, INCLUDE_DIRECTORIES should be
> also available as target and source file property, so I would vote
> for 1968 and 8189 - seem to be relatives - and possibly 8874, too.
> However, if this undertaking is addressed, one should think about
> how the include directories are ordered on the compiler's command
> line. Perhaps, there might be a convention that they appear from
> most to least specific, i.e. in source-target-directory order.

Thanks for digging up the bugnumbers for me. I've added my use-case
there and will make sure to bring this up when the cmake devs gather
input again for the next release...

Andreas

-- 
You will soon meet a person who will play an important role in your life.


More information about the CMake mailing list