[CMake] FindX11 vs. Lion

Clifford Yapp cliffyapp at gmail.com
Tue Aug 21 16:00:44 EDT 2012


On Tue, Aug 21, 2012 at 2:38 PM, Randolph M. Fritz <RFritz at lbl.gov> wrote:

> What problems did your solutions address?  I've skimmed them, but am not
> sure I understand them.  I'd also be interested in hearing from anyone else
> who has done this, and even people who have done it on Windows systems.

In our specific case, the problem was "we have a Mac with both a
system X11 and a MacPorts/Fink X11 - mixing and matching is Not Good,
so get FindX11 to avoid mixing them."

The basic idea is to forbid CMake from searching Fink/MacPorts paths
for libraries if they are disabled.  The broader problem of multiple
distinct X11 installations we do not address - that has lots of sharp
corners that would be a pain to deal with.  Our FindX11 will warn if
it sees X11 libraries coming from different prefixes, but sometimes
symlinking means it's finding the same libraries anyway...  In the
case of a MacPorts install that doesn't have everything we need but
has SOME of it, we don't avoid finding the System versions of those
libraries if we specify that we want MacPorts.  So the best we can do
at this point is warn - ideally it shouldn't return any non-MacPorts
X11 libs though.

To really avoid finding "undesirable" X11 components on a system with
multiple X11 installs, you'd probably have to do an individual,
directory constrained search through *all* the system search paths for
one of the core X11 libs and/or headers.  Once you have built up a set
of "candidates", you would then have to run the full X11 search logic,
constrained to each candidate path, and build up search results for
each candidate.  Then, once you have built all of those candidate
sets, you'll have to decide which one satisfies the search criteria
and set all the "final" X11 variables used by programs.

I've tried something similar when searching for Tcl/Tk - it's very
easy to have search logic of that nature get crazy complex.  Since
excluding MacPorts and Fink paths from search results deals with (for
us) the most common case of multiple X11s, the considerable effort to
build a "set enforcing" X11 search hasn't been undertaken yet.

There's probably some sort of more general "define a set of components
and return all available sets on the system" functionality that could
be speced out for this stuff, but I haven't really thought too hard
about what it would look like generally - if its needed for X11
though, it's probably worth taking the time to do right.

Cheers,
CY


More information about the CMake mailing list