[CMake] Proposed fix for the FindX11.cmake triplication annoyance

Alexander Neundorf a.neundorf-work at gmx.net
Fri Aug 3 13:37:34 EDT 2007


On Friday 03 August 2007 13:27, Alan W. Irwin wrote:
> On Linux (at least for both my Debian and Ubuntu platforms), FindX11.cmake
> sets X11_INCLUDE_DIR to /usr/include;/usr/include;/usr/include.
>
> This triplication is an annoyance at least in the case where you are using
> SET_SOURCE_FILES_PROPERTIES to set the -I compiler flags (as we do for the
> subset of the PLplot source files which depend on X) because you then
> end up with triplicate -I/usr/include options for the compiler which
> (unless the compiler itself ignores duplicate -I flags) causes compilation
> inefficiencies as the same /usr/include directory is searched three times
> for header files.
>
> N.B. I am well aware that you don't need the -I/usr/include flag at all on
> most/all Linux platforms.  I am also aware that FindX11.cmake violates the
> readme.txt standard for Find modules.  However, please ignore those issues
> for now and focus here on the triplication issue.
>
> The source of the triplication is the following code in FindX11.cmake.
>
>    FIND_PATH(X11_X11_INCLUDE_PATH X11/X.h ${X11_INC_SEARCH_PATH})
>    FIND_PATH(X11_Xlib_INCLUDE_PATH X11/Xlib.h ${X11_INC_SEARCH_PATH})
>    FIND_PATH(X11_Xutil_INCLUDE_PATH X11/Xutil.h ${X11_INC_SEARCH_PATH})
> [...]
>    IF(X11_X11_INCLUDE_PATH)
>      SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_X11_INCLUDE_PATH})
>    ENDIF(X11_X11_INCLUDE_PATH)
>
>    IF(X11_Xlib_INCLUDE_PATH)
>      SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xlib_INCLUDE_PATH})
>    ENDIF(X11_Xlib_INCLUDE_PATH)
>
>    IF(X11_Xutil_INCLUDE_PATH)
>      SET(X11_INCLUDE_DIR ${X11_INCLUDE_DIR} ${X11_Xutil_INCLUDE_PATH})
>    ENDIF(X11_Xutil_INCLUDE_PATH)
>
> The question I have is whether there is _any_ platform left where X is
> distributed with X.h, Xlib.h, and Xutil.h in different directories?  If
> there is no possibility of that any more, then the above code could be
> vastly simplified to
>
> FIND_PATH(X11_INCLUDE_DIR X11/X.h ${X11_INC_SEARCH_PATH})

Another idea would be to only add the include path if it is not already in 
X11_INCLUDE_DIR , e.g. by testing with LIST(CONTAINS ...) which is in cvs 
HEAD. 

Bye
Alex


More information about the CMake mailing list