OpenCVVersion.cmake 1.9 KB

123456789101112131415161718192021222324252627
  1. SET(OPENCV_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/modules/core/include/opencv2/core/version.hpp")
  2. file(STRINGS "${OPENCV_VERSION_FILE}" OPENCV_VERSION_PARTS REGEX "#define CV_VERSION_[A-Z]+[ ]+" )
  3. string(REGEX REPLACE ".+CV_VERSION_MAJOR[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MAJOR "${OPENCV_VERSION_PARTS}")
  4. string(REGEX REPLACE ".+CV_VERSION_MINOR[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MINOR "${OPENCV_VERSION_PARTS}")
  5. string(REGEX REPLACE ".+CV_VERSION_REVISION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_PATCH "${OPENCV_VERSION_PARTS}")
  6. string(REGEX REPLACE ".+CV_VERSION_STATUS[ ]+\"([^\"]*)\".*" "\\1" OPENCV_VERSION_STATUS "${OPENCV_VERSION_PARTS}")
  7. set(OPENCV_VERSION_PLAIN "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}")
  8. set(OPENCV_VERSION "${OPENCV_VERSION_PLAIN}${OPENCV_VERSION_STATUS}")
  9. string(REGEX MATCH "[0-9][0-9]$" OPENCV_VERSION_MINOR_2DIGITS "00${OPENCV_VERSION_MINOR}")
  10. string(REGEX MATCH "[0-9][0-9]$" OPENCV_VERSION_PATCH_2DIGITS "00${OPENCV_VERSION_PATCH}")
  11. ocv_update(OPENCV_SOVERSION "${OPENCV_VERSION_MAJOR}${OPENCV_VERSION_MINOR_2DIGITS}")
  12. ocv_update(OPENCV_LIBVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}")
  13. # create a dependency on the version file
  14. # we never use the output of the following command but cmake will rerun automatically if the version file changes
  15. configure_file("${OPENCV_VERSION_FILE}" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/opencv_junk/version.junk" COPYONLY)
  16. ocv_update(OPENCV_VS_VER_FILEVERSION_QUAD "${OPENCV_VERSION_MAJOR},${OPENCV_VERSION_MINOR},${OPENCV_VERSION_PATCH},0")
  17. ocv_update(OPENCV_VS_VER_PRODUCTVERSION_QUAD "${OPENCV_VERSION_MAJOR},${OPENCV_VERSION_MINOR},${OPENCV_VERSION_PATCH},0")
  18. ocv_update(OPENCV_VS_VER_FILEVERSION_STR "${OPENCV_VERSION}")
  19. ocv_update(OPENCV_VS_VER_PRODUCTVERSION_STR "${OPENCV_VERSION}")
  20. ocv_update(OPENCV_VS_VER_PRODUCTNAME_STR "OpenCV library")
  21. ocv_update(OPENCV_VS_VER_COMMENTS_STR "http://opencv.org/")