1 # ----------------------------------------------------------------------------
\r
2 # CMake file for C samples. See root CMakeLists.txt
\r
4 # ----------------------------------------------------------------------------
\r
6 SET(OPENCV_C_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc
\r
7 opencv_highgui opencv_ml opencv_video opencv_objdetect opencv_photo opencv_nonfree
\r
8 opencv_features2d opencv_calib3d opencv_legacy opencv_contrib)
\r
10 ocv_check_dependencies(${OPENCV_C_SAMPLES_REQUIRED_DEPS})
\r
12 if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
\r
15 if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
\r
16 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
\r
19 ocv_include_modules(${OPENCV_C_SAMPLES_REQUIRED_DEPS})
\r
21 # ---------------------------------------------
\r
22 # Define executable targets
\r
23 # ---------------------------------------------
\r
24 MACRO(OPENCV_DEFINE_C_EXAMPLE name srcs)
\r
25 set(the_target "example_${name}")
\r
26 add_executable(${the_target} ${srcs})
\r
27 target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_C_SAMPLES_REQUIRED_DEPS})
\r
29 set_target_properties(${the_target} PROPERTIES
\r
30 OUTPUT_NAME "${name}"
\r
31 PROJECT_LABEL "(EXAMPLE) ${name}")
\r
33 if(ENABLE_SOLUTION_FOLDERS)
\r
34 set_target_properties(${the_target} PROPERTIES FOLDER "samples//c")
\r
38 if(MSVC AND NOT BUILD_SHARED_LIBS)
\r
39 set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
\r
41 install(TARGETS ${the_target}
\r
42 RUNTIME DESTINATION "samples/c" COMPONENT main)
\r
46 file(GLOB cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp *.c)
\r
48 foreach(sample_filename ${cpp_samples})
\r
49 get_filename_component(sample ${sample_filename} NAME_WE)
\r
50 OPENCV_DEFINE_C_EXAMPLE(${sample} ${sample_filename})
\r
54 if (INSTALL_C_EXAMPLES AND NOT WIN32)
\r
55 file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
\r
56 install(FILES ${C_SAMPLES}
\r
57 DESTINATION share/OpenCV/samples/c
\r
58 PERMISSIONS OWNER_READ GROUP_READ WORLD_READ)
\r