[CMake] What does `cross-platform' mean?
Alexander Neundorf
a.neundorf-work at gmx.net
Fri Nov 7 13:08:03 EST 2008
On Friday 07 November 2008, Bill Hoffman wrote:
> So, currently CMake assumes that the environment you are working from is
> correctly configured. I think adding CMakeModule would go beyond the
> scope of what CMake should be doing. Just like you have to have a
> working compiler in your path, you should also have a working environment.
>
> However, I am sure the find_* stuff can be further refined, and extra
> error checks put in place to make sure ABI's match. CMake works best if
> it can find a full path to a specific library. The idea of a command
> that turns -L/path -lA into /path/libA.a sounds like a useful thing to
> add.
>
> So, as to the title of this thread, Cross platform means Windows, OSX,
> Linux (all distros), HPUX, IRIX, SunOS, Haiku, QNX, cygwin, mingw.
>
> As far as I can tell, the only problem you are talking about here, is
> when you link to a static library that depends on other static libraries
> CMake is not figuring out the depend information for you. That
> information has to come form somewhere. It comes from:
>
> 1. pkg-config output, which potentially needs the above command that can
> turn -L -l into full paths for the libraries.
I think a command to actually parse the pkgconfig files by cmake itself may be
a good idea. This would avoid the need to
* search the pkg-config executable (ok, easy)
* execute it multiple times (didn't measure, but might slow cmake runs down
somewhat)
* parse the stdout of pkgconfig within cmake (the pc files can also be buggy)
and handle the -L/foo/lib -l foo correctly, which may easily break the build
(as you noticed)
* avoid the need to set PKG_CONFIG_PATH, since cmake could assume that the
variables whcih specify the search directories find_library() already contain
also the library dir where the pkgconfig/ subdir is located.
In general, you should link to libraries found using find_library(). Then they
have the full path and cmake gets the ordering right. If you mix in results
from pkg-config, things may go wrong.
The issue with being able to specify that you are searching the static version
of a library is asked often, and I don't remember the solution to this. May
be worth a feature request in the bug tracker.
About the different versions: since 2.6.0 (or 2.6.1 ?) find_package() supports
specifying version numbers, now "only" the modules have to be adapted to
support this too. Some modules, e.g. FindQt4.cmake, supported versions
already before by using a special variable like QT_MIN_VERSION, which you
have to set to the minimum version you want to have . Then the module can
check whether it found a good version and fail if it didn't. So this is
basically a problem of the individual modules and no general cmake problem.
If you know where the set of libs is which you want to use I suggest setting
the CMAKE_PREFIX_PATH environment variable accordingly, so cmake looks in
these directories first.
Alex
More information about the CMake
mailing list