-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
144 lines (118 loc) · 3.34 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
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
cmake_minimum_required(VERSION 2.8)
# Options
set(ENABLE_CAPTURE TRUE CACHE BOOL "Enable the Kinect capture tool")
set(ENABLE_PROCESS TRUE CACHE BOOL "Enable the command line processing tool")
set(ENABLE_GUI TRUE CACHE BOOL "Enable the Qt GUI")
set(ENABLE_TEST TRUE CACHE BOOL "Enable self-testing")
# Global settings
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
set(CMAKE_CXX_FLAGS "-Wall -std=c++11")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
# Boost
find_package(Boost
COMPONENTS program_options
REQUIRED)
function (UseBoost target)
target_include_directories(${target} PRIVATE ${Boost_INCLUDE_DIRS})
target_link_libraries(${target} ${Boost_LIBRARIES})
endfunction()
# TIFF
find_package(TIFF 4.0.0)
function (UseTiff target)
if (NOT TIFF_FOUND)
message(FATAL_ERROR "TIFF is required for target ${target}")
endif()
target_include_directories(${target} PRIVATE ${TIFF_INCLUDE_DIRS})
target_link_libraries(${target} ${TIFF_LIBRARIES})
endfunction()
# OpenCV
find_package(OpenCV COMPONENTS core highgui)
function (UseOpenCV target)
if (NOT OpenCV_FOUND)
message(FATAL_ERROR "OpenCV is required for target ${target}")
endif()
target_include_directories(${target} PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries(${target} ${OpenCV_LIBRARIES})
endfunction()
# libfreenect
find_package(libfreenect)
if (libfreenect_FOUND)
# Add library directory
# This is supposedly not needed for proper Find*.cmake modules
link_directories(${FREENECT_LIBRARY_DIRS})
endif()
function (UseFreenect target)
if (NOT libfreenect_FOUND)
message(FATAL_ERROR "libfreenect is required for target ${target}")
endif()
target_include_directories(${target} PRIVATE ${FREENECT_INCLUDE_DIRS})
target_link_libraries(${target} ${FREENECT_LIBRARIES})
endfunction()
# Qt
find_package(Qt5Widgets)
function (UseQt target)
if (NOT Qt5Widgets_FOUND)
message(FATAL_ERROR "Qt5 is required for target ${target}")
endif()
target_link_libraries(${target} Qt5::Widgets)
set(CMAKE_AUTOMOC ON)
endfunction()
# Threads
find_package(Threads)
function (UseThreads target)
target_link_libraries(${target} ${CMAKE_THREAD_LIBS_INIT})
endfunction()
# libspeckle
add_library(speckle
src/compute/ColourMap.cpp
src/compute/ComputePipeline.cpp
src/compute/CorrelationTime.cpp
src/compute/SpatialWindow.cpp
src/compute/Visualize.cpp)
function (UseSpeckle target)
target_link_libraries(${target} speckle)
endfunction()
# capture
if (ENABLE_CAPTURE)
add_executable(capture
src/tools/capture/capture.cpp
src/tools/capture/KinectCapture.cpp)
UseBoost(capture)
UseFreenect(capture)
UseTiff(capture)
UseOpenCV(capture)
endif()
# process
if (ENABLE_PROCESS)
add_executable(process src/tools/process/process.cpp)
UseBoost(process)
UseTiff(process)
UseOpenCV(process)
UseSpeckle(process)
endif()
# gui
if (ENABLE_GUI)
add_executable(gui
src/gui/gui.cpp
src/gui/MainWindow.cpp)
UseOpenCV(gui)
UseQt(gui)
UseFreenect(gui)
UseThreads(gui)
UseSpeckle(gui)
endif()
# test
if (ENABLE_TEST)
enable_testing()
add_executable(test-runner test/test-runner.cpp)
UseOpenCV(test-runner)
UseSpeckle(test-runner)
add_test(
NAME SpatialWindow
COMMAND $<TARGET_FILE:test-runner>
SpatialWindow ${CMAKE_CURRENT_SOURCE_DIR}/test/SpatialWindow.tsv)
add_test(
NAME CorrelationTime
COMMAND $<TARGET_FILE:test-runner>
CorrelationTime ${CMAKE_CURRENT_SOURCE_DIR}/test/CorrelationTime.tsv)
endif()