[CMake] 3rd party modules
Brad King
brad.king at kitware.com
Tue Sep 19 10:16:00 EDT 2006
Kedzierski, Artur CIV NAVSURFWARCENDIV CORONA wrote:
> Some packages provide modules/programs that
> provide information where they were installed. For
> example, "FooLibrary" may provide
> FooLibrary.m4 for auto-tools,
> FooLibrary.pc for pkg-confing,
> or
> Foo-config for anything else.
> As an author of a library, should I start
> providing anything for Cmake for easier integration
> (that works on multiple platforms)?
You should create a "FooConfig.cmake" file, where "Foo" is your project
name and "Config.cmake" is that exact string (capitalization and all).
The file should have information about the installed copy of Foo with
which it comes.
FIND_PACKAGE(Foo)
will look for FindFoo.cmake first and if not found then create a Foo_DIR
cache entry that asks the user to locate FooConfig.cmake. In the future
there will be better support for locating FooConfig.cmake automatically:
http://www.cmake.org/Bug/bug.php?op=show&bugid=3659
If you can't wait until that bug is implemented, install FooConfig.cmake
anyway and then create a small FindFoo.cmake that just looks for this
file and loads it. Then post FindFoo.cmake for your users to copy into
their projects or for inclusion into CMake.
The key is that the FindFoo.cmake file cannot be distributed as part of
Foo's distribution because by the time CMake finds it it must have
already found the project anyway.
-Brad
More information about the CMake
mailing list