2013-08-07 16:53:48 +08:00
|
|
|
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
|
2018-02-09 18:30:04 +08:00
|
|
|
#===================================================================================================
|
2013-08-07 16:53:48 +08:00
|
|
|
#
|
2018-02-09 18:30:04 +08:00
|
|
|
# Build as part of OpenCV
|
2013-08-07 16:53:48 +08:00
|
|
|
#
|
2018-02-09 18:30:04 +08:00
|
|
|
#===================================================================================================
|
|
|
|
|
2019-05-14 20:46:44 +08:00
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/samples_utils.cmake")
|
|
|
|
|
2018-02-09 18:30:04 +08:00
|
|
|
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()
|
2010-05-12 01:44:00 +08:00
|
|
|
|
2019-05-14 20:46:44 +08:00
|
|
|
if((TARGET Threads::Threads OR HAVE_PTHREAD OR MSVC OR APPLE) AND NOT OPENCV_EXAMPLES_DISABLE_THREADS)
|
|
|
|
add_definitions(-DHAVE_THREADS=1)
|
|
|
|
endif()
|
|
|
|
|
2012-06-27 20:02:31 +08:00
|
|
|
add_subdirectory(cpp)
|
2017-06-26 23:24:10 +08:00
|
|
|
add_subdirectory(java/tutorial_code)
|
2017-06-26 19:36:40 +08:00
|
|
|
add_subdirectory(dnn)
|
2012-06-27 20:02:31 +08:00
|
|
|
add_subdirectory(gpu)
|
2013-12-29 06:28:43 +08:00
|
|
|
add_subdirectory(tapi)
|
2018-02-09 18:30:04 +08:00
|
|
|
add_subdirectory(opencl)
|
2013-12-02 05:50:24 +08:00
|
|
|
if(WIN32 AND HAVE_DIRECTX)
|
|
|
|
add_subdirectory(directx)
|
|
|
|
endif()
|
2015-06-01 23:16:22 +08:00
|
|
|
if((NOT ANDROID) AND HAVE_OPENGL)
|
|
|
|
add_subdirectory(opengl)
|
|
|
|
endif()
|
2016-09-01 19:34:34 +08:00
|
|
|
if(HAVE_OPENVX)
|
|
|
|
add_subdirectory(openvx)
|
|
|
|
endif()
|
2015-09-11 00:30:19 +08:00
|
|
|
if(UNIX AND NOT ANDROID AND (HAVE_VA OR HAVE_VA_INTEL))
|
2015-08-31 07:33:15 +08:00
|
|
|
add_subdirectory(va_intel)
|
2015-08-12 16:59:05 +08:00
|
|
|
endif()
|
2012-02-03 19:26:49 +08:00
|
|
|
if(ANDROID AND BUILD_ANDROID_EXAMPLES)
|
|
|
|
add_subdirectory(android)
|
2010-12-05 09:19:36 +08:00
|
|
|
endif()
|
2014-12-30 18:13:10 +08:00
|
|
|
if(INSTALL_PYTHON_EXAMPLES)
|
2015-12-16 21:36:03 +08:00
|
|
|
add_subdirectory(python)
|
2014-12-30 18:13:10 +08:00
|
|
|
endif()
|
|
|
|
|
2020-02-06 23:04:09 +08:00
|
|
|
ocv_install_example_src("." CMakeLists.txt samples_utils.cmake)
|
2018-02-09 18:30:04 +08:00
|
|
|
if(INSTALL_C_EXAMPLES)
|
2018-08-01 20:58:20 +08:00
|
|
|
install(DIRECTORY data DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}" COMPONENT samples_data)
|
2018-02-09 18:30:04 +08:00
|
|
|
endif()
|
|
|
|
|
2013-08-07 16:53:48 +08:00
|
|
|
else()
|
2018-02-09 18:30:04 +08:00
|
|
|
#===================================================================================================
|
2013-08-07 16:53:48 +08:00
|
|
|
#
|
2018-02-09 18:30:04 +08:00
|
|
|
# Standalone mode
|
2013-08-07 16:53:48 +08:00
|
|
|
#
|
2018-02-09 18:30:04 +08:00
|
|
|
#===================================================================================================
|
2022-07-12 18:42:39 +08:00
|
|
|
cmake_minimum_required(VERSION 2.8.12.2)
|
2013-08-07 16:53:48 +08:00
|
|
|
|
|
|
|
project(samples C CXX)
|
|
|
|
option(BUILD_EXAMPLES "Build samples" ON)
|
|
|
|
|
2018-02-09 18:30:04 +08:00
|
|
|
# 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 "..")
|
|
|
|
|
2019-05-14 20:46:44 +08:00
|
|
|
include("${CMAKE_CURRENT_LIST_DIR}/samples_utils.cmake")
|
|
|
|
|
2018-02-09 18:30:04 +08:00
|
|
|
function(ocv_install_example_src)
|
|
|
|
# not used in this branch
|
|
|
|
endfunction()
|
2013-08-07 16:53:48 +08:00
|
|
|
|
|
|
|
if(MSVC)
|
2017-06-07 17:07:32 +08:00
|
|
|
if(NOT ENABLE_BUILD_HARDENING)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
|
|
|
endif()
|
2013-10-03 22:48:07 +08:00
|
|
|
|
|
|
|
if(NOT OpenCV_SHARED)
|
|
|
|
foreach(flag_var
|
|
|
|
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
|
|
|
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
|
|
|
|
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
|
|
|
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
|
|
|
if(${flag_var} MATCHES "/MD")
|
|
|
|
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
|
|
|
endif()
|
|
|
|
if(${flag_var} MATCHES "/MDd")
|
|
|
|
string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
|
|
|
|
endif()
|
|
|
|
endforeach(flag_var)
|
|
|
|
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib")
|
2021-10-04 20:42:51 +08:00
|
|
|
if(NOT BUILD_WITH_STATIC_CRT)
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib")
|
|
|
|
endif()
|
2013-10-03 22:48:07 +08:00
|
|
|
endif()
|
2013-08-07 16:53:48 +08:00
|
|
|
endif()
|
|
|
|
|
2018-03-26 18:02:57 +08:00
|
|
|
add_definitions(-DDISABLE_OPENCV_24_COMPATIBILITY=1) # Avoid C-like legacy API
|
|
|
|
|
2019-05-14 20:46:44 +08:00
|
|
|
if(OPENCV_EXAMPLES_DISABLE_THREADS)
|
|
|
|
# nothing
|
|
|
|
elseif(MSVC OR APPLE)
|
|
|
|
set(HAVE_THREADS 1)
|
|
|
|
else()
|
|
|
|
find_package(Threads)
|
|
|
|
endif()
|
|
|
|
if((TARGET Threads::Threads OR HAVE_THREADS) AND NOT OPENCV_EXAMPLES_DISABLE_THREADS)
|
2021-10-19 17:28:12 +08:00
|
|
|
set(HAVE_THREADS 1)
|
2019-05-14 20:46:44 +08:00
|
|
|
add_definitions(-DHAVE_THREADS=1)
|
|
|
|
endif()
|
|
|
|
|
2013-08-07 16:53:48 +08:00
|
|
|
add_subdirectory(cpp)
|
2013-12-02 05:50:24 +08:00
|
|
|
if(WIN32)
|
|
|
|
add_subdirectory(directx)
|
|
|
|
endif()
|
2018-02-09 18:30:04 +08:00
|
|
|
add_subdirectory(dnn)
|
|
|
|
# add_subdirectory(gpu)
|
|
|
|
add_subdirectory(opencl)
|
|
|
|
# add_subdirectory(opengl)
|
|
|
|
# add_subdirectory(openvx)
|
|
|
|
add_subdirectory(tapi)
|
|
|
|
# add_subdirectory(va_intel)
|
2013-12-02 05:50:24 +08:00
|
|
|
|
2013-12-29 06:28:43 +08:00
|
|
|
endif()
|