[CMake] Query about FindXXX files
Leo Breebaart
leo at lspace.org
Wed Sep 17 11:45:39 EDT 2008
Christian Ehrlicher <Ch.Ehrlicher at gmx.de> writes:
> Leo Breebaart schrieb:
> > In CMake 2.6.1, the header for FindTIFF.cmake says:
> >
> > # This module defines
> > # TIFF_INCLUDE_DIR, where to find tiff.h, etc.
> > # TIFF_LIBRARIES, libraries to link against to use TIFF.
> > # TIFF_FOUND, If false, do not try to use TIFF.
> > # also defined, but not for general use are
> > # TIFF_LIBRARY, where to find the TIFF library.
> >
> > However, after executing:
> >
> > FIND_PACKAGE(TIFF)
> >
> > my CMakeCache.txt now has the following entries:
> >
> > TIFF_INCLUDE_DIR:PATH=/usr/include
> > TIFF_LIBRARY:FILEPATH=/usr/lib/libtiff.so
> >
> > So, in other words, the "not for general use" TIFF_LIBRARY
> > variable is placed in my cache, while the promised TIFF_LIBRARIES
> > variable is not.
>
> Is there a reason why you want to have the other vars in
> CMakeCache.txt? Isn't it enough to have them available?
Yes, it should be, I suppose.
My use case is that I have in my sources a 3rd party non-CMake
library that I need to include in my overall build. So I have
'cmakified' that library, and since it relies on libtiff, I call
the FIND_PACKAGE(TIFF) in that CMakeFile, so it can also compile
standalone.
Now elsewhere in my sources I have an application that actually
uses the 3rd party library, but which of course still needs to
link to libtiff as well. So I was attempting to add
${TIFF_LIBRARIES} to that application's TARGET_LINK_LIBRARIES,
when I discovered the issues in my earlier message.
So if the Cache is not the right way to pass information
'sideways' in your build tree, what is? I think I understand (but
please correct if I get it wrong -- I am new to CMake) that if I
call FIND_PACKAGE(TIFF) at a high enough level, i.e. at my top
level CMakeLists.txt, the TIFF_LIBRARIES var will be available to
all 'lower' level directories reached via ADD_SUBDIRECTORY.
But in this case, it still seems somehow wrong to me not to keep
the check where it belongs, i.e. with the application. But the
library is not a subdir from the application dir (and shouldn't
be -- it may be used elsewhere as well), so I still have that
'passing information sideways' problem. TIFF_INCLUDE_DIR is no
problem, because FIND_PACKAGE(TIFF) *does* put that one in the
cache...
--
Leo Breebaart <leo at lspace.org>
More information about the CMake
mailing list