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 # ----------------------------------------------------------------------------
17 add_subdirectory(tapi)
19 if(WIN32 AND HAVE_DIRECTX)
20 add_subdirectory(directx)
23 if(ANDROID AND BUILD_ANDROID_EXAMPLES)
24 add_subdirectory(android)
28 # END OF BUILD CASE 1: Build samples with library sources
32 # BUILD CASE 2: Build samples with library binaries
34 cmake_minimum_required(VERSION 2.8)
36 project(samples C CXX)
37 option(BUILD_EXAMPLES "Build samples" ON)
39 find_package(OpenCV REQUIRED)
42 add_definitions(-D_CRT_SECURE_NO_WARNINGS)
46 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
47 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
48 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
49 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
50 if(${flag_var} MATCHES "/MD")
51 string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
53 if(${flag_var} MATCHES "/MDd")
54 string(REGEX REPLACE "/MDd" "/MTd" ${flag_var} "${${flag_var}}")
58 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib")
59 set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib")
60 set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib")
67 # FIXIT: can't use cvconfig.h in samples: add_subdirectory(gpu)
70 add_subdirectory(directx)
74 # END OF BUILD CASE 2: Build samples with library binaries