Home | History | Annotate | Download | only in gpu
      1 SET(OPENCV_CUDA_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui
      2                                      opencv_ml opencv_video opencv_objdetect opencv_features2d
      3                                      opencv_calib3d opencv_superres
      4                                      opencv_cudaarithm opencv_cudafilters opencv_cudawarping opencv_cudaimgproc
      5                                      opencv_cudafeatures2d opencv_cudaoptflow opencv_cudabgsegm
      6                                      opencv_cudastereo opencv_cudalegacy opencv_cudaobjdetect)
      7 
      8 ocv_check_dependencies(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
      9 
     10 if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
     11   set(project "gpu")
     12   string(TOUPPER "${project}" project_upper)
     13 
     14   project("${project}_samples")
     15 
     16   ocv_include_modules_recurse(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
     17   ocv_include_directories(
     18     "${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia"
     19     "${OpenCV_SOURCE_DIR}/modules/gpu/src/nvidia/core"
     20     )
     21 
     22   if(HAVE_opencv_xfeatures2d)
     23     ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/xfeatures2d/include")
     24   endif()
     25 
     26   if(HAVE_opencv_cudacodec)
     27     ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudacodec/include")
     28   endif()
     29 
     30   if(HAVE_CUDA)
     31     ocv_include_directories(${CUDA_INCLUDE_DIRS})
     32   endif()
     33 
     34   if(HAVE_OPENCL)
     35     ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/ocl/include")
     36   endif()
     37 
     38   if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
     39     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
     40   endif()
     41 
     42   # ---------------------------------------------
     43   #      Define executable targets
     44   # ---------------------------------------------
     45   MACRO(OPENCV_DEFINE_CUDA_EXAMPLE name srcs)
     46     set(the_target "example_${project}_${name}")
     47     add_executable(${the_target} ${srcs})
     48 
     49     ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
     50 
     51     if(HAVE_CUDA AND NOT ANDROID)
     52       ocv_target_link_libraries(${the_target} ${CUDA_CUDA_LIBRARY})
     53     endif()
     54 
     55     if(HAVE_opencv_xfeatures2d)
     56       ocv_target_link_libraries(${the_target} opencv_xfeatures2d)
     57     endif()
     58     if(HAVE_opencv_cudacodec)
     59       ocv_target_link_libraries(${the_target} opencv_cudacodec)
     60     endif()
     61 
     62     if(HAVE_opencv_ocl)
     63       ocv_target_link_libraries(${the_target} opencv_ocl)
     64     endif()
     65 
     66     set_target_properties(${the_target} PROPERTIES
     67       OUTPUT_NAME "${project}-example-${name}"
     68       PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
     69 
     70     if(ENABLE_SOLUTION_FOLDERS)
     71       set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
     72     endif()
     73 
     74     if(WIN32)
     75       if(MSVC AND NOT BUILD_SHARED_LIBS)
     76         set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
     77       endif()
     78       install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT samples)
     79     endif()
     80   ENDMACRO()
     81 
     82   file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
     83 
     84   foreach(sample_filename ${all_samples})
     85     get_filename_component(sample ${sample_filename} NAME_WE)
     86     file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
     87     OPENCV_DEFINE_CUDA_EXAMPLE(${sample} ${sample_srcs})
     88   endforeach()
     89 
     90   include("performance/CMakeLists.txt")
     91 endif()
     92 
     93 if(INSTALL_C_EXAMPLES AND NOT WIN32)
     94   file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
     95   install(FILES ${install_list}
     96           DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu
     97           PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
     98 endif()
     99