2013-08-07 16:53:48 +08:00
|
|
|
# Detect if we want to build samples with library binaries or not
|
|
|
|
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
|
|
|
|
#
|
|
|
|
# BUILD CASE 1: Build samples with library sources
|
|
|
|
#
|
|
|
|
|
|
|
|
|
2010-05-12 01:44:00 +08:00
|
|
|
# ----------------------------------------------------------------------------
|
2012-06-27 20:02:31 +08:00
|
|
|
# CMake file for samples. See root CMakeLists.txt
|
2010-05-12 01:44:00 +08:00
|
|
|
#
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
2012-06-27 20:02:31 +08:00
|
|
|
add_subdirectory(c)
|
|
|
|
add_subdirectory(cpp)
|
|
|
|
add_subdirectory(gpu)
|
2012-08-08 17:12:53 +08:00
|
|
|
add_subdirectory(ocl)
|
2011-06-30 21:37:56 +08:00
|
|
|
|
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()
|
2013-08-07 16:53:48 +08:00
|
|
|
|
2015-01-19 01:33:05 +08:00
|
|
|
if(INSTALL_C_EXAMPLES)
|
|
|
|
install(FILES "CMakeLists.txt"
|
|
|
|
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}
|
2015-10-13 21:32:53 +08:00
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ COMPONENT samples)
|
2015-01-19 01:33:05 +08:00
|
|
|
endif()
|
2013-08-07 16:53:48 +08:00
|
|
|
|
2014-12-30 18:13:10 +08:00
|
|
|
if(INSTALL_PYTHON_EXAMPLES)
|
|
|
|
add_subdirectory(python2)
|
|
|
|
endif()
|
|
|
|
|
2013-08-07 16:53:48 +08:00
|
|
|
#
|
|
|
|
# END OF BUILD CASE 1: Build samples with library sources
|
|
|
|
#
|
|
|
|
else()
|
|
|
|
#
|
|
|
|
# BUILD CASE 2: Build samples with library binaries
|
|
|
|
#
|
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
|
|
|
project(samples C CXX)
|
|
|
|
option(BUILD_EXAMPLES "Build samples" ON)
|
|
|
|
|
|
|
|
find_package(OpenCV REQUIRED)
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
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")
|
|
|
|
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-08-07 16:53:48 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
add_subdirectory(c)
|
|
|
|
add_subdirectory(cpp)
|
2015-10-14 17:52:32 +08:00
|
|
|
ocv_check_dependencies(opencv_ocl)
|
|
|
|
if (OCV_DEPENDENCIES_FOUND)
|
|
|
|
add_subdirectory(ocl)
|
|
|
|
endif()
|
|
|
|
ocv_check_dependencies(opencv_gpu)
|
|
|
|
if (OCV_DEPENDENCIES_FOUND)
|
|
|
|
add_subdirectory(gpu)
|
|
|
|
endif()
|
2013-08-07 16:53:48 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# END OF BUILD CASE 2: Build samples with library binaries
|
|
|
|
#
|
|
|
|
endif()
|