如何安装您的自定义CMake-Find模块 [英] How to install your custom CMake-Find module

查看:495
本文介绍了如何安装您的自定义CMake-Find模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CMake和CPack配置和打包我的库。我写了我自己的查找模块FindMyLib.cmake。

I configure and package my library using CMake and CPack. I've written my own find-module FindMyLib.cmake.

如何告诉CMake / CPack将这个文件添加到CMake模块目录,以便未来的开发人员可以只要指定FIND_PACKAGE(MyLib)使用我的库?

How do I tell CMake/CPack to add this file to the CMake module directory, so that future developers can simply specify FIND_PACKAGE(MyLib) to use my library?

推荐答案

CMake模块目录是CMake本身的安装树的一部分,

The CMake module directory is part of the install tree of CMake itself, and as such you shouldn't be trying to add anything there.

CMake模块目录包含已由Kitware编写或至少审核的模块,并添加您自己的模块会给你的项目的用户给你的印象也是你的项目的情况。

The CMake module directory contains modules which have been written or at least reviewed by Kitware, and adding your own there would give the impression to users of your project that this was the case for your project also.

你最好只是安装FindMyLib.cmake到其中一个 find_package 搜寻的地点:

You'd be better to just install FindMyLib.cmake to one of the places searched by find_package:


<prefix>/                                               (Windows)
<prefix>/(cmake|CMake)/                                 (Windows)
<prefix>/<name>*/                                       (Windows)
<prefix>/<name>*/(cmake|CMake)/                         (Windows)
<prefix>/(lib/<arch>|lib|share)/cmake/<name>*/          (Unix)
<prefix>/(lib/<arch>|lib|share)/<name>*/                (Unix)
<prefix>/(lib/<arch>|lib|share)/<name>*/(cmake|CMake)/  (Unix)
<prefix>/<name>.framework/Resources/                    (Apple)
<prefix>/<name>.framework/Resources/CMake/              (Apple)
<prefix>/<name>.framework/Versions/*/Resources/         (Apple)
<prefix>/<name>.framework/Versions/*/Resources/CMake/   (Apple)
<prefix>/<name>.app/Contents/Resources/                 (Apple)
<prefix>/<name>.app/Contents/Resources/CMake/           (Apple)


br />

请参阅 find_package 搜索的完整详细信息,请参阅 find_package 的nofollow>文档。此外, CMake包装教程在这种情况下也很有用。

See the documentation for find_package for the full details of how find_package searches. Also the CMake packaging tutorial is useful in this case.

这篇关于如何安装您的自定义CMake-Find模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆