【问题标题】:Cmake policy setting in building Opencv构建 Opencv 中的 Cmake 策略设置
【发布时间】:2016-05-19 07:31:54
【问题描述】:

我不确定在哪里设置 cmake_policy。 这个link 解释了cmake_policy。但不确定在哪里设置 cmake 策略。 我使用 cmake 构建 Opencv 并且有很多警告,例如

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.

我需要设置为cmake_policy(SET CMP0054 NEW)。 在哪里设置此政策? 我确实喜欢

ppp@ppp-Inspiron-7537:~/Softwares/opencv-2.4.9/build$ cmake_policy(SET CMP0054 NEW)
bash: syntax error near unexpected token `SET'

但我得到了错误。 如何设置政策?

【问题讨论】:

    标签: opencv cmake


    【解决方案1】:

    使用cmake-Wno-dev 选项来抑制针对开发人员的警告:

    cmake -Wno-dev <other-options> <source-dir>
    

    或者,如果要为项目设置策略,则需要修改其CMakeLists.txt 文件并添加行

    cmake_policy(SET CMP0054 OLD)
    

    在开头的某个地方。

    注意,您需要为属性使用 OLD 值,因为项目很可能依赖于此类变量的取消引用。设置 NEW 值可能会破坏项目的功能。

    当项目的代码被修复时,即使没有明确的政策设置也不会产生警告。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-02
      • 2018-07-17
      • 1970-01-01
      • 1970-01-01
      • 2015-06-17
      相关资源
      最近更新 更多