CMakeLists.txt 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. add_definitions(-D__OPENCV_BUILD=1)
  2. add_definitions(-D__OPENCV_APPS=1)
  3. string(REPLACE "," ";" OPENCV_INSTALL_APPS_LIST "${OPENCV_INSTALL_APPS_LIST}") # support comma-separated list (,) too
  4. # Unified function for creating OpenCV applications:
  5. # ocv_add_application(tgt [MODULES <m1> [<m2> ...]] SRCS <src1> [<src2> ...])
  6. function(ocv_add_application the_target)
  7. cmake_parse_arguments(APP "" "" "MODULES;SRCS" ${ARGN})
  8. ocv_check_dependencies(${APP_MODULES})
  9. if(NOT OCV_DEPENDENCIES_FOUND)
  10. return()
  11. endif()
  12. project(${the_target})
  13. ocv_target_include_modules_recurse(${the_target} ${APP_MODULES})
  14. ocv_target_include_directories(${the_target} PRIVATE "${OpenCV_SOURCE_DIR}/include/opencv")
  15. ocv_add_executable(${the_target} ${APP_SRCS})
  16. ocv_target_link_libraries(${the_target} ${APP_MODULES})
  17. set_target_properties(${the_target} PROPERTIES
  18. DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
  19. ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
  20. RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
  21. OUTPUT_NAME "${the_target}")
  22. if(ENABLE_SOLUTION_FOLDERS)
  23. set_target_properties(${the_target} PROPERTIES FOLDER "applications")
  24. endif()
  25. if(NOT INSTALL_CREATE_DISTRIB
  26. OR (OPENCV_INSTALL_APPS_LIST STREQUAL "all" OR ";${OPENCV_INSTALL_APPS_LIST};" MATCHES ";${the_target};")
  27. )
  28. install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT dev)
  29. elseif(INSTALL_CREATE_DISTRIB)
  30. if(BUILD_SHARED_LIBS)
  31. install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_BIN_INSTALL_PATH} CONFIGURATIONS Release COMPONENT dev)
  32. endif()
  33. endif()
  34. endfunction()
  35. link_libraries(${OPENCV_LINKER_LIBS})
  36. macro(ocv_add_app directory)
  37. if(DEFINED BUILD_APPS_LIST)
  38. list(FIND BUILD_APPS_LIST ${directory} _index)
  39. if (${_index} GREATER -1)
  40. add_subdirectory(${directory})
  41. else()
  42. message(STATUS "Skip OpenCV app: ${directory}")
  43. endif()
  44. else()
  45. add_subdirectory(${directory})
  46. endif()
  47. endmacro()
  48. #ocv_add_app(traincascade)
  49. #ocv_add_app(createsamples)
  50. ocv_add_app(annotation)
  51. ocv_add_app(visualisation)
  52. ocv_add_app(interactive-calibration)
  53. ocv_add_app(version)
  54. ocv_add_app(model-diagnostics)