mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
cmake: refactored scripts with samples building:
- allow installing samples sources on all platforms even if BUILD_EXAMPLES is disabled, fixed minor issues in sources installation process - use 'example_<group>_<name>' scheme for target and binary file naming - use single function for sample executable creation
This commit is contained in:
parent
633b0e56a5
commit
2200e13c71
@ -420,7 +420,7 @@ else()
|
||||
ocv_update(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}lib${LIB_SUFFIX}")
|
||||
endif()
|
||||
ocv_update(OPENCV_3P_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
|
||||
ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH samples/native)
|
||||
ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH samples)
|
||||
ocv_update(OPENCV_JAR_INSTALL_PATH java)
|
||||
ocv_update(OPENCV_OTHER_INSTALL_PATH etc)
|
||||
ocv_update(OPENCV_CONFIG_INSTALL_PATH ".")
|
||||
@ -804,7 +804,7 @@ if(BUILD_opencv_apps)
|
||||
endif()
|
||||
|
||||
# examples
|
||||
if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES)
|
||||
if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES OR INSTALL_C_EXAMPLES)
|
||||
add_subdirectory(samples)
|
||||
endif()
|
||||
|
||||
|
@ -1221,9 +1221,13 @@ function(ocv_add_samples)
|
||||
ocv_debug_message("ocv_add_samples(" ${ARGN} ")")
|
||||
|
||||
set(samples_path "${CMAKE_CURRENT_SOURCE_DIR}/samples")
|
||||
if(NOT EXISTS "${samples_path}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
string(REGEX REPLACE "^opencv_" "" module_id ${the_module})
|
||||
|
||||
if(BUILD_EXAMPLES AND EXISTS "${samples_path}")
|
||||
if(BUILD_EXAMPLES)
|
||||
set(samples_deps ${the_module} ${OPENCV_MODULE_${the_module}_DEPS} opencv_imgcodecs opencv_videoio opencv_highgui ${ARGN})
|
||||
ocv_check_dependencies(${samples_deps})
|
||||
|
||||
@ -1237,15 +1241,14 @@ function(ocv_add_samples)
|
||||
ocv_add_executable(${the_target} "${source}")
|
||||
ocv_target_include_modules(${the_target} ${samples_deps})
|
||||
ocv_target_link_libraries(${the_target} LINK_PRIVATE ${samples_deps})
|
||||
set_target_properties(${the_target} PROPERTIES PROJECT_LABEL "(sample) ${name}")
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Sample")
|
||||
set_source_files_properties("${source}"
|
||||
PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Sample")
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
PROJECT_LABEL "(sample) ${name}"
|
||||
LABELS "${OPENCV_MODULE_${the_module}_LABEL};Sample")
|
||||
set_source_files_properties("${source}" PROPERTIES
|
||||
LABELS "${OPENCV_MODULE_${the_module}_LABEL};Sample")
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
OUTPUT_NAME "${module_id}-example-${name}"
|
||||
FOLDER "samples/${module_id}")
|
||||
endif()
|
||||
|
||||
@ -1256,8 +1259,8 @@ function(ocv_add_samples)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(INSTALL_C_EXAMPLES AND NOT WIN32 AND EXISTS "${samples_path}")
|
||||
file(GLOB DEPLOY_FILES_AND_DIRS "${samples_path}/*")
|
||||
if(INSTALL_C_EXAMPLES)
|
||||
file(GLOB DEPLOY_FILES_AND_DIRS "${samples_path}/*")
|
||||
foreach(ITEM ${DEPLOY_FILES_AND_DIRS})
|
||||
IF( IS_DIRECTORY "${ITEM}" )
|
||||
LIST( APPEND sample_dirs "${ITEM}" )
|
||||
@ -1266,10 +1269,10 @@ function(ocv_add_samples)
|
||||
ENDIF()
|
||||
endforeach()
|
||||
install(FILES ${sample_files}
|
||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
||||
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}"
|
||||
COMPONENT samples)
|
||||
install(DIRECTORY ${sample_dirs}
|
||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}
|
||||
USE_SOURCE_PERMISSIONS COMPONENT samples)
|
||||
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}"
|
||||
COMPONENT samples)
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -1,58 +1,95 @@
|
||||
# Detect if we want to build samples with library binaries or not
|
||||
# Utility function: adds sample executable target with name "example_<group>_<file_name>"
|
||||
# Usage:
|
||||
# ocv_define_sample(<output target> <relative filename> <group>)
|
||||
function(ocv_define_sample out_target source sub)
|
||||
get_filename_component(name "${source}" NAME_WE)
|
||||
set(the_target "example_${sub}_${name}")
|
||||
add_executable(${the_target} "${source}")
|
||||
set_target_properties(${the_target} PROPERTIES PROJECT_LABEL "(sample) ${name}")
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sub}")
|
||||
endif()
|
||||
if(WIN32 AND MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
if(WIN32)
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${sub}" COMPONENT samples)
|
||||
endif()
|
||||
set(${out_target} ${the_target} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
|
||||
#===================================================================================================
|
||||
#
|
||||
# BUILD CASE 1: Build samples with library sources
|
||||
# Build as part of OpenCV
|
||||
#
|
||||
#===================================================================================================
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# CMake file for samples. See root CMakeLists.txt
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
function(ocv_install_example_src relpath)
|
||||
if(INSTALL_C_EXAMPLES)
|
||||
file(GLOB files ${ARGN})
|
||||
install(FILES ${files}
|
||||
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${relpath}"
|
||||
COMPONENT samples)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
add_subdirectory(cpp)
|
||||
add_subdirectory(java/tutorial_code)
|
||||
add_subdirectory(dnn)
|
||||
add_subdirectory(gpu)
|
||||
add_subdirectory(tapi)
|
||||
|
||||
add_subdirectory(opencl)
|
||||
if(WIN32 AND HAVE_DIRECTX)
|
||||
add_subdirectory(directx)
|
||||
endif()
|
||||
|
||||
if((NOT ANDROID) AND HAVE_OPENGL)
|
||||
add_subdirectory(opengl)
|
||||
endif()
|
||||
|
||||
if(HAVE_OPENVX)
|
||||
add_subdirectory(openvx)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT ANDROID AND (HAVE_VA OR HAVE_VA_INTEL))
|
||||
add_subdirectory(va_intel)
|
||||
endif()
|
||||
|
||||
if(ANDROID AND BUILD_ANDROID_EXAMPLES)
|
||||
add_subdirectory(android)
|
||||
endif()
|
||||
|
||||
if(INSTALL_PYTHON_EXAMPLES)
|
||||
add_subdirectory(python)
|
||||
endif()
|
||||
|
||||
#
|
||||
# END OF BUILD CASE 1: Build samples with library sources
|
||||
#
|
||||
ocv_install_example_src("." CMakeLists.txt)
|
||||
if(INSTALL_C_EXAMPLES)
|
||||
install(DIRECTORY data
|
||||
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/data"
|
||||
COMPONENT samples)
|
||||
endif()
|
||||
|
||||
else()
|
||||
#===================================================================================================
|
||||
#
|
||||
# BUILD CASE 2: Build samples with library binaries
|
||||
# Standalone mode
|
||||
#
|
||||
#===================================================================================================
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
project(samples C CXX)
|
||||
option(BUILD_EXAMPLES "Build samples" ON)
|
||||
|
||||
find_package(OpenCV REQUIRED)
|
||||
# Assuming following installation folder structure (default for UNIX):
|
||||
# <install_root>/share/
|
||||
# └── OpenCV/ <-- OPENCV_CONFIG_INSTALL_PATH
|
||||
# ├── OpenCVConfig.cmake <-- file to be found by find_package
|
||||
# ├── ...
|
||||
# ├── samples/ <-- OPENCV_SAMPLES_SRC_INSTALL_PATH
|
||||
# │ ├── CMakeLists.txt <-- this file
|
||||
# │ ├── cpp/
|
||||
find_package(OpenCV REQUIRED PATHS "..")
|
||||
|
||||
function(ocv_install_example_src)
|
||||
# not used in this branch
|
||||
endfunction()
|
||||
|
||||
if(MSVC)
|
||||
if(NOT ENABLE_BUILD_HARDENING)
|
||||
@ -80,16 +117,15 @@ if(MSVC)
|
||||
endif()
|
||||
|
||||
add_subdirectory(cpp)
|
||||
add_subdirectory(dnn)
|
||||
# FIXIT: can't use cvconfig.h in samples: add_subdirectory(gpu)
|
||||
|
||||
add_subdirectory(opencl)
|
||||
|
||||
if(WIN32)
|
||||
add_subdirectory(directx)
|
||||
endif()
|
||||
add_subdirectory(dnn)
|
||||
# add_subdirectory(gpu)
|
||||
add_subdirectory(opencl)
|
||||
# add_subdirectory(opengl)
|
||||
# add_subdirectory(openvx)
|
||||
add_subdirectory(tapi)
|
||||
# add_subdirectory(va_intel)
|
||||
|
||||
#
|
||||
# END OF BUILD CASE 2: Build samples with library binaries
|
||||
#
|
||||
endif()
|
||||
|
@ -1,117 +1,65 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# CMake file for C samples. See root CMakeLists.txt
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_flann
|
||||
opencv_imgcodecs opencv_videoio opencv_highgui opencv_ml opencv_video
|
||||
opencv_objdetect opencv_photo opencv_features2d opencv_calib3d
|
||||
opencv_stitching opencv_videostab opencv_shape ${OPENCV_MODULES_PUBLIC} ${OpenCV_LIB_COMPONENTS})
|
||||
ocv_install_example_src(cpp *.cpp *.hpp CMakeLists.txt)
|
||||
|
||||
set(OPENCV_CPP_SAMPLES_REQUIRED_DEPS
|
||||
opencv_core
|
||||
opencv_imgproc
|
||||
opencv_flann
|
||||
opencv_imgcodecs
|
||||
opencv_videoio
|
||||
opencv_highgui
|
||||
opencv_ml
|
||||
opencv_video
|
||||
opencv_objdetect
|
||||
opencv_photo
|
||||
opencv_features2d
|
||||
opencv_calib3d
|
||||
opencv_stitching
|
||||
opencv_videostab
|
||||
opencv_shape
|
||||
${OPENCV_MODULES_PUBLIC}
|
||||
${OpenCV_LIB_COMPONENTS})
|
||||
ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
|
||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
project(cpp_samples)
|
||||
|
||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/include")#for opencv.hpp
|
||||
ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
if(HAVE_opencv_cudaoptflow)
|
||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaoptflow/include")
|
||||
endif()
|
||||
if(HAVE_opencv_cudaimgproc)
|
||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaimgproc/include")
|
||||
endif()
|
||||
if(HAVE_opencv_cudaarithm)
|
||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaarithm/include")
|
||||
endif()
|
||||
if(HAVE_opencv_cudafilters)
|
||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudafilters/include")
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-missing-declarations")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function -Wno-missing-declarations")
|
||||
endif()
|
||||
|
||||
# ---------------------------------------------
|
||||
# Define executable targets
|
||||
# ---------------------------------------------
|
||||
MACRO(OPENCV_DEFINE_CPP_EXAMPLE name srcs)
|
||||
|
||||
if("${srcs}" MATCHES "tutorial_code")
|
||||
set(sample_kind tutorial)
|
||||
set(sample_KIND TUTORIAL)
|
||||
set(sample_subfolder "tutorials")
|
||||
else()
|
||||
set(sample_kind example)
|
||||
set(sample_KIND EXAMPLE)
|
||||
set(sample_subfolder "cpp")
|
||||
endif()
|
||||
|
||||
set(the_target "${sample_kind}_${name}")
|
||||
add_executable(${the_target} ${srcs})
|
||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
if("${srcs}" MATCHES "gpu/")
|
||||
ocv_target_link_libraries(${the_target} opencv_cudaarithm opencv_cudafilters)
|
||||
endif()
|
||||
|
||||
if("${srcs}" MATCHES "viz/" AND VTK_USE_FILE)
|
||||
include(${VTK_USE_FILE})
|
||||
ocv_target_link_libraries(${the_target} ${VTK_LIBRARIES})
|
||||
add_definitions(-DUSE_VTK)
|
||||
endif()
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
OUTPUT_NAME "cpp-${sample_kind}-${name}"
|
||||
PROJECT_LABEL "(${sample_KIND}) ${name}")
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sample_subfolder}")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if (MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
install(TARGETS ${the_target}
|
||||
RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${sample_subfolder}" COMPONENT samples)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
|
||||
if(NOT HAVE_OPENGL)
|
||||
ocv_list_filterout(cpp_samples Qt_sample)
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters)
|
||||
ocv_list_filterout(cpp_samples "/gpu/")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET opencv_viz)
|
||||
ocv_list_filterout(cpp_samples "/viz/")
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_IPP_A)
|
||||
ocv_list_filterout(cpp_samples "/ippasync/")
|
||||
endif()
|
||||
|
||||
foreach(sample_filename ${cpp_samples})
|
||||
if(NOT "${sample_filename}" MATCHES "real_time_pose_estimation/")
|
||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
||||
OPENCV_DEFINE_CPP_EXAMPLE(${sample} ${sample_filename})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt")
|
||||
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(INSTALL_C_EXAMPLES AND NOT WIN32)
|
||||
file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
|
||||
install(FILES ${C_SAMPLES}
|
||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/cpp
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
||||
project(cpp_samples)
|
||||
ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||
file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
if(NOT HAVE_OPENGL)
|
||||
ocv_list_filterout(cpp_samples Qt_sample)
|
||||
endif()
|
||||
if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters)
|
||||
ocv_list_filterout(cpp_samples "/gpu/")
|
||||
endif()
|
||||
if(NOT TARGET opencv_viz)
|
||||
ocv_list_filterout(cpp_samples "/viz/")
|
||||
endif()
|
||||
if(NOT HAVE_IPP_A)
|
||||
ocv_list_filterout(cpp_samples "/ippasync/")
|
||||
endif()
|
||||
ocv_list_filterout(cpp_samples "real_time_pose_estimation/")
|
||||
foreach(sample_filename ${cpp_samples})
|
||||
if(sample_filename MATCHES "viz/" AND VTK_USE_FILE)
|
||||
include(${VTK_USE_FILE})
|
||||
endif()
|
||||
set(package "cpp")
|
||||
if(sample_filename MATCHES "tutorial_code")
|
||||
set(package "tutorial")
|
||||
endif()
|
||||
ocv_define_sample(tgt ${sample_filename} ${package})
|
||||
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||
if(sample_filename MATCHES "gpu/" AND HAVE_opencv_cudaarithm AND HAVE_opencv_cuda_filters)
|
||||
ocv_target_link_libraries(${tgt} opencv_cudaarithm opencv_cudafilters)
|
||||
endif()
|
||||
if(sample_filename MATCHES "viz/" AND VTK_USE_FILE)
|
||||
ocv_target_link_libraries(${tgt} ${VTK_LIBRARIES})
|
||||
target_compile_definitions(${tgt} PRIVATE -DUSE_VTK)
|
||||
endif()
|
||||
if(HAVE_OPENGL AND sample_filename MATCHES "detect_mser")
|
||||
target_compile_definitions(${tgt} PRIVATE HAVE_OPENGL)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt" OPTIONAL)
|
||||
|
@ -1,5 +1,5 @@
|
||||
set(sample_dir ${CMAKE_CURRENT_SOURCE_DIR}/tutorial_code/calib3d/real_time_pose_estimation/src/)
|
||||
set(target cpp-tutorial-)
|
||||
set(target example_tutorial_)
|
||||
|
||||
set(sample_pnplib
|
||||
${sample_dir}CsvReader.cpp
|
||||
@ -12,6 +12,8 @@ set(sample_pnplib
|
||||
${sample_dir}RobustMatcher.cpp
|
||||
)
|
||||
|
||||
ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
add_executable( ${target}pnp_registration ${sample_dir}main_registration.cpp ${sample_pnplib} )
|
||||
add_executable( ${target}pnp_detection ${sample_dir}main_detection.cpp ${sample_pnplib} )
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
@ -1,45 +1,21 @@
|
||||
SET(OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui)
|
||||
ocv_install_example_src(directx *.cpp *.hpp CMakeLists.txt)
|
||||
|
||||
set(OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS
|
||||
opencv_core
|
||||
opencv_imgproc
|
||||
opencv_imgcodecs
|
||||
opencv_videoio
|
||||
opencv_highgui)
|
||||
ocv_check_dependencies(${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
set(project "directx")
|
||||
string(TOUPPER "${project}" project_upper)
|
||||
|
||||
project("${project}_samples")
|
||||
|
||||
ocv_include_modules_recurse(${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
# ---------------------------------------------
|
||||
# Define executable targets
|
||||
# ---------------------------------------------
|
||||
MACRO(OPENCV_DEFINE_DIRECTX_EXAMPLE name srcs)
|
||||
set(the_target "example_${project}_${name}")
|
||||
add_executable(${the_target} ${srcs})
|
||||
|
||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
OUTPUT_NAME "${project}-example-${name}"
|
||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT samples)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
|
||||
foreach(sample_filename ${all_samples})
|
||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
||||
OPENCV_DEFINE_DIRECTX_EXAMPLE(${sample} ${sample_srcs})
|
||||
endforeach()
|
||||
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
project("directx_samples")
|
||||
ocv_include_modules_recurse(${tgt} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
foreach(sample_filename ${all_samples})
|
||||
ocv_define_sample(tgt ${sample_filename} directx)
|
||||
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
||||
endforeach()
|
||||
|
@ -1,76 +1,39 @@
|
||||
SET(OPENCV_DNN_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_dnn
|
||||
opencv_imgcodecs opencv_videoio opencv_highgui
|
||||
${OpenCV_LIB_COMPONENTS})
|
||||
ocv_install_example_src(dnn *.cpp *.hpp CMakeLists.txt)
|
||||
|
||||
set(OPENCV_DNN_SAMPLES_REQUIRED_DEPS
|
||||
opencv_core
|
||||
opencv_imgproc
|
||||
opencv_dnn
|
||||
opencv_imgcodecs
|
||||
opencv_videoio
|
||||
opencv_highgui)
|
||||
ocv_check_dependencies(${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
|
||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
project(dnn_samples)
|
||||
|
||||
# Model branch name: dnn_samples_face_detector_20170830
|
||||
set(DNN_FACE_DETECTOR_MODEL_COMMIT "b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f")
|
||||
set(DNN_FACE_DETECTOR_MODEL_HASH "afbb6037fd180e8d2acb3b58ca737b9e")
|
||||
|
||||
set(DNN_FACE_DETECTOR_MODEL_NAME "res10_300x300_ssd_iter_140000.caffemodel")
|
||||
|
||||
set(DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR "${CMAKE_CURRENT_LIST_DIR}/face_detector")
|
||||
|
||||
if(COMMAND ocv_download)
|
||||
ocv_download(FILENAME ${DNN_FACE_DETECTOR_MODEL_NAME}
|
||||
HASH ${DNN_FACE_DETECTOR_MODEL_HASH}
|
||||
URL
|
||||
"$ENV{OPENCV_DNN_MODELS_URL}"
|
||||
"${OPENCV_DNN_MODELS_URL}"
|
||||
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${DNN_FACE_DETECTOR_MODEL_COMMIT}/"
|
||||
DESTINATION_DIR ${DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR}
|
||||
ID DNN_FACE_DETECTOR
|
||||
RELATIVE_URL
|
||||
STATUS res)
|
||||
endif()
|
||||
|
||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/include")
|
||||
ocv_include_modules_recurse(${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
# ---------------------------------------------
|
||||
# Define executable targets
|
||||
# ---------------------------------------------
|
||||
MACRO(OPENCV_DEFINE_DNN_EXAMPLE name srcs)
|
||||
set(sample_kind example_dnn)
|
||||
set(sample_subfolder "dnn")
|
||||
|
||||
set(the_target "${sample_kind}_${name}")
|
||||
add_executable(${the_target} ${srcs})
|
||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
OUTPUT_NAME "${sample_kind}-${name}"
|
||||
PROJECT_LABEL "(${sample_KIND}) ${name}")
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sample_subfolder}")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if (MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
install(TARGETS ${the_target}
|
||||
RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${sample_subfolder}" COMPONENT samples)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
file(GLOB_RECURSE dnn_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
|
||||
foreach(sample_filename ${dnn_samples})
|
||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
||||
OPENCV_DEFINE_DNN_EXAMPLE(${sample} ${sample_filename})
|
||||
endforeach()
|
||||
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(INSTALL_C_EXAMPLES AND NOT WIN32)
|
||||
file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
|
||||
install(FILES ${C_SAMPLES}
|
||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/dnn
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
||||
# Model branch name: dnn_samples_face_detector_20170830
|
||||
set(DNN_FACE_DETECTOR_MODEL_COMMIT "b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f")
|
||||
set(DNN_FACE_DETECTOR_MODEL_HASH "afbb6037fd180e8d2acb3b58ca737b9e")
|
||||
set(DNN_FACE_DETECTOR_MODEL_NAME "res10_300x300_ssd_iter_140000.caffemodel")
|
||||
set(DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR "${CMAKE_CURRENT_LIST_DIR}/face_detector")
|
||||
if(COMMAND ocv_download)
|
||||
ocv_download(FILENAME ${DNN_FACE_DETECTOR_MODEL_NAME}
|
||||
HASH ${DNN_FACE_DETECTOR_MODEL_HASH}
|
||||
URL
|
||||
"$ENV{OPENCV_DNN_MODELS_URL}"
|
||||
"${OPENCV_DNN_MODELS_URL}"
|
||||
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${DNN_FACE_DETECTOR_MODEL_COMMIT}/"
|
||||
DESTINATION_DIR ${DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR}
|
||||
ID DNN_FACE_DETECTOR
|
||||
RELATIVE_URL
|
||||
STATUS res)
|
||||
endif()
|
||||
project(dnn_samples)
|
||||
ocv_include_modules_recurse(${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
||||
file(GLOB_RECURSE dnn_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
foreach(sample_filename ${dnn_samples})
|
||||
ocv_define_sample(tgt ${sample_filename} dnn)
|
||||
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
||||
endforeach()
|
||||
|
@ -1,97 +1,60 @@
|
||||
SET(OPENCV_CUDA_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui
|
||||
opencv_ml opencv_video opencv_objdetect opencv_features2d
|
||||
opencv_calib3d opencv_superres
|
||||
opencv_cudaarithm opencv_cudafilters opencv_cudawarping opencv_cudaimgproc
|
||||
opencv_cudafeatures2d opencv_cudaoptflow opencv_cudabgsegm
|
||||
opencv_cudastereo opencv_cudalegacy opencv_cudaobjdetect)
|
||||
ocv_install_example_src(gpu *.cpp *.hpp CMakeLists.txt)
|
||||
|
||||
set(OPENCV_CUDA_SAMPLES_REQUIRED_DEPS
|
||||
opencv_core
|
||||
opencv_flann
|
||||
opencv_imgproc
|
||||
opencv_imgcodecs
|
||||
opencv_videoio
|
||||
opencv_highgui
|
||||
opencv_ml
|
||||
opencv_video
|
||||
opencv_objdetect
|
||||
opencv_features2d
|
||||
opencv_calib3d
|
||||
opencv_superres
|
||||
opencv_cudaarithm
|
||||
opencv_cudafilters
|
||||
opencv_cudawarping
|
||||
opencv_cudaimgproc
|
||||
opencv_cudafeatures2d
|
||||
opencv_cudaoptflow
|
||||
opencv_cudabgsegm
|
||||
opencv_cudastereo
|
||||
opencv_cudalegacy
|
||||
opencv_cudaobjdetect)
|
||||
ocv_check_dependencies(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
set(project "gpu")
|
||||
string(TOUPPER "${project}" project_upper)
|
||||
|
||||
project("${project}_samples")
|
||||
|
||||
ocv_include_modules_recurse(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
||||
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
project(gpu_samples)
|
||||
ocv_include_modules_recurse(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
||||
if(HAVE_opencv_xfeatures2d)
|
||||
ocv_include_modules_recurse(opencv_xfeatures2d)
|
||||
endif()
|
||||
if(HAVE_opencv_cudacodec)
|
||||
ocv_include_modules_recurse(opencv_cudacodec)
|
||||
endif()
|
||||
if(HAVE_CUDA)
|
||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||
endif()
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
||||
endif()
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
if(NOT HAVE_OPENGL)
|
||||
ocv_list_filterout(all_samples "opengl")
|
||||
endif()
|
||||
foreach(sample_filename ${all_samples})
|
||||
ocv_define_sample(tgt ${sample_filename} gpu)
|
||||
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
||||
if(HAVE_opencv_xfeatures2d)
|
||||
ocv_include_modules_recurse(opencv_xfeatures2d)
|
||||
ocv_target_link_libraries(${tgt} opencv_xfeatures2d)
|
||||
endif()
|
||||
|
||||
if(HAVE_opencv_cudacodec)
|
||||
ocv_include_modules_recurse(opencv_cudacodec)
|
||||
ocv_target_link_libraries(${tgt} opencv_cudacodec)
|
||||
endif()
|
||||
|
||||
if(HAVE_CUDA)
|
||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
||||
endif()
|
||||
|
||||
# ---------------------------------------------
|
||||
# Define executable targets
|
||||
# ---------------------------------------------
|
||||
MACRO(OPENCV_DEFINE_CUDA_EXAMPLE name srcs)
|
||||
set(the_target "example_${project}_${name}")
|
||||
add_executable(${the_target} ${srcs})
|
||||
|
||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
if(HAVE_CUDA AND NOT ANDROID)
|
||||
ocv_target_link_libraries(${the_target} ${CUDA_CUDA_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(HAVE_opencv_xfeatures2d)
|
||||
ocv_target_link_libraries(${the_target} opencv_xfeatures2d)
|
||||
endif()
|
||||
if(HAVE_opencv_cudacodec)
|
||||
ocv_target_link_libraries(${the_target} opencv_cudacodec)
|
||||
endif()
|
||||
|
||||
if(HAVE_opencv_ocl)
|
||||
ocv_target_link_libraries(${the_target} opencv_ocl)
|
||||
endif()
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
OUTPUT_NAME "${project}-example-${name}"
|
||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT samples)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
|
||||
if(NOT HAVE_OPENGL)
|
||||
list(REMOVE_ITEM all_samples "opengl.cpp")
|
||||
endif()
|
||||
|
||||
foreach(sample_filename ${all_samples})
|
||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
||||
OPENCV_DEFINE_CUDA_EXAMPLE(${sample} ${sample_srcs})
|
||||
endforeach()
|
||||
|
||||
include("performance/CMakeLists.txt")
|
||||
endif()
|
||||
|
||||
if(INSTALL_C_EXAMPLES AND NOT WIN32)
|
||||
file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
|
||||
if(NOT HAVE_OPENGL)
|
||||
list(REMOVE_ITEM install_list "opengl.cpp")
|
||||
endif()
|
||||
install(FILES ${install_list}
|
||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
||||
endif()
|
||||
endforeach()
|
||||
include("performance/CMakeLists.txt" OPTIONAL)
|
||||
|
@ -34,10 +34,4 @@ if(WIN32)
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/gpu" COMPONENT samples)
|
||||
endif()
|
||||
|
||||
if(INSTALL_C_EXAMPLES AND NOT WIN32)
|
||||
file(GLOB CUDA_FILES performance/*.cpp performance/*.h)
|
||||
install(FILES ${CUDA_FILES}
|
||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu/performance
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
|
||||
COMPONENT samples)
|
||||
endif()
|
||||
ocv_install_example_src("gpu/performance" performance/*.cpp performance/*.h)
|
||||
|
@ -1,72 +1,38 @@
|
||||
# cmake 3.1 needed for find_package(OpenCL)
|
||||
ocv_install_example_src(opencl *.cpp *.hpp CMakeLists.txt)
|
||||
|
||||
# cmake 3.1 needed for find_package(OpenCL)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.1")
|
||||
message(STATUS "OpenCL samples require CMakes 3.1+")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(
|
||||
OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS
|
||||
opencv_core
|
||||
opencv_imgproc
|
||||
opencv_video
|
||||
opencv_imgcodecs
|
||||
opencv_videoio
|
||||
opencv_highgui)
|
||||
|
||||
set(OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS
|
||||
opencv_core
|
||||
opencv_imgproc
|
||||
opencv_video
|
||||
opencv_imgcodecs
|
||||
opencv_videoio
|
||||
opencv_highgui)
|
||||
ocv_check_dependencies(${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
|
||||
find_package(OpenCL 1.2 QUIET)
|
||||
if(NOT OpenCL_FOUND)
|
||||
message(STATUS "OpenCL samples are skipped: OpenCL SDK is required")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(project "opencl")
|
||||
string(TOUPPER "${project}" project_upper)
|
||||
|
||||
project("${project}_samples")
|
||||
|
||||
ocv_include_modules_recurse(${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
include_directories(${OpenCL_INCLUDE_DIR})
|
||||
|
||||
# ---------------------------------------------
|
||||
# Define executable targets
|
||||
# ---------------------------------------------
|
||||
MACRO(OPENCV_DEFINE_OPENCL_EXAMPLE name srcs)
|
||||
set(the_target "example_${project}_${name}")
|
||||
add_executable(${the_target} ${srcs})
|
||||
|
||||
ocv_target_link_libraries(
|
||||
${the_target}
|
||||
${OPENCV_LINKER_LIBS}
|
||||
${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS}
|
||||
${OpenCL_LIBRARY})
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
OUTPUT_NAME "${project}-example-${name}"
|
||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT main)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
|
||||
foreach(sample_filename ${all_samples})
|
||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
||||
OPENCV_DEFINE_OPENCL_EXAMPLE(${sample} ${sample_srcs})
|
||||
endforeach()
|
||||
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(OpenCL 1.2 QUIET)
|
||||
if(NOT OpenCL_FOUND)
|
||||
message(STATUS "OpenCL samples are skipped: OpenCL SDK is required")
|
||||
return()
|
||||
endif()
|
||||
|
||||
project(opencl_samples)
|
||||
ocv_include_modules_recurse(${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS})
|
||||
ocv_include_directories(${OpenCL_INCLUDE_DIR})
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
foreach(sample_filename ${all_samples})
|
||||
ocv_define_sample(tgt ${sample_filename} opencl)
|
||||
ocv_target_link_libraries(${tgt}
|
||||
${OPENCV_LINKER_LIBS}
|
||||
${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS}
|
||||
${OpenCL_LIBRARY})
|
||||
endforeach()
|
||||
|
@ -12,50 +12,23 @@ if(UNIX)
|
||||
set(SAMPLE_LINKER_DEPS "${X11_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
SET(OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui)
|
||||
|
||||
SET(OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS
|
||||
opencv_core
|
||||
opencv_imgproc
|
||||
opencv_imgcodecs
|
||||
opencv_videoio
|
||||
opencv_highgui)
|
||||
ocv_check_dependencies(${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
set(project "opengl")
|
||||
string(TOUPPER "${project}" project_upper)
|
||||
|
||||
project("${project}_samples")
|
||||
|
||||
project(opengl_samples)
|
||||
ocv_include_modules_recurse(${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
# ---------------------------------------------
|
||||
# Define executable targets
|
||||
# ---------------------------------------------
|
||||
MACRO(OPENCV_DEFINE_OPENGL_EXAMPLE name srcs)
|
||||
set(the_target "example_${project}_${name}")
|
||||
add_executable(${the_target} ${srcs})
|
||||
|
||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS} ${SAMPLE_LINKER_DEPS})
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
OUTPUT_NAME "${project}-example-${name}"
|
||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT samples)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
|
||||
foreach(sample_filename ${all_samples})
|
||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
||||
OPENCV_DEFINE_OPENGL_EXAMPLE(${sample} ${sample_srcs})
|
||||
ocv_define_sample(tgt ${sample_filename} opengl)
|
||||
ocv_target_link_libraries(${tgt}
|
||||
${OPENCV_LINKER_LIBS} ${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS} ${SAMPLE_LINKER_DEPS})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
ocv_install_example_src(opengl *.cpp *.hpp CMakeLists.txt)
|
||||
|
@ -1,37 +1,25 @@
|
||||
ocv_install_example_src(cpp *.cpp *.hpp CMakeLists.txt)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.9)
|
||||
|
||||
set(OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui)
|
||||
|
||||
set(OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS
|
||||
opencv_core
|
||||
opencv_imgproc
|
||||
opencv_imgcodecs
|
||||
opencv_videoio
|
||||
opencv_highgui)
|
||||
ocv_check_dependencies(${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
|
||||
|
||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
set(group "openvx")
|
||||
set(name_wrapped "interop")
|
||||
set(name_orig "interop_orig")
|
||||
set(name_video "interop_video")
|
||||
|
||||
project("${group}_sample")
|
||||
|
||||
ocv_include_modules_recurse(${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
|
||||
|
||||
add_definitions(-DIVX_USE_OPENCV)
|
||||
add_definitions(-DIVX_HIDE_INFO_WARNINGS)
|
||||
|
||||
file(GLOB srcs_wrapped wrappers.cpp *.hpp)
|
||||
file(GLOB srcs_orig no_wrappers.cpp *.hpp)
|
||||
file(GLOB srcs_video wrappers_video.cpp *.hpp)
|
||||
|
||||
MACRO(OPENVX_DEFINE_SAMPLE name srcs)
|
||||
set(target "example_${group}_${name}")
|
||||
add_executable(${target} ${srcs})
|
||||
ocv_target_link_libraries(${target} ${OPENCV_LINKER_LIBS} ${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS} ${OPENVX_LIBRARIES})
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${target} PROPERTIES FOLDER "samples//${group}")
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
OPENVX_DEFINE_SAMPLE(${name_wrapped} ${srcs_wrapped})
|
||||
OPENVX_DEFINE_SAMPLE(${name_orig} ${srcs_orig})
|
||||
OPENVX_DEFINE_SAMPLE(${name_video} ${srcs_video})
|
||||
|
||||
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
project(openvx_samples)
|
||||
ocv_include_modules_recurse(${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
|
||||
add_definitions(-DIVX_USE_OPENCV)
|
||||
add_definitions(-DIVX_HIDE_INFO_WARNINGS)
|
||||
file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
foreach(sample_filename ${cpp_samples})
|
||||
ocv_define_sample(tgt ${sample_filename} openvx)
|
||||
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
|
||||
endforeach()
|
||||
|
@ -1,52 +1,26 @@
|
||||
SET(OPENCV_TAPI_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_video opencv_imgcodecs opencv_videoio opencv_highgui opencv_objdetect opencv_features2d opencv_calib3d opencv_flann)
|
||||
ocv_install_example_src(tapi *.cpp *.hpp CMakeLists.txt)
|
||||
|
||||
set(OPENCV_TAPI_SAMPLES_REQUIRED_DEPS
|
||||
opencv_core
|
||||
opencv_imgproc
|
||||
opencv_video
|
||||
opencv_imgcodecs
|
||||
opencv_videoio
|
||||
opencv_highgui
|
||||
opencv_objdetect
|
||||
opencv_features2d
|
||||
opencv_calib3d
|
||||
opencv_flann)
|
||||
ocv_check_dependencies(${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
set(project "tapi")
|
||||
string(TOUPPER "${project}" project_upper)
|
||||
|
||||
project("${project}_samples")
|
||||
|
||||
ocv_include_modules_recurse(${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
# ---------------------------------------------
|
||||
# Define executable targets
|
||||
# ---------------------------------------------
|
||||
MACRO(OPENCV_DEFINE_TAPI_EXAMPLE name srcs)
|
||||
set(the_target "example_${project}_${name}")
|
||||
add_executable(${the_target} ${srcs})
|
||||
|
||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
OUTPUT_NAME "${project}-example-${name}"
|
||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||
endif()
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT samples)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
|
||||
foreach(sample_filename ${all_samples})
|
||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
||||
OPENCV_DEFINE_TAPI_EXAMPLE(${sample} ${sample_srcs})
|
||||
endforeach()
|
||||
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(INSTALL_C_EXAMPLES AND NOT WIN32)
|
||||
file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
|
||||
install(FILES ${install_list}
|
||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/tapi
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
||||
endif()
|
||||
project(tapi_samples)
|
||||
ocv_include_modules_recurse(${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
foreach(sample_filename ${all_samples})
|
||||
ocv_define_sample(tgt ${sample_filename} tapi)
|
||||
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
|
||||
endforeach()
|
||||
|
@ -1,38 +1,21 @@
|
||||
SET(OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui)
|
||||
ocv_install_example_src(opencl *.cpp *.inc CMakeLists.txt)
|
||||
|
||||
set(OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS
|
||||
opencv_core
|
||||
opencv_imgproc
|
||||
opencv_imgcodecs
|
||||
opencv_videoio
|
||||
opencv_highgui)
|
||||
ocv_check_dependencies(${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||
set(project "va_intel")
|
||||
string(TOUPPER "${project}" project_upper)
|
||||
|
||||
project("${project}_samples")
|
||||
|
||||
ocv_include_modules_recurse(${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS})
|
||||
|
||||
# ---------------------------------------------
|
||||
# Define executable targets
|
||||
# ---------------------------------------------
|
||||
MACRO(OPENCV_DEFINE_VA_INTEL_EXAMPLE name srcs)
|
||||
set(the_target "example_${project}_${name}")
|
||||
add_executable(${the_target} ${srcs})
|
||||
|
||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS} ${VA_LIBRARIES} ${VA_INTEL_LIBRARIES})
|
||||
|
||||
set_target_properties(${the_target} PROPERTIES
|
||||
OUTPUT_NAME "${project}-example-${name}"
|
||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
|
||||
foreach(sample_filename ${all_samples})
|
||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
||||
OPENCV_DEFINE_VA_INTEL_EXAMPLE(${sample} ${sample_srcs})
|
||||
endforeach()
|
||||
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||
return()
|
||||
endif()
|
||||
|
||||
project(va_intel_samples)
|
||||
ocv_include_modules_recurse(${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS})
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
foreach(sample_filename ${all_samples})
|
||||
ocv_define_sample(tgt ${sample_filename} va_intel)
|
||||
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS})
|
||||
endforeach()
|
||||
|
Loading…
Reference in New Issue
Block a user