[Cmake] Making the cmake FindXXX.cmake files more consistent

Brad King brad.king at kitware.com
Fri Aug 16 15:36:32 EDT 2002


> This list of variables brings a subtle assumption that I would rather
> not have: the client of a library must specify the *directories* for any
> dependent libraries.
[snip]
> I think, therefore, that the FOO_LIBRARY_DIRS should not exist. That
> path should be embedded in FOO_LIBRARIES. Now, it may be somewhat
> accidental that this works. If so, I think CMake should be made so
> that this is not accidental. The less the client needs to know about
> implementation details of a library, the better.

This is a fine idea.  The fewer variables the better.  Also, I think
perahps we should use "FOO_EXECUTABLE" for the path to FOO's executable
instead of just "FOO".

> Perhaps we should provide a corresponding UseFOO module that does the
> first three (two, with my suggestion above)? Saves a _little_ bit of
> typing, and may provide a convenient place for funny libraries. For
> example, libpng needs special definitions depending on shared or static
> libraries, client code or library code, etc.

This thought also crossed my mind while I was writing the previous
message.  We then need to add another variable definition like
FOO_USE_MODULE, so code can be written like this:

INCLUDE(${CMAKE_ROOT}/Modules/FindFOO.cmake)

IF(FOO_FOUND)
  INCLUDE(${FOO_USE_MODULE})
ENDIF(FOO_FOUND)

This way each project can provide its own UseFOO.cmake, but the modules
directory can also provide one for projects that don't.  The FindFOO
module can decide which to use and set the variable.

> But how long must the ugliness remain? :-) Perhaps we could use the
> CMake minimum required version to conditionally do the backward
> compatible stuff.

We will need to have a way to check the CMake minimum required settings
from a CMakeLists.txt file.  Right now I think it can only be checked from
CMake C++ code internally.  This could probably be done pretty easily,
though.

-Brad




More information about the CMake mailing list