[CMake] Howto create a ProjectConfig.cmake tutorial

Eric Noulard eric.noulard at gmail.com
Wed Aug 8 11:49:25 EDT 2012


2012/8/8 Nico Schlömer <nico.schloemer at gmail.com>:
>> see:
>> cmake --help-module CMakePackageConfigHelpers
>
> This gives
>
> $ cmake --help-module CMakePackageConfigHelpers
> cmake version 2.8.7
> Argument "CMakePackageConfigHelpers" to --help-module is not a CMake module.

This has been added in 2.8.8.

> on my system.
> I understand now that ${INSTALL_DATA_DIR} is a variable I'll just have
> to set myself, which does work if I set to a directory relative to the
> installation directory.
>
> Even the example runs through cleanly then, and produces
>
> FooBarLibraryDepends.cmake
> FooBarLibraryDepends-release.cmake
>
> The all-important FooBarConfig.cmake, which I though this whole
> document was about, is not created.

Do you mean in the FooBar example or in **your** project?
When I run cmake on the FooBar.zip I do get the
FooBarConfig.cmake
FooBarConfigVersion.cmake

in the build tree, however the CMakeLists.txt miss the rule
to install them.

Try adding:
install(FILES
        ${PROJECT_BINARY_DIR}/FooBarConfig.cmake
        ${PROJECT_BINARY_DIR}/FooBarConfigVersion.cmake
        DESTINATION ${INSTALL_DATA_DIR}/FooBar/CMake)

> Is there any other documentation on this?

http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file
(but as you discovered it should be updated)

The find_package command explains how the <Project>Config.cmake file
is processed:
http://www.cmake.org/cmake/help/v2.8.7/cmake.html#command:find_package

But for CMake being to find the file it should be installed (as other
file of the project do).

And may be this old message explain the whole process:
http://www.cmake.org/pipermail/cmake/2010-December/041619.html


-- 
Erk
Le gouvernement représentatif n'est pas la démocratie --
http://www.le-message.org


More information about the CMake mailing list