[CMake] find_package and lib/cmake.<project>

Nils Gladitz nilsgladitz at gmail.com
Sun Sep 21 17:54:12 EDT 2014


On 21.09.2014 23:34, Biddiscombe, John A. wrote:
> If a projX is installed to
>
> ~/apps/projX
>
> And when installed it creates
>
> projXConfig.cmake
> projXConfigVersion.cmake
> projXTargets-debug.cmake
> projXTargets.cmake
> &etc.
>
> In ~/apps/projX/lib/cmake/projX
>
> It is necessary to say
> cmake –Dprojx_DIR=~/apps/projX/lib/cmake/projX …..
>
> When configuring another project that uses find_package(projX)
>
> Is there a way of setting it up so that the user only has to say
> cmake –Dprojx_DIR=~/apps/projX …..
>
> Without putting all the installed *.cmake files at the root of the install. It seems odd to me that CMake doesn’t search in lib/cmake/<projectname>

The cache variable projX_DIR points at the directory that contains the 
configuration file (e.g. is not an installation prefix) and will also be 
set by cmake itself if it finds a configuration file.
The environment variables projX_DIR and CMAKE_PREFIX_PATH expect an 
installation prefix.

e.g. setting the projX_DIR environment variable to ~/apps/projX should 
have it look in ~/apps/projX/lib/cmake/<name>* as well.

Nils


More information about the CMake mailing list