1
# ----------------------------------------------------------------------------
2
# CMake file for C samples. See root CMakeLists.txt
4
# ----------------------------------------------------------------------------
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})
11
ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
14
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
17
ocv_include_directories("${OpenCV_SOURCE_DIR}/include")#for opencv.hpp
18
ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
20
if(HAVE_opencv_cudaoptflow)
21
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaoptflow/include")
23
if(HAVE_opencv_cudaimgproc)
24
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaimgproc/include")
26
if(HAVE_opencv_cudaarithm)
27
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaarithm/include")
29
if(HAVE_opencv_cudafilters)
30
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudafilters/include")
33
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
34
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
37
# ---------------------------------------------
38
# Define executable targets
39
# ---------------------------------------------
40
MACRO(OPENCV_DEFINE_CPP_EXAMPLE name srcs)
42
if("${srcs}" MATCHES "tutorial_code")
43
set(sample_kind tutorial)
44
set(sample_KIND TUTORIAL)
45
set(sample_subfolder "tutorials")
47
set(sample_kind example)
48
set(sample_KIND EXAMPLE)
49
set(sample_subfolder "cpp")
52
set(the_target "${sample_kind}_${name}")
53
add_executable(${the_target} ${srcs})
54
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
56
if("${srcs}" MATCHES "gpu/")
57
ocv_target_link_libraries(${the_target} opencv_cudaarithm opencv_cudafilters)
61
ocv_target_link_libraries(${the_target} opencv_ocl)
64
set_target_properties(${the_target} PROPERTIES
65
OUTPUT_NAME "cpp-${sample_kind}-${name}"
66
PROJECT_LABEL "(${sample_KIND}) ${name}")
68
if(ENABLE_SOLUTION_FOLDERS)
69
set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sample_subfolder}")
73
if (MSVC AND NOT BUILD_SHARED_LIBS)
74
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
76
install(TARGETS ${the_target}
77
RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${sample_subfolder}" COMPONENT samples)
81
file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
84
ocv_list_filterout(cpp_samples Qt_sample)
87
if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters)
88
ocv_list_filterout(cpp_samples "/gpu/")
91
ocv_list_filterout(cpp_samples "viz")
94
ocv_list_filterout(cpp_samples "/ippasync/")
97
foreach(sample_filename ${cpp_samples})
98
if(NOT "${sample_filename}" MATCHES "real_time_pose_estimation/")
99
get_filename_component(sample ${sample_filename} NAME_WE)
100
OPENCV_DEFINE_CPP_EXAMPLE(${sample} ${sample_filename})
104
include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt")
107
if(INSTALL_C_EXAMPLES AND NOT WIN32)
108
file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
109
install(FILES ${C_SAMPLES}
110
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/cpp
111
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)