OpenCVGenABI.cmake 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. if (NOT GENERATE_ABI_DESCRIPTOR)
  2. return()
  3. endif()
  4. set(OPENCV_ABI_SKIP_MODULES_LIST "" CACHE STRING "List of modules to exclude from ABI checker")
  5. set(filename "opencv_abi.xml")
  6. set(path1 "${CMAKE_BINARY_DIR}/${filename}")
  7. set(modules "${OPENCV_MODULES_PUBLIC}")
  8. ocv_list_filterout(modules "opencv_ts")
  9. message(STATUS "Generating ABI compliance checker configuration: ${filename}")
  10. if (OPENCV_VCSVERSION AND NOT OPENCV_VCSVERSION STREQUAL "unknown")
  11. set(OPENCV_ABI_VERSION "${OPENCV_VCSVERSION}")
  12. else()
  13. set(OPENCV_ABI_VERSION "${OPENCV_VERSION}")
  14. endif()
  15. # Headers
  16. set(OPENCV_ABI_HEADERS "{RELPATH}/${OPENCV_INCLUDE_INSTALL_PATH}")
  17. # Libraries
  18. set(OPENCV_ABI_LIBRARIES "{RELPATH}/${OPENCV_LIB_INSTALL_PATH}")
  19. foreach(mod ${OPENCV_MODULES_BUILD})
  20. string(REGEX REPLACE "^opencv_" "" mod "${mod}")
  21. if(NOT OPENCV_MODULE_opencv_${mod}_CLASS STREQUAL "PUBLIC"
  22. OR NOT "${OPENCV_MODULE_opencv_${mod}_LOCATION}" STREQUAL "${OpenCV_SOURCE_DIR}/modules/${mod}" # opencv_contrib
  23. OR ";${mod};" MATCHES ";${OPENCV_ABI_SKIP_MODULES_LIST};"
  24. )
  25. # headers
  26. foreach(h ${OPENCV_MODULE_opencv_${mod}_HEADERS})
  27. file(RELATIVE_PATH h "${OPENCV_MODULE_opencv_${mod}_LOCATION}/include" "${h}")
  28. list(APPEND OPENCV_ABI_SKIP_HEADERS "${h}")
  29. endforeach()
  30. # libraries
  31. if(TARGET opencv_${mod}) # opencv_world
  32. list(APPEND OPENCV_ABI_SKIP_LIBRARIES "\$<TARGET_FILE_NAME:opencv_${mod}>")
  33. endif()
  34. endif()
  35. endforeach()
  36. string(REPLACE ";" "\n " OPENCV_ABI_SKIP_HEADERS "${OPENCV_ABI_SKIP_HEADERS}")
  37. string(REPLACE ";" "\n " OPENCV_ABI_SKIP_LIBRARIES "${OPENCV_ABI_SKIP_LIBRARIES}")
  38. # Options
  39. set(OPENCV_ABI_GCC_OPTIONS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -DOPENCV_ABI_CHECK=1 -DCV_DNN_DONT_ADD_INLINE_NS=1")
  40. string(REGEX REPLACE "([^ ]) +([^ ])" "\\1\\n \\2" OPENCV_ABI_GCC_OPTIONS "${OPENCV_ABI_GCC_OPTIONS}")
  41. configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_abi.xml.in" "${path1}.base")
  42. file(GENERATE OUTPUT "${path1}" INPUT "${path1}.base")