|
1 |
| -# ---------------------------------------------------------------------------- |
2 |
| -# CMake file for C samples. See root CMakeLists.txt |
3 |
| -# |
4 |
| -# ---------------------------------------------------------------------------- |
5 |
| - |
6 |
| -SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_flann |
7 |
| - opencv_imgcodecs opencv_videoio opencv_highgui opencv_ml opencv_video |
8 |
| - opencv_objdetect opencv_photo opencv_features2d opencv_calib3d |
9 |
| - opencv_stitching opencv_videostab opencv_shape ${OPENCV_MODULES_PUBLIC} ${OpenCV_LIB_COMPONENTS}) |
10 |
| - |
| 1 | +ocv_install_example_src(cpp *.cpp *.hpp CMakeLists.txt) |
| 2 | + |
| 3 | +set(OPENCV_CPP_SAMPLES_REQUIRED_DEPS |
| 4 | + opencv_core |
| 5 | + opencv_imgproc |
| 6 | + opencv_flann |
| 7 | + opencv_imgcodecs |
| 8 | + opencv_videoio |
| 9 | + opencv_highgui |
| 10 | + opencv_ml |
| 11 | + opencv_video |
| 12 | + opencv_objdetect |
| 13 | + opencv_photo |
| 14 | + opencv_features2d |
| 15 | + opencv_calib3d |
| 16 | + opencv_stitching |
| 17 | + opencv_videostab |
| 18 | + opencv_shape |
| 19 | + ${OPENCV_MODULES_PUBLIC} |
| 20 | + ${OpenCV_LIB_COMPONENTS}) |
11 | 21 | ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
12 | 22 |
|
| 23 | +if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND) |
| 24 | + return() |
| 25 | +endif() |
13 | 26 |
|
14 |
| -if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) |
15 |
| - project(cpp_samples) |
16 |
| - |
17 |
| - ocv_include_directories("${OpenCV_SOURCE_DIR}/include")#for opencv.hpp |
18 |
| - ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) |
19 |
| - |
20 |
| - if(HAVE_opencv_cudaoptflow) |
21 |
| - ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaoptflow/include") |
| 27 | +project(cpp_samples) |
| 28 | +ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) |
| 29 | +file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) |
| 30 | +if(NOT HAVE_OPENGL) |
| 31 | + ocv_list_filterout(cpp_samples Qt_sample) |
| 32 | +endif() |
| 33 | +if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters) |
| 34 | + ocv_list_filterout(cpp_samples "/gpu/") |
| 35 | +endif() |
| 36 | +if(NOT TARGET opencv_viz) |
| 37 | + ocv_list_filterout(cpp_samples "/viz/") |
| 38 | +endif() |
| 39 | +if(NOT HAVE_IPP_A) |
| 40 | + ocv_list_filterout(cpp_samples "/ippasync/") |
| 41 | +endif() |
| 42 | +ocv_list_filterout(cpp_samples "real_time_pose_estimation/") |
| 43 | +foreach(sample_filename ${cpp_samples}) |
| 44 | + if(sample_filename MATCHES "viz/" AND VTK_USE_FILE) |
| 45 | + include(${VTK_USE_FILE}) |
22 | 46 | endif()
|
23 |
| - if(HAVE_opencv_cudaimgproc) |
24 |
| - ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaimgproc/include") |
| 47 | + set(package "cpp") |
| 48 | + if(sample_filename MATCHES "tutorial_code") |
| 49 | + set(package "tutorial") |
25 | 50 | endif()
|
26 |
| - if(HAVE_opencv_cudaarithm) |
27 |
| - ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaarithm/include") |
| 51 | + ocv_define_sample(tgt ${sample_filename} ${package}) |
| 52 | + ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) |
| 53 | + if(sample_filename MATCHES "gpu/" AND HAVE_opencv_cudaarithm AND HAVE_opencv_cuda_filters) |
| 54 | + ocv_target_link_libraries(${tgt} opencv_cudaarithm opencv_cudafilters) |
28 | 55 | endif()
|
29 |
| - if(HAVE_opencv_cudafilters) |
30 |
| - ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudafilters/include") |
| 56 | + if(sample_filename MATCHES "viz/" AND VTK_USE_FILE) |
| 57 | + ocv_target_link_libraries(${tgt} ${VTK_LIBRARIES}) |
| 58 | + target_compile_definitions(${tgt} PRIVATE -DUSE_VTK) |
31 | 59 | endif()
|
32 |
| - |
33 |
| - if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS) |
34 |
| - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-missing-declarations") |
35 |
| - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function -Wno-missing-declarations") |
| 60 | + if(HAVE_OPENGL AND sample_filename MATCHES "detect_mser") |
| 61 | + target_compile_definitions(${tgt} PRIVATE HAVE_OPENGL) |
36 | 62 | endif()
|
| 63 | +endforeach() |
37 | 64 |
|
38 |
| - # --------------------------------------------- |
39 |
| - # Define executable targets |
40 |
| - # --------------------------------------------- |
41 |
| - MACRO(OPENCV_DEFINE_CPP_EXAMPLE name srcs) |
42 |
| - |
43 |
| - if("${srcs}" MATCHES "tutorial_code") |
44 |
| - set(sample_kind tutorial) |
45 |
| - set(sample_KIND TUTORIAL) |
46 |
| - set(sample_subfolder "tutorials") |
47 |
| - else() |
48 |
| - set(sample_kind example) |
49 |
| - set(sample_KIND EXAMPLE) |
50 |
| - set(sample_subfolder "cpp") |
51 |
| - endif() |
52 |
| - |
53 |
| - set(the_target "${sample_kind}_${name}") |
54 |
| - add_executable(${the_target} ${srcs}) |
55 |
| - ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) |
56 |
| - |
57 |
| - if("${srcs}" MATCHES "gpu/") |
58 |
| - ocv_target_link_libraries(${the_target} opencv_cudaarithm opencv_cudafilters) |
59 |
| - endif() |
60 |
| - |
61 |
| - if("${srcs}" MATCHES "viz/" AND VTK_USE_FILE) |
62 |
| - include(${VTK_USE_FILE}) |
63 |
| - ocv_target_link_libraries(${the_target} ${VTK_LIBRARIES}) |
64 |
| - add_definitions(-DUSE_VTK) |
65 |
| - endif() |
66 |
| - |
67 |
| - set_target_properties(${the_target} PROPERTIES |
68 |
| - OUTPUT_NAME "cpp-${sample_kind}-${name}" |
69 |
| - PROJECT_LABEL "(${sample_KIND}) ${name}") |
70 |
| - |
71 |
| - if(ENABLE_SOLUTION_FOLDERS) |
72 |
| - set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sample_subfolder}") |
73 |
| - endif() |
74 |
| - |
75 |
| - if(WIN32) |
76 |
| - if (MSVC AND NOT BUILD_SHARED_LIBS) |
77 |
| - set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG") |
78 |
| - endif() |
79 |
| - install(TARGETS ${the_target} |
80 |
| - RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${sample_subfolder}" COMPONENT samples) |
81 |
| - endif() |
82 |
| - ENDMACRO() |
83 |
| - |
84 |
| - file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) |
85 |
| - |
86 |
| - if(NOT HAVE_OPENGL) |
87 |
| - ocv_list_filterout(cpp_samples Qt_sample) |
88 |
| - endif() |
89 |
| - |
90 |
| - if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters) |
91 |
| - ocv_list_filterout(cpp_samples "/gpu/") |
92 |
| - endif() |
93 |
| - |
94 |
| - if(NOT TARGET opencv_viz) |
95 |
| - ocv_list_filterout(cpp_samples "/viz/") |
96 |
| - endif() |
97 |
| - |
98 |
| - if(NOT HAVE_IPP_A) |
99 |
| - ocv_list_filterout(cpp_samples "/ippasync/") |
100 |
| - endif() |
101 |
| - |
102 |
| - foreach(sample_filename ${cpp_samples}) |
103 |
| - if(NOT "${sample_filename}" MATCHES "real_time_pose_estimation/") |
104 |
| - get_filename_component(sample ${sample_filename} NAME_WE) |
105 |
| - OPENCV_DEFINE_CPP_EXAMPLE(${sample} ${sample_filename}) |
106 |
| - endif() |
107 |
| - endforeach() |
108 |
| - |
109 |
| - include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt") |
110 |
| -endif() |
111 |
| - |
112 |
| -if(INSTALL_C_EXAMPLES AND NOT WIN32) |
113 |
| - file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd ) |
114 |
| - install(FILES ${C_SAMPLES} |
115 |
| - DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/cpp |
116 |
| - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples) |
117 |
| -endif() |
| 65 | +include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt" OPTIONAL) |
0 commit comments