-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
154 lines (117 loc) · 4.26 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
143
144
145
146
147
148
149
150
cmake_minimum_required(VERSION 3.21)
project(ir-tracking)
# Set C++17 as the standard globally
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 -D_ENABLE_EXTENDED_ALIGNED_STORAGE=1")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /FORCE") # /PROFILE
add_definitions("/MP")
add_definitions("/MT")
else()
# Warnings
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
# Remove Asio warning
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable")
# Static library: -fPIC
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS_DEBUG "-g -O0 -march=native -fstack-protector")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native")
endif()
IF(MSVC)
ADD_DEFINITIONS(/arch:AVX)
ENDIF(MSVC)
add_subdirectory(extern)
# Simple non robust way to find the k4a library
if(NOT WIN32)
# Find the Azure Kinect SDK
find_package( k4a REQUIRED )
endif()
# Find OpenCV
find_package(OpenCV REQUIRED)
# Include directories for OpenCV
include_directories(${OpenCV_INCLUDE_DIRS})
set(TRACKER_SOURCE_FILES
include/IRStructs.h
include/IRKalmanFilter.h
include/IRToolTrack.h
include/IRToolTracking.h
src/IRToolTrack.cpp
src/IRToolTracking.cpp
)
include_directories(include)
# Add the IRToolTracking library
add_library(IRToolTracking STATIC ${TRACKER_SOURCE_FILES})
# Specify C++17 for IRToolTracking library
target_compile_features(IRToolTracking PUBLIC cxx_std_17)
# Link RealSense SDK and OpenCV with the IRToolTracking library
target_link_libraries(IRToolTracking PUBLIC Eigen3 k4a::k4a opencv_core opencv_imgproc opencv_imgcodecs opencv_video)
################################################################################
# Dependencies for the main application
#set(MACOS_ICON "resources/app_icon.icns")
find_package(OpenGL REQUIRED)
include_directories(
.
${OPENGL_INCLUDE_DIRS}
)
set(VIEWER_SOURCE_FILES
#${MACOS_ICON}
win.rc
include/ROMParser.h
include/ViewerWindow.h
src/ViewerWindow.cpp
src/viewer_main.cpp
)
# Add the main application
add_executable(ir-tracking-app ${VIEWER_SOURCE_FILES})
# if(APPLE)
# set_target_properties(ir-tracking-app PROPERTIES
# MACOSX_BUNDLE TRUE
# MACOSX_BUNDLE_ICON_FILE app_icon.icns
# RESOURCE "${MACOS_ICON}"
# )
# set_source_files_properties(${MACOS_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
# endif()
include_directories( ${IMGUI_DIR} )
include_directories( ${IMGUI_DIR}/backends)
include_directories( ${OPENGL_INCLUDE_DIR} )
include_directories( ${GLFW_INCLUDE_DIR} )
# Specify C++17 for the main application
target_compile_features(ir-tracking-app PUBLIC cxx_std_17)
target_link_libraries(ir-tracking-app PRIVATE
IRToolTracking
glfw::glfw
imgui::imgui
${OPENGL_LIBRARIES}
nanosockets
nfd
json)
if(WIN32)
set(DYNLIB_TARGET ir-tracking-app)
set(DYNLIB_DEST "$<TARGET_FILE_DIR:${DYNLIB_TARGET}>")
message("Copying k4a library to build folder: ${K4A_DYNLIB}")
add_custom_command(TARGET ${DYNLIB_TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${K4A_DYNLIB}"
"${DYNLIB_DEST}"
)
message("Copying k4a library to build folder: ${K4ARECORD_DYNLIB}")
add_custom_command(TARGET ${DYNLIB_TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${K4ARECORD_DYNLIB}"
"${DYNLIB_DEST}"
)
message("Copying k4a library to build folder: ${DEPTHENGINE_DYNLIB}")
add_custom_command(TARGET ${DYNLIB_TARGET} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${DEPTHENGINE_DYNLIB}"
"${DYNLIB_DEST}"
)
endif()