1 # Detect if we want to build samples with library binaries or not
2 if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
4 # BUILD CASE 1: Build samples with library sources
8 # ----------------------------------------------------------------------------
9 # CMake file for samples. See root CMakeLists.txt
11 # ----------------------------------------------------------------------------
16 add_subdirectory(tapi)
18 if(WIN32 AND HAVE_DIRECTX)
19 add_subdirectory(directx)
22 if(ANDROID AND BUILD_ANDROID_EXAMPLES)
23 add_subdirectory(android)
27 # END OF BUILD CASE 1: Build samples with library sources
31 # BUILD CASE 2: Build samples with library binaries
33 cmake_minimum_required(VERSION 2.8)
35 project(samples C CXX)
36 option(BUILD_EXAMPLES "Build samples" ON)
38 find_package(OpenCV REQUIRED)
41 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
45 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
46 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
47 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
48 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
49 if(${flag_var} MATCHES "/MD")
50 string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
52 if(${flag_var} MATCHES "/MDd")
53 string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
57 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib")
58 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib")
59 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib")
65 # FIXIT: can't use cvconfig.h in samples: add_subdirectory(gpu)
68 add_subdirectory(directx)
72 # END OF BUILD CASE 2: Build samples with library binaries