forked from OpenHMD/OpenHMD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
172 lines (144 loc) · 5.4 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
cmake_minimum_required(VERSION 2.8)
project(openhmd C CXX)
set(CMAKE_C_FLAGS "-std=c99")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(LIB_VERSION_MAJOR 0)
set(LIB_VERSION_MINOR 1)
set(LIB_VERSION_PATCH 0)
set(LIB_VERSION_STRING ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
include_directories(${CMAKE_CURRENT_LIST_DIR}/include)
if (MSVC)
# Add the "lib" prefix for generated .lib outputs.
set(LIB_PREFIX lib)
else (MSVC)
# When building with "make", "lib" prefix will be added automatically by
# the build tool.
set(LIB_PREFIX)
endif (MSVC)
#source files set just for Android
set(openhmd_source_files
${CMAKE_CURRENT_LIST_DIR}/src/openhmd.c
${CMAKE_CURRENT_LIST_DIR}/src/platform-win32.c
${CMAKE_CURRENT_LIST_DIR}/src/drv_dummy/dummy.c
${CMAKE_CURRENT_LIST_DIR}/src/omath.c
${CMAKE_CURRENT_LIST_DIR}/src/platform-posix.c
${CMAKE_CURRENT_LIST_DIR}/src/fusion.c
${CMAKE_CURRENT_LIST_DIR}/src/shaders.c
)
OPTION(OPENHMD_DRIVER_OCULUS_RIFT "Oculus Rift DK1 and DK2" ON)
OPTION(OPENHMD_DRIVER_DEEPOON "Deepoon E2" ON)
OPTION(OPENHMD_DRIVER_WMR "Windows Mixed Reality" ON)
OPTION(OPENHMD_DRIVER_PSVR "Sony PSVR" ON)
OPTION(OPENHMD_DRIVER_HTC_VIVE "HTC Vive" ON)
OPTION(OPENHMD_DRIVER_NOLO "NOLO VR CV1" ON)
OPTION(OPENHMD_DRIVER_XGVR "3Glasses HMD" ON)
OPTION(OPENHMD_DRIVER_EXTERNAL "External sensor driver" ON)
OPTION(OPENHMD_DRIVER_ANDROID "General Android driver" OFF)
OPTION(OPENHMD_EXAMPLE_SIMPLE "Simple test binary" ON)
OPTION(OPENHMD_EXAMPLE_SDL "SDL OpenGL test (outdated)" OFF)
if(OPENHMD_DRIVER_OCULUS_RIFT)
set(openhmd_source_files ${openhmd_source_files}
${CMAKE_CURRENT_LIST_DIR}/src/drv_oculus_rift/rift.c
${CMAKE_CURRENT_LIST_DIR}/src/drv_oculus_rift/packet.c
)
add_definitions(-DDRIVER_OCULUS_RIFT)
find_package(HIDAPI REQUIRED)
include_directories(${HIDAPI_INCLUDE_DIRS})
set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
endif(OPENHMD_DRIVER_OCULUS_RIFT)
if(OPENHMD_DRIVER_DEEPOON)
set(openhmd_source_files ${openhmd_source_files}
${CMAKE_CURRENT_LIST_DIR}/src/drv_deepoon/deepoon.c
${CMAKE_CURRENT_LIST_DIR}/src/drv_deepoon/packet.c
)
add_definitions(-DDRIVER_DEEPOON)
find_package(HIDAPI REQUIRED)
include_directories(${HIDAPI_INCLUDE_DIRS})
set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
endif(OPENHMD_DRIVER_DEEPOON)
if(OPENHMD_DRIVER_WMR)
set(openhmd_source_files ${openhmd_source_files}
${CMAKE_CURRENT_LIST_DIR}/src/drv_wmr/wmr.c
${CMAKE_CURRENT_LIST_DIR}/src/drv_wmr/packet.c
)
add_definitions(-DDRIVER_WMR)
find_package(HIDAPI REQUIRED)
include_directories(${HIDAPI_INCLUDE_DIRS})
set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
endif(OPENHMD_DRIVER_WMR)
if(OPENHMD_DRIVER_PSVR)
set(openhmd_source_files ${openhmd_source_files}
${CMAKE_CURRENT_LIST_DIR}/src/drv_psvr/psvr.c
${CMAKE_CURRENT_LIST_DIR}/src/drv_psvr/packet.c
)
add_definitions(-DDRIVER_PSVR)
find_package(HIDAPI REQUIRED)
include_directories(${HIDAPI_INCLUDE_DIRS})
set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
endif(OPENHMD_DRIVER_PSVR)
if(OPENHMD_DRIVER_HTC_VIVE)
set(openhmd_source_files ${openhmd_source_files}
${CMAKE_CURRENT_LIST_DIR}/src/drv_htc_vive/vive.c
${CMAKE_CURRENT_LIST_DIR}/src/drv_htc_vive/packet.c
#${CMAKE_CURRENT_LIST_DIR}/src/ext_deps/miniz.c
${CMAKE_CURRENT_LIST_DIR}/src/ext_deps/nxjson.c
)
add_definitions(-DDRIVER_HTC_VIVE)
find_package(HIDAPI REQUIRED)
include_directories(${HIDAPI_INCLUDE_DIRS})
set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
endif(OPENHMD_DRIVER_HTC_VIVE)
if(OPENHMD_DRIVER_NOLO)
set(openhmd_source_files ${openhmd_source_files}
${CMAKE_CURRENT_LIST_DIR}/src/drv_nolo/nolo.c
${CMAKE_CURRENT_LIST_DIR}/src/drv_nolo/packet.c
)
add_definitions(-DDRIVER_NOLO)
find_package(HIDAPI REQUIRED)
include_directories(${HIDAPI_INCLUDE_DIRS})
set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
endif(OPENHMD_DRIVER_NOLO)
if(OPENHMD_DRIVER_XGVR)
set(openhmd_source_files ${openhmd_source_files}
${CMAKE_CURRENT_LIST_DIR}/src/drv_3glasses/xgvr.c
${CMAKE_CURRENT_LIST_DIR}/src/drv_3glasses/packet.c
)
add_definitions(-DDRIVER_XGVR)
find_package(HIDAPI REQUIRED)
include_directories(${HIDAPI_INCLUDE_DIRS})
set(LIBS ${LIBS} ${HIDAPI_LIBRARIES})
endif(OPENHMD_DRIVER_XGVR)
if (OPENHMD_DRIVER_EXTERNAL)
set(openhmd_source_files ${openhmd_source_files}
${CMAKE_CURRENT_LIST_DIR}/src/drv_external/external.c
)
add_definitions(-DDRIVER_EXTERNAL)
endif(OPENHMD_DRIVER_EXTERNAL)
if (OPENHMD_DRIVER_ANDROID)
set(openhmd_source_files ${openhmd_source_files}
${CMAKE_CURRENT_LIST_DIR}/src/drv_android/android.c
)
add_definitions(-DDRIVER_ANDROID)
endif(OPENHMD_DRIVER_ANDROID)
if (OPENHMD_EXAMPLE_SIMPLE)
add_subdirectory(./examples/simple)
endif(OPENHMD_EXAMPLE_SIMPLE)
if (OPENHMD_EXAMPLE_SDL)
find_package(SDL2 REQUIRED)
find_package(GLEW REQUIRED)
find_package(OpenGL REQUIRED)
add_subdirectory(./examples/opengl)
endif (OPENHMD_EXAMPLE_SDL)
if (UNIX)
set(LIBS ${LIBS} rt pthread)
endif (UNIX)
link_libraries(${LIBS})
add_library(openhmd-shared SHARED ${openhmd_source_files})
SET_TARGET_PROPERTIES(openhmd-shared PROPERTIES OUTPUT_NAME openhmd CLEAN_DIRECT_OUTPUT 1 VERSION ${LIB_VERSION_STRING} SOVERSION ${LIB_VERSION_MAJOR})
add_library(openhmd-static STATIC ${openhmd_source_files})
SET_TARGET_PROPERTIES(openhmd-static PROPERTIES OUTPUT_NAME openhmd CLEAN_DIRECT_OUTPUT 1)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_DIR}/)
#install properties
install (TARGETS openhmd-shared openhmd-static DESTINATION lib)
install (FILES include/openhmd.h DESTINATION include)