CMake Warning at cmake/OpenCVPackaging.cmake:23 (message): CPACK_PACKAGE_VER 问题处理

来源:互联网 发布:软件fmea可靠性分析 编辑:程序博客网 时间:2024/05/18 15:25

今天在win7中配置opencv2.4.13 时报错  ,错误信息是:CMake Warning at cmake/OpenCVPackaging.cmake:23 (message): CPACK_PACKAGE_VER

网上搜了一圈,发现只有提问的,没有找到答案,只好自己想办法了。

我也是cmake小白,没使过这工具,只好硬着头皮去想办法。根据报错信息“”cmake/OpenCVPackaging.cmake:23“”

错误现场信息是:

  if (NOT "${OPENCV_VCSVERSION}" MATCHES "^${OPENCV_VERSION}.*")
    message(WARNING "CPACK_PACKAGE_VERSION does not match version provided by version.hpp header!")
  endif()

然后去找${OPENCV_VCSVERSION}  , ${OPENCV_VERSION} 这2个参数信息是从哪里来

最后在CMakeList.txt文件中找到如下信息

status("General configuration for OpenCV ${OPENCV_VERSION} =====================================")
if(OPENCV_VCSVERSION)
  status("  Version control:" ${OPENCV_VCSVERSION})
endif()

正好是状态输出中有看到,如下

General configuration for OpenCV 2.4.13 =====================================

Version control: unknown


也就是对应了${OPENCV_VERSION} = 2.4.13  ,  ${OPENCV_VCSVERSION}) = unknown


继续寻找${OPENCV_VCSVERSION}) 这个参数是在哪里赋值的

找找找,找到了,在这里

find_host_program(GIT_EXECUTABLE NAMES ${git_names} PATH_SUFFIXES Git/cmd Git/bin DOC "git command line client")
mark_as_advanced(GIT_EXECUTABLE)

if(GIT_EXECUTABLE)
  execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty --match "2.[0-9].[0-9]*"
    WORKING_DIRECTORY "${OpenCV_SOURCE_DIR}"
    OUTPUT_VARIABLE OPENCV_VCSVERSION
    RESULT_VARIABLE GIT_RESULT
    ERROR_QUIET
    OUTPUT_STRIP_TRAILING_WHITESPACE
  )
  if(NOT GIT_RESULT EQUAL 0)
    set(OPENCV_VCSVERSION "unknown")
  endif()
else()
  # We don't have git:
  set(OPENCV_VCSVERSION "unknown")
endif()


原来这个参数是需要安装git客户端工具才能获得,所以装个git工具应该就可以解决问题,本人偷懒,直接改了如下内容

  if(NOT GIT_RESULT EQUAL 0)
    set(OPENCV_VCSVERSION "unknown")
  endif()
else()
  # We don't have git:
  # set(OPENCV_VCSVERSION "unknown")
  set(OPENCV_VCSVERSION "2.4.13")
endif()


保存编译,通过,接下来编译一切正常,把处理过程记录下来,希望能帮到cmake小白