forked from knorth55/vive_ros
-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
executable file
·147 lines (123 loc) · 3.01 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
cmake_minimum_required(VERSION 2.8.3)
project(vive_ros)
## set definition, path, compileflags
add_definitions(-DLINUX -DLINUX64 -DPOSIX)
set(OPENVR "$ENV{HOME}/libraries/openvr")
add_definitions(-DOPENVR_PATH="${OPENVR}") ## for source code to get sample textures and shader files path
set(THIRDPARTY_DIR ${OPENVR}/samples/thirdparty)
set(SHARED_SRC_DIR ${OPENVR}/samples/shared)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -include ${SHARED_SRC_DIR}/compat.h")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -pedantic -g")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
## find openvr
find_library(OPENVR_LIBRARIES
NAMES
openvr_api
PATHS
${OPENVR}/bin
${OPENVR}/lib
PATH_SUFFIXES
linux64
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)
set(OPENVR_INCLUDE_DIR ${OPENVR}/headers ${OPENVR}/samples)
## find SDL
set(SDL_REQUIRED_LIBRARIES SDL2)
foreach(lib ${SDL_REQUIRED_LIBRARIES})
find_library(${lib}_LIBRARY
NAMES
${lib}
PATHS
${THIRDPARTY_DIR}/sdl2-2.0.3/bin
PATH_SUFFIXES
linux64
)
list(APPEND SDL2_LIBRARIES ${${lib}_LIBRARY})
endforeach()
set(SDL2_INCLUDE_DIR ${THIRDPARTY_DIR}/sdl2-2.0.3/include)
## common src from openvr sample
file(GLOB SHARED_SRC_FILES
${SHARED_SRC_DIR}/*.cpp
${SHARED_SRC_DIR}/*.h
)
## find opengl (OpenGL specific)
find_package(OpenGL REQUIRED)
find_package(GLEW 1.11 REQUIRED)
## find vulkan (vulkan specific)
find_library(VULKAN_LIBRARY
NAMES
vulkan-1
vulkan
PATHS
${THIRDPARTY_DIR}/vulkan-1.0.49.0/lib
PATH_SUFFIXES
linux64
NO_DEFAULT_PATH
)
set(VULKAN_INCLUDE_DIR ${THIRDPARTY_DIR}/vulkan-1.0.49.0/include)
## add include path
include_directories(
${SDL2_INCLUDE_DIR}
${OPENVR_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR} ## (OpenGL specific)
${GLEW_INCLUDE_DIR} ## (OpenGL specific)
${VULKAN_INCLUDE_DIR} ## (Vulkan specific)
)
## Find catkin macros and libraries
find_package(catkin REQUIRED COMPONENTS
roscpp
tf
std_srvs
std_msgs
geometry_msgs
cv_bridge
image_transport
message_generation
)
set(CMAKE_BUILD_TYPE "Release")
add_message_files(
FILES
devices.msg
)
add_service_files(
FILES
list_devices.srv
)
generate_messages(DEPENDENCIES std_msgs)
catkin_package(CATKIN_DEPENDS message_runtime)
include_directories(
include
${catkin_INCLUDE_DIRS}
)
add_executable(vive_hmd
${SHARED_SRC_FILES}
src/vive_hmd.cpp
src/vr_interface.cpp
)
add_executable(vive_ctrl
${SHARED_SRC_FILES}
src/vive_ctrl.cpp
src/vr_interface.cpp
)
## link all
target_link_libraries(vive_hmd
${catkin_LIBRARIES}
${OPENGL_LIBRARIES} ## (OpenGL specific)
${GLEW_LIBRARIES} ## (OpenGL specific)
${VULKAN_LIBRARY} ## (Vulkan specific)
${SDL2_LIBRARIES}
${OPENVR_LIBRARIES}
${CMAKE_DL_LIBS}
${EXTRA_LIBS}
)
target_link_libraries(vive_ctrl
${catkin_LIBRARIES}
${OPENGL_LIBRARIES} ## (OpenGL specific)
${GLEW_LIBRARIES} ## (OpenGL specific)
${VULKAN_LIBRARY} ## (Vulkan specific)
${SDL2_LIBRARIES}
${OPENVR_LIBRARIES}
${CMAKE_DL_LIBS}
${EXTRA_LIBS}
)