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 # ----------------------------------------------------------------------------
15 add_subdirectory(tapi)
17 if(WIN32 AND HAVE_DIRECTX)
18 add_subdirectory(directx)
21 if(ANDROID AND BUILD_ANDROID_EXAMPLES)
22 add_subdirectory(android)
26 # END OF BUILD CASE 1: Build samples with library sources
30 # BUILD CASE 2: Build samples with library binaries
32 cmake_minimum_required(VERSION 2.8)
34 project(samples C CXX)
35 option(BUILD_EXAMPLES "Build samples" ON)
37 find_package(OpenCV REQUIRED)
40 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
44 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
45 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
46 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
47 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
48 if(${flag_var} MATCHES "/MD")
49 string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
51 if(${flag_var} MATCHES "/MDd")
52 string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
56 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib")
57 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib")
58 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib")
63 # FIXIT: can't use cvconfig.h in samples: add_subdirectory(gpu)
66 add_subdirectory(directx)
70 # END OF BUILD CASE 2: Build samples with library binaries