建立Opencv中的Cmake策略设置 [英] Cmake policy setting in building Opencv
问题描述
我不知道在哪里设置cmake_policy。
此链接已解释cmake_policy 。但不知道在哪里设置cmake策略。
我使用cmake来构建Opencv,我在cuda_compile_generated_row_filter有很多警告,如
CMake Warning(dev)。 2.cu.o.cmake:137(if):
未设置策略CMP0054:仅在未引用时解释if()参数作为变量或
关键字。运行cmake --help-policy CMP0054了解策略
的详细信息。使用cmake_policy命令设置策略并抑制此
警告。
我需要设置像 cmake_policy(SET CMP0054 NEW)
。
在哪里设置此策略?
我喜欢
ppp @ ppp-Inspiron-7537:〜/ Softwares / opencv-2.4.9 / build $ cmake_policy(SET CMP0054 NEW)
bash:在意外标记SET附近的语法错误
但我有错误。
如何设置策略?
使用 -Wno-dev
选项 cmake
用于禁止用于开发人员的警告:
cmake -Wno-dev< other-options> < source-dir> ;.
或者,如果要为项目设置策略,则需要修改其 CMakeLists.txt
文件并添加行
cmake_policy(SET CMP0054 OLD)
请注意,您需要对该属性使用 OLD 值,因为项目最有可能依赖此变量的取消引用。设置新值可能会打破项目的功能。
当项目的代码被修复时,即使没有明确的策略设置,也不会生成警告。
I am not sure where to set cmake_policy.
This link has explained cmake_policy. But not sure where to set cmake policy.
I use cmake to build Opencv and I have a lot of warnings like
CMake Warning (dev) at cuda_compile_generated_row_filter.2.cu.o.cmake:137 (if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.
I need to set like cmake_policy(SET CMP0054 NEW)
.
Where to set this policy?
I did like
ppp@ppp-Inspiron-7537:~/Softwares/opencv-2.4.9/build$ cmake_policy(SET CMP0054 NEW)
bash: syntax error near unexpected token `SET'
but I got error.
How can I set the policy?
解决方案 Use -Wno-dev
option for cmake
for suppress warnings intended for developers:
cmake -Wno-dev <other-options> <source-dir>
Alternatively, if you want to set policy for the project, you need to modify its CMakeLists.txt
file and add line
cmake_policy(SET CMP0054 OLD)
somewhere at the beginning.
Note, that you need to use OLD value for the property, as the project most likely relies on such variable's dereference. Setting NEW value will probably break project's functionality.
When project's code will be fixed, warnings won't be generated even without explicit policy set.
这篇关于建立Opencv中的Cmake策略设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!