[CMake] find_package is fantastic

Brad King brad.king at kitware.com
Wed Nov 4 13:30:34 EST 2009


Mathieu Malaterre wrote:
> Just wanted to say : great job on the find_package interface !

Thanks!

> This is extremely convenient to use for package using cmake as build package.
> All I had to do is configure a *Config.cmake and a
> *ConfigVersion.cmake file. And then from the outside I can simply
> find_package(MyPackage HINTS $ENV{MyPackage_ROOT})
> 
> -> No need to write a FindMyPackage.cmake
> -> *Congif.cmake files are auto-magically found
> -> Version is automatically taken into account.
> -> I can easily configure/build, thanks to a simple env var.

FYI, you don't actually need the HINTS option either.
Just set CMAKE_PREFIX_PATH in your environment to point
at the installation prefix (or even the build tree).

You can also set the env var MyPacakage_DIR and it will be used
automatically.  I've just committed documentation and testing
for this old but previously un-advertised feature.

-Brad


Document and test find_package <pkg>_DIR env var
/cvsroot/CMake/CMake/Source/cmFindPackageCommand.cxx,v  <--  Source/cmFindPackageCommand.cxx
new revision: 1.67; previous revision: 1.66
/cvsroot/CMake/CMake/Tests/FindPackageTest/CMakeLists.txt,v  <--  Tests/FindPackageTest/CMakeLists.txt
new revision: 1.20; previous revision: 1.19



More information about the CMake mailing list