关于cmake中CMP0074变量设置以及<PackageName>_ROOT

警告提示

使用cmake时出现CMP0074警告。

CMake Warning (dev) at CMakeLists.txt:5 (find_package):
  Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
  Run "cmake --help-policy CMP0074" for policy details.  Use the cmake_policy
  command to set the policy and suppress this warning.

  Environment variable Eigen3_ROOT is set to:

    C:\Program Files (x86)\Eigen3

  For compatibility, CMake is ignoring the variable.
This warning is for project developers.  Use -Wno-dev to suppress it.

问题分析

根据警告提示信息,_ROOT变量被忽略了,如果不想忽略需要使用cmake_policy指令设置变量CMP0074。

解决方法

在CMakeLists.txt中第二行添加一条cmake_policy(SET CMP0074 NEW) 或者 cmake_policy(SET CMP0074 OLD),前面所示的警告就消失了。在Windows中使用cmake的一些无法找到库文件的错误提示,比如常见 xxx not found 也是因为这个变量没有设置忽略了<PackageName>_ROOT导致的。

参考链接

https://stackoverflow.com/questions/56586348/how-to-handle-with-policy-cmp0074-is-not-set-error-while-using-cmake-to-build

https://cmake.org/cmake/help/latest/policy/CMP0074.html

https://cmake.org/cmake/help/latest/command/cmake_policy.html#command:cmake_policy

评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值