[CMake] providing library information, what's the cmake way

Johannes Zarl Johannes.Zarl at jku.at
Tue Nov 23 06:57:56 EST 2010


Sorry for hijacking this thread, but I'm wondering about this for some 
time, too. (And the information in the doc/wiki is somewhat dated and/or 
ambiguous [1,2,3,4]). I will just go on and write my thoughts and what I 
(think I) know, in the hope that somebody corrects those things I got 
wrong.

So summarizing the previous mesage in the thread, one can say:
 + cmake aware packages should provide LibraryConfig.cmake scripts
   (and optionally LibraryVersion.cmake scrips), just like they would
   provide pkg-config files.
 + developers should create FindLibrary.cmake scripts for packages
   they are using that are not cmake aware.

I think that information should be transported more clearly, because
in practice most cmake based software provides a FindLibrary.cmake
file for itself.

Also, I could not find a definitive answer on where these packages 
should put the LibraryConfig.cmake script. If I read the search paths in
[1] correctly, the preferred paths are:
 + <prefix>/ on windows
 + <prefix>/(share|lib)/cmake/<name>*/ on linux, and
 + <prefix>/<name>.framework/Resources/ on Apple

We have have every library and library-version in its own prefix and use 
shell modules[5] to provide the correct environment that a user wants.
Is there any way to let cmake know about specific prefix directories it 
should be aware of? Unfortunately, the CMAKE_MODULE_PATH variable has
to be manually set, and not influenced by the environment.

Something like the PKG_CONFIG_PATH environment variable for pkg-config
would be really nice to have in cmake.

Another somehow related topic seems to be import/export of targets. Should
a LibraryConfig.cmake or FindLibrary.cmake file create imported targets
for the library?

And is there any documentation on how to create a LibraryConfig.cmake file
with support for components?

Cheers,
  Johannes

[1] http://www.cmake.org/cmake/help/cmake-2-8-docs.html#command:find_package
[2] http://www.cmake.org/Wiki/CMake_HowToFindInstalledSoftware
[3] http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries
[4] http://www.cmake.org/Wiki/CMake:Improving_Find*_Modules
[5] http://modules.sourceforge.net/




-- 
Johannes Zarl
Virtual Reality Services

Johannes Kepler University
Informationsmanagement

Altenbergerstrasze 69
4040 Linz, Austria
Phone: +43 732 2468-8321
johannes.zarl at jku.at
http://vrc.zid.jku.at












More information about the CMake mailing list