-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
85 lines (66 loc) · 3.03 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
cmake_minimum_required(VERSION 3.0)
project(KinectAssignments CXX)
# find OpenCV
find_package(OpenCV REQUIRED)
message(STATUS "OpenCV_LIBS: ${OpenCV_LIBS}")
# find OpenNI2
set(OpenNI_DIR "" CACHE PATH "OpenNI2 base directory. On windows, this should be C:\\Program Files\\OpenNI2.")
set(OpenNI_INCLUDE_DIR ${OpenNI_DIR}/Include)
set(OpenNI_LIB_DIR ${OpenNI_DIR}/Lib)
file(GLOB OpenNI_LIBS ${OpenNI_LIB_DIR}/*)
if(NOT OpenNI_LIBS)
message(FATAL_ERROR "Could not find any OpenNI libs. Please check the OpenNI_DIR.")
endif()
message(STATUS "OpenNI_LIBS: ${OpenNI_LIBS}")
# framework
set(source_dir src)
set(framework_source_dir ${source_dir}/framework)
file(GLOB framework_sources ${framework_source_dir}/*.cpp)
file(GLOB framework_headers ${framework_source_dir}/*.hpp)
add_library(framework ${framework_headers} ${framework_sources})
target_include_directories(framework PUBLIC ${OpenNI_INCLUDE_DIR})
target_link_libraries(framework ${OpenCV_LIBS} ${OpenNI_LIBS})
# helper macros
macro(get_relative_files files)
foreach(file ${${files}})
file(RELATIVE_PATH relative_temp ${CMAKE_SOURCE_DIR} ${file})
if(NOT files_temp)
set(files_temp "${relative_temp}")
else()
set(files_temp "${files_temp};${relative_temp}")
endif()
endforeach()
set(${files}_relative "${files_temp}")
unset(files_temp)
unset(files_relative)
endmacro()
macro(add_additional assignment_name file_type)
set(${assignment_name}_${file_type}_relative ${${assignment_name}_${file_type}_relative} ${${assignment_name}_additional_${file_type}})
endmacro()
macro(add_files assignment_name file_type glob_pattern)
file(GLOB ${assignment_name}_${file_type} ${${assignment_name}_source_dir}/${glob_pattern})
get_relative_files(${assignment_name}_${file_type})
add_additional(${assignment_name} ${file_type})
endmacro()
# assingment macro
macro(add_assignment assignment_name)
set(${assignment_name}_source_dir ${source_dir}/${assignment_name})
add_files(${assignment_name} sources "*.cpp")
add_files(${assignment_name} headers "*.hpp")
message(STATUS "Adding ${assignment_name}...")
message(STATUS " Source dir: ${${assignment_name}_source_dir}")
message(STATUS " Headers: ${${assignment_name}_headers_relative}")
message(STATUS " Sources: ${${assignment_name}_sources_relative}")
add_executable(${assignment_name} ${${assignment_name}_headers_relative} ${${assignment_name}_sources_relative})
target_link_libraries(${assignment_name} framework)
endmacro()
# assingnments
add_assignment("assignment00")
add_assignment("assignment01")
set(assignment02_additional_headers "src/assignment01/touchRecognizer.hpp")
set(assignment02_additional_sources "src/assignment01/touchRecognizer.cpp")
add_assignment("assignment02")
configure_file("${assignment02_source_dir}/pendigits.tra" "${CMAKE_CURRENT_BINARY_DIR}")
set(assignment03_additional_headers "src/assignment01/touchRecognizer.hpp")
set(assignment03_additional_sources "src/assignment01/touchRecognizer.cpp")
add_assignment("assignment03")