forked from jrterven/win-sdk-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
executable file
·162 lines (132 loc) · 5.84 KB
/
CMakeLists.txt
File metadata and controls
executable file
·162 lines (132 loc) · 5.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
cmake_minimum_required(VERSION 2.6)
set(rootProject cpp-sdk-samples)
project(${rootProject})
# CMake includes
include(cmake_modules/Macros.cmake) # Some custom macros we have writtens
# -------------------
# CMAKE - ENVIRONMENT
# --------------------
set(CXX_COMPILER_WARNINGS "-Wreturn-type" CACHE STRING "Compiler warnings to use")
set(CMAKE_VERBOSE ON CACHE BOOL "Verbose mode")
# Setup "Profile" build type
set(CMAKE_CXX_FLAGS_PROFILE "-O3 -pg")
set(CMAKE_C_FLAGS_PROFILE "-O3 -pg")
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "-pg")
set(CMAKE_MODULE_LINKER_FLAGS_PROFILE "-pg")
# Setup additional compiler warnings
status("Setting up compiler warnings")
if( MSVC )
# Force to always compile with W4
if( CMAKE_CXX_FLAGS MATCHES "/W[0-4]" )
string( REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
else()
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4" )
endif()
elseif( CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX )
# Update if necessary
set( CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS} ${CXX_COMPILER_WARNINGS}" )
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
status("Updating compiler to make use of C++14")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++14")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
endif()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(bitness 64) # We have a 64-bit machine
else()
set(bitness 32) # We have a 32-bit machine
endif()
status("Bitness detected: ${bitness}")
# Setup install locations
if( NOT RUNTIME_INSTALL_DIRECTORY )
set( RUNTIME_INSTALL_DIRECTORY "bin" CACHE STRING "Install sub-directory of CMAKE_INSTALL_PREFIX for RUNTIME targets (binaries, and *.dll on windows)." )
endif( NOT RUNTIME_INSTALL_DIRECTORY )
# --------------------
# LOCATE DEPENDENCIES
# --------------------
# OpenCV
# ----------------------------------------------------------------------------
# find_package OpenCV to get OpenCV_FOUND, OpenCV_INCLUDE_DIRS, OpenCV_LIBS, OpenCV_LINK_LIBRARIES
# ----------------------------------------------------------------------------
set( OPENCV_COMPONENTS ml highgui core imgproc objdetect )
if( DEFINED OpenCV_DIR ) # Force the user to tell us which OpenCV they want (otherwise find_package can find the wrong one, cache it and changes to OpenCV_DIR are ignored)
find_package(OpenCV REQUIRED PATHS ${OpenCV_DIR})
if( NOT OpenCV_FOUND)
message(SEND_ERROR "Failed to find OpenCV. Double check that \"OpenCV_DIR\" to the root build directory of OpenCV.")
endif(NOT OpenCV_FOUND)
else( DEFINED OpenCV_DIR )
set( OpenCV_DIR "" CACHE PATH "Root directory for opencv BUILD directory." )
message(FATAL_ERROR "\"OpenCV_DIR\" not set. Please explicitly provide the path to the root build directory of OpenCV.")
endif( DEFINED OpenCV_DIR )
# Boost package
# ----------------------------------------------------------------------------
# BOOST_ROOT is needed by BoostConfig.cmake configuration file to
# look for the Boost includes / libraries:
# Boost_FOUND, Boost_INCLUDE_DIRS, Boost_LIBRARY_DIRS, Boost_LIBRARIES,Boost_VERSION
set(Boost_USE_MULTITHREADED ON)
set( BOOST_COMPONENTS system filesystem date_time regex thread timer chrono serialization log log_setup program_options)
set( BOOST_MIN_VERSION "1.54.0" CACHE STRING "Minimum version of boost you would like to link against (e.g. C:/BOOST_1_55_0 is 1.55.0" )
status("")
if( ANDROID )
find_host_package( Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS ${BOOST_COMPONENTS} )
else( ANDROID )
find_package( Boost ${BOOST_MIN_VERSION} REQUIRED COMPONENTS ${BOOST_COMPONENTS} )
endif()
if( NOT Boost_FOUND )
if( NOT DEFINED BOOST_ROOT )
set( BOOST_ROOT "" CACHE PATH "Root directory for Boost." )
endif( NOT DEFINED BOOST_ROOT )
message( FATAL_ERROR "Failed to find Boost (or missing components). Double check that \"BOOST_ROOT\" is properly set")
endif( NOT Boost_FOUND )
# Affdex package
# ----------------------------------------------------------------------------
set (AFFDEX_FOUND FALSE)
if( DEFINED AFFDEX_DIR )
find_path(AFFDEX_INCLUDE_DIR FrameDetector.h
HINTS "${AFFDEX_DIR}/include" )
find_library(AFFDEX_LIBRARY NAMES affdex-native
HINTS "${AFFDEX_DIR}/lib" )
set(AFFDEX_INCLUDE_DIRS "${AFFDEX_INCLUDE_DIR}")
set(AFFDEX_LIBRARIES "${AFFDEX_LIBRARY}")
if (AFFDEX_INCLUDE_DIR AND AFFDEX_LIBRARY)
set(AFFDEX_FOUND TRUE)
endif (AFFDEX_INCLUDE_DIR AND AFFDEX_LIBRARY)
set(AFFDEX_DATA_DIR "${AFFDEX_DIR}/data")
if (NOT AFFDEX_FOUND)
message(FATAL_ERROR "Unable to find the Affdex found")
endif (NOT AFFDEX_FOUND)
else (DEFINED AFFDEX_DIR)
message(FATAL_ERROR "Please define AFFDEX_DIR")
endif (DEFINED AFFDEX_DIR)
add_subdirectory(opencv-webcam-demo)
add_subdirectory(video-demo)
# --------------------
# SUMMARY
# --------------------
status("${CMAKE_INCLUDE_DIRECTORIES}")
status( "------- SUMMARY ------- " )
status( "Boost version found = ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION} (${Boost_VERSION})" )
foreach( comp ${BOOST_COMPONENTS} )
string( TOUPPER ${comp} COMP )
status( " - ${comp}" 1 THEN "${Boost_${COMP}_LIBRARY}" )
endforeach( comp )
status("")
status("Affdex")
foreach( lib ${AFFDEX_LIBRARIES} )
status( "${lib}")
endforeach( lib )
status("")
status( "OpenCV version found = ${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.${OpenCV_VERSION_PATCH} (${OpenCV_VERSION})" )
status( "OpenCV_LIB_DIR = ${OpenCV_DIR}/lib" )
foreach( lib ${OpenCV_LIBRARIES} )
foreach( comp ${OPENCV_COMPONENTS} )
if( ${lib} MATCHES ${comp} )
status( " - ${comp}" 1 THEN "${lib}" )
endif( ${lib} MATCHES ${comp} )
endforeach( comp )
endforeach( lib )
status("")
status( "Apps identified for building:" )
foreach( app ${${rootProject}_APPS} )
status( " - ${app}" )
endforeach( app ${${rootProject}_APPS} )