CMakeLists.txt 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. set(the_description "All OpenCV modules")
  2. set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE)
  3. set(BUILD_opencv_world_INIT OFF)
  4. if(NOT BUILD_SHARED_LIBS)
  5. set(OPENCV_MODULE_TYPE STATIC)
  6. set(OPENCV_WORLD_FLAGS_PROPERTY STATIC_LIBRARY_FLAGS)
  7. else()
  8. set(OPENCV_WORLD_FLAGS_PROPERTY LINK_FLAGS)
  9. endif()
  10. function(include_one_module m)
  11. include("${OPENCV_MODULE_${m}_LOCATION}/CMakeLists.txt")
  12. foreach(var
  13. CMAKE_CXX_FLAGS CMAKE_C_FLAGS # Propagate warnings settings
  14. )
  15. set(${var} "${${var}}" PARENT_SCOPE)
  16. endforeach()
  17. endfunction()
  18. if(NOT OPENCV_INITIAL_PASS)
  19. set(ENABLE_PRECOMPILED_HEADERS OFF CACHE INTERNAL "" FORCE)
  20. project(opencv_world)
  21. message(STATUS "Processing WORLD modules...")
  22. foreach(m ${OPENCV_MODULES_BUILD})
  23. set(the_module ${m})
  24. if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
  25. message(STATUS " module ${m}...")
  26. set(CMAKE_CURRENT_SOURCE_DIR "${OPENCV_MODULE_${m}_LOCATION}")
  27. #add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" ${CMAKE_CURRENT_BINARY_DIR}/${m})
  28. include_one_module(${m})
  29. endif()
  30. endforeach()
  31. message(STATUS "Processing WORLD modules... DONE")
  32. set(CMAKE_CURRENT_SOURCE_DIR "${OPENCV_MODULE_opencv_world_LOCATION}")
  33. endif()
  34. ocv_add_module(world opencv_core)
  35. set(headers_list)
  36. set(sources_list)
  37. set(link_deps "")
  38. foreach(m ${OPENCV_MODULE_${the_module}_DEPS} opencv_world)
  39. if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
  40. list(APPEND headers_list ${OPENCV_MODULE_${m}_HEADERS})
  41. list(APPEND sources_list ${OPENCV_MODULE_${m}_SOURCES})
  42. endif()
  43. if(NOT " ${OPENCV_MODULE_${m}_LINK_DEPS}" STREQUAL " ")
  44. list(APPEND link_deps ${OPENCV_MODULE_${m}_LINK_DEPS})
  45. endif()
  46. endforeach()
  47. ocv_glob_module_sources(HEADERS ${headers_list} SOURCES ${sources_list})
  48. ocv_module_include_directories()
  49. #message(STATUS "${OPENCV_MODULE_${the_module}_HEADERS}")
  50. #message(STATUS "${OPENCV_MODULE_${the_module}_SOURCES}")
  51. ocv_create_module(${link_deps})
  52. if(";${OPENCV_MODULES_BUILD};" MATCHES ";opencv_viz;" AND OPENCV_MODULE_opencv_viz_IS_PART_OF_WORLD AND NOT (VTK_VERSION VERSION_LESS "8.90.0"))
  53. vtk_module_autoinit(TARGETS opencv_world MODULES ${VTK_LIBRARIES})
  54. endif()
  55. ocv_target_compile_definitions(${the_module} PRIVATE OPENCV_MODULE_IS_PART_OF_WORLD=1)
  56. if(BUILD_opencv_imgcodecs AND OPENCV_MODULE_opencv_imgcodecs_IS_PART_OF_WORLD)
  57. ocv_imgcodecs_configure_target()
  58. endif()
  59. if(BUILD_opencv_highgui AND OPENCV_MODULE_opencv_highgui_IS_PART_OF_WORLD)
  60. ocv_highgui_configure_target()
  61. endif()