This repository has been archived by the owner on Aug 6, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 173
/
CMakeLists.txt
71 lines (56 loc) · 2.56 KB
/
CMakeLists.txt
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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
set(name "facerec")
set(the_library "opencv_${name}")
project(${the_library})
#SET(OpenCV_DIR /path/to/your/opencv/installation)
#---------------------------------
# packages
#---------------------------------
find_package(OpenCV REQUIRED) # http://opencv.willowgarage.com
#---------------------------------
# includes & sources
#---------------------------------
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include")
file(GLOB lib_hdrs "include/*.hpp")
file(GLOB lib_srcs "src/*.cpp")
#---------------------------------
# build the library & link
#---------------------------------
add_library(${the_library} ${lib_srcs} ${lib_hdrs})
target_link_libraries(${the_library} opencv_core opencv_imgproc opencv_highgui)
#---------------------------------
# add tests
#---------------------------------
if(NOT DEFINED ENABLE_TESTS)
set(ENABLE_TESTS FALSE CACHE BOOL "Enable to make the tests")
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test AND ENABLE_TESTS)
file(GLOB test_srcs "test/*.cpp")
file(GLOB test_hdrs "test/*.h*")
set(the_test_target "opencv_test_${name}")
add_executable(${the_test_target} ${test_srcs} ${test_hdrs})
# link to opencv_ts, as it is not in OpenCV_LIBS for OpenCV 2.3.1
target_link_libraries(${the_test_target} ${the_library} opencv_core opencv_ts)
enable_testing()
get_target_property(LOC ${the_test_target} LOCATION)
add_test(${the_test_target} "${LOC}")
endif()
#---------------------------------
# add samples
#---------------------------------
if(NOT DEFINED ENABLE_SAMPLES)
set(ENABLE_SAMPLES FALSE CACHE BOOL "Enable to make the samples")
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/samples AND ENABLE_SAMPLES)
# probably there's a simpler way to link against multiple executables...
add_executable(facerec_demo samples/facerec_demo.cpp)
target_link_libraries(facerec_demo ${the_library} opencv_core opencv_imgproc opencv_highgui)
add_executable(facerec_video samples/facerec_video.cpp)
target_link_libraries(facerec_video ${the_library} opencv_core opencv_imgproc opencv_highgui opencv_objdetect opencv_imgproc)
add_executable(facerec_eigenfaces samples/facerec_eigenfaces.cpp)
target_link_libraries(facerec_eigenfaces ${the_library} opencv_core opencv_imgproc opencv_highgui)
add_executable(facerec_fisherfaces samples/facerec_fisherfaces.cpp)
target_link_libraries(facerec_fisherfaces ${the_library} opencv_core opencv_imgproc opencv_highgui)
add_executable(facerec_lbph samples/facerec_lbph.cpp)
target_link_libraries(facerec_lbph ${the_library} opencv_core opencv_imgproc opencv_highgui)
endif()