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

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Aug 6 16:57:17 EDT 2007


On 2007-08-06 15:27-0400 Alexander Neundorf wrote:

> 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.
>
> Does this really happen ?

Yes.  :-)

> Please have a look at
> void cmMakefile::AddIncludeDirectory(const char* inc, bool before), this
> should actually avoid duplicates according to the comment.

I am guessing a bit here, but I think you are referring to INCLUDE_DIRECTORIES
behaviour?

I wasn't sure what INCLUDE_DIRECTORIES would do with duplicates, and it is
nice to know they are eliminated.  However, for the
SET_SOURCE_FILES_PROPERTIES case reported above (which of course is quite
different from INCLUDE_DIRECTORIES) duplicate C flags are not eliminated.

I use the command

string(REGEX REPLACE ";" " -I" X11_COMPILE_FLAGS "-I${X11_INCLUDE_DIR}")

to transform X11_INCLUDE_DIR delivered by FindX11.cmake (currently
"/usr/include;/usr/include;/usr/include" which is the fundamental problem)
into a form that can be used by SET_SOURCE_FILES_PROPERTIES to set
PROPERTIES COMPILE_FLAGS using ${X11_COMPILE_FLAGS} on those of our source
files that need it.

The result is X11_COMPILE_FLAGS is set to

-I/usr/include -I/usr/include -I/usr/include

and these triplicate flags (I just double-checked this) are indeed the gcc
options that are used for compiling for the SET_SOURCE_FILES_PROPERTIES
PROPERTIES COMPILE_FLAGS case.

Getting back to the original issue, does anybody here have enough X
experience to comment on my patch (sent earlier in this thread) for
simplifying FindX11.cmake so it doesn't produce triplicate values of
X11_INCLUDE_DIR?  I believe my patch is worthwhile because it removes a lot
of unnecessary cruft (it is certainly unnecessary on my system) as well as
the annoying triplicate results.  However, the patched version needs
wide-spread testing to be sure all is well on all X platforms.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list