使用cmake进行编译安装时指定安装位置

使用默认安装位置进行编译安装,在卸载时会比较麻烦,因此选择设置制定的安装位置方便管理。

mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/xxx/yyy ..
make
sudo make install

当用cmake安装其他库的时候,可能会出现类似下面的warning

Could not find a package configuration file provided by "fmt" with any of
  the following names:

    fmtConfig.cmake
    fmt-config.cmake

  Add the installation prefix of "fmt" to CMAKE_PREFIX_PATH or set "fmt_DIR"
  to a directory containing one of the above files.  If "fmt" provides a
  separate development package or SDK, be sure it has been installed.

如果确定已经安装过这个库(fmt),那么打开现在正在安装的CMakeLists.txt,在里面增加下面这一行(path为包含 fmtConfig.cmake 或 fmt-config.cmake 的路径)

set(fmt_DIR /path)

然后就不会有这个warning了。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值