CMakeLists.txt 2.4 KB
Newer Older
1
set(the_description "All the selected OpenCV modules in a single binary")
2 3
set(OPENCV_MODULE_IS_PART_OF_WORLD FALSE)
set(BUILD_opencv_world_INIT OFF)
4

5 6 7 8 9
if(IOS OR NOT BUILD_SHARED_LIBS)
  set(OPENCV_MODULE_TYPE STATIC)
  set(OPENCV_WORLD_FLAGS_PROPERTY STATIC_LIBRARY_FLAGS)
else()
  set(OPENCV_WORLD_FLAGS_PROPERTY LINK_FLAGS)
10
endif()
11

A
Alexander Alekhin 已提交
12 13 14 15 16 17 18 19 20 21 22
if(NOT OPENCV_INITIAL_PASS)
  project(opencv_world)

  message(STATUS "Processing WORLD modules...")
  foreach(m ${OPENCV_MODULES_BUILD})
    if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD)
      message(STATUS "    module ${m}...")
      set(CMAKE_CURRENT_SOURCE_DIR ${OPENCV_MODULE_${m}_LOCATION})
      #add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" ${CMAKE_CURRENT_BINARY_DIR}/${m})
      include("${OPENCV_MODULE_${m}_LOCATION}/CMakeLists.txt")
    endif()
23
  endforeach()
A
Alexander Alekhin 已提交
24 25
  message(STATUS "Processing WORLD modules... DONE")
  set(CMAKE_CURRENT_SOURCE_DIR OPENCV_MODULE_${opencv_world}_LOCATION)
26 27
endif()

A
Alexander Alekhin 已提交
28
ocv_add_module(world opencv_core)
29

A
Alexander Alekhin 已提交
30 31 32
set(headers_list "HEADERS")
set(sources_list "SOURCES")
set(link_deps "")
33
foreach(m ${OPENCV_MODULE_${the_module}_DEPS})
A
Alexander Alekhin 已提交
34 35 36
  set(headers_list "${headers_list};${OPENCV_MODULE_${m}_HEADERS}")
  set(sources_list "${sources_list};${OPENCV_MODULE_${m}_SOURCES}")
  set(link_deps "${link_deps};${OPENCV_MODULE_${m}_LINK_DEPS}")
37 38
endforeach()

A
Alexander Alekhin 已提交
39
ocv_glob_module_sources(${headers_list} ${sources_list})
A
Anatoly Baksheev 已提交
40

A
Alexander Alekhin 已提交
41
ocv_module_include_directories()
A
Anatoly Baksheev 已提交
42

A
Alexander Alekhin 已提交
43 44 45
#message(STATUS "${OPENCV_MODULE_${the_module}_HEADERS}")
#message(STATUS "${OPENCV_MODULE_${the_module}_SOURCES}")
ocv_create_module(${link_deps})
46

A
Alexander Alekhin 已提交
47 48
if(BUILD_opencv_imgcodecs)
  ocv_imgcodecs_configure_target()
49
endif()
A
Alexander Alekhin 已提交
50 51
if(BUILD_opencv_videoio)
  ocv_videoio_configure_target()
52
endif()
A
Alexander Alekhin 已提交
53 54
if(BUILD_opencv_highgui)
  ocv_highgui_configure_target()
55
endif()
A
Alexander Alekhin 已提交
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78

if(IOS OR APPLE)
  set(merge_libs "")
  macro(ios_include_3party_libs)
    foreach(l ${ARGN})
      add_dependencies(${the_module} ${l})
      list(APPEND merge_libs "$<TARGET_LINKER_FILE:${l}>")
    endforeach()
  endmacro()

  if(WITH_PNG)
    ios_include_3party_libs(zlib libpng)
  endif()

  if(WITH_JPEG)
    ios_include_3party_libs(libjpeg)
  endif()

  add_custom_command(TARGET ${the_module} POST_BUILD
    COMMAND /usr/bin/libtool -static -o ${CMAKE_CURRENT_BINARY_DIR}/${the_module}_fat.a $<TARGET_LINKER_FILE:${the_module}> ${merge_libs}
    COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/${the_module}_fat.a $<TARGET_LINKER_FILE:${the_module}>
  )
endif()