[CMake] Query about FindXXX files

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed Sep 17 17:11:55 EDT 2008


On 2008-09-17 15:45-0000 Leo Breebaart wrote:

> 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.

Yes, you are correct.

>
> 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...

I think you have answered your own question.  Determine local things
locally and determine things that are going to be used in more than
one place in a higher level directory.

N.B. to keep our top-level CMakeLists.txt file from getting too cluttered
by general find commands, it is a nice idea to set CMAKE_MODULE_PATH in your
top-level directory, then include files from there.

e.g.,

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)

include(anyname)

immediately includes CMake commands from cmake/modules/anyname.cmake just as
if they had been typed in the top-level CMakeLists.txt.  Furthermore,
anyname.cmake itself can include other files from cmake/modules so that helps
you to keep everything nicely organized.

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