[CMake] pkg-config and Cross_compiling

Alexander Neundorf a.neundorf-work at gmx.net
Mon Jul 7 15:11:41 EDT 2008


On Monday 07 July 2008, Hendrik Sattler wrote:
> Zitat von Alexander Neundorf <a.neundorf-work at gmx.net>:
> > On Wednesday 02 July 2008, Hendrik Sattler wrote:
> >> Am Mittwoch, 2. Juli 2008 18:59:37 schrieb Wookey:
> >
> > ...
> >
> >> Additionally, I found that the include paths are another source of
> >> problems, not fully covered by the cmake cross compiling, yet. You
> >> really have to -I any path that is not known and specific to the cross
> >> compiler, using INCLUDE_DIRECTORIES(). This is not done automatically
> >> for the changed ROOT_PATH, yet.
> >
> > Can you please explain more detailled ? I don't understand what you mean.
> > If you find such problems, please report them in the cmake bugtracker.
>
> If you include a non-standard header file in your program:
> #include <foo/bar.h>
>
> and foo sits /path/to/non-native (e.g. /opt/cross-root/usr/include
> with /opt/cross-root being CMAKE_FIND_ROOT_PATH), then it will not be
> found. How could it, the compiler doesn't know about /opt/cross-root
> as it is installed somewhere else. So you must tell the compiler with
> -I/opt/cross-root/usr/include that it should look there. Currently, I
> do something like:
> foreach ( dir ${CMAKE_FIND_ROOT_PATH} )
>    foreach ( inc usr/local/include usr/include include )

I think /usr/local/include isn't always part of the built-in search path, but 
usr/include and include look good.

>      if ( EXISTS "${dir}/${inc}" )
>        include_directories( SYSTEM "${dir}/${inc}" )
>      endif ( EXISTS "${dir}/${inc}" )
>    endforeach ( inc )
> endforeach ( dir )
>
> That make it "just work". Same goes for pkg-config.
>
> If I do a find_* in cmake first to find that include, that will solve
> that, sure. 

Yes, that would be the general advice for that kind of problems.
What do the other cmake devs think ?
Is it the authors fault if he didn't search for the correct header using 
FIND_PATH() or should we add these include dirs automatically ?

Beside that, what would you think about using -nostdinc ?

Alex


More information about the CMake mailing list