1 SET(OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui) 2 3 ocv_check_dependencies(${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS}) 4 5 if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) 6 set(project "directx") 7 string(TOUPPER "${project}" project_upper) 8 9 project("${project}_samples") 10 11 ocv_include_modules_recurse(${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS}) 12 13 # --------------------------------------------- 14 # Define executable targets 15 # --------------------------------------------- 16 MACRO(OPENCV_DEFINE_DIRECTX_EXAMPLE name srcs) 17 set(the_target "example_${project}_${name}") 18 add_executable(${the_target} ${srcs}) 19 20 ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS}) 21 22 set_target_properties(${the_target} PROPERTIES 23 OUTPUT_NAME "${project}-example-${name}" 24 PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}") 25 26 if(ENABLE_SOLUTION_FOLDERS) 27 set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}") 28 endif() 29 30 if(WIN32) 31 if(MSVC AND NOT BUILD_SHARED_LIBS) 32 set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG") 33 endif() 34 install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT samples) 35 endif() 36 ENDMACRO() 37 38 file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) 39 40 foreach(sample_filename ${all_samples}) 41 get_filename_component(sample ${sample_filename} NAME_WE) 42 file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*) 43 OPENCV_DEFINE_DIRECTX_EXAMPLE(${sample} ${sample_srcs}) 44 endforeach() 45 endif() 46