forked from r57zone/OpenVR-ArduinoHMD
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
94 lines (78 loc) · 2.7 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
cmake_minimum_required(VERSION 3.7.1)
# This is your project name
set(TARGET_NAME air_glasses)
# This is the name that the binary will be called (driver_air_glasses)
set(DRIVER_NAME "driver_${TARGET_NAME}")
project(${TARGET_NAME})
set(OPENVR_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/modules/openvr)
set(AIR_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/modules/xrealAirLinuxDriver)
# If not set, determine the platform architecture
if (NOT PLATFORM)
if (CMAKE_SIZEOF_VOID_P MATCHES 8)
set(PLATFORM 64)
else ()
set(PLATFORM 32)
endif ()
endif ()
message(STATUS "Compilation set for ${PLATFORM}bits architectures.")
# OpenVR compatibility checking
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_definitions(-DLINUX -DPOSIX)
set(ARCH_TARGET linux64)
if (${PLATFORM} MATCHES 32)
message(WARNING "OpenVR x86 binaries not provided on GNU/Linux.")
endif ()
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_MACOSX_RPATH 0)
add_definitions(-DOSX -DPOSIX)
set(ARCH_TARGET osx32)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions(-D_WIN32)
set(ARCH_TARGET win${PLATFORM})
# Binaries path for thirdparties are not generics so we try to guess their suffixes.
set(WINDOWS_PATH_SUFFIXES win${PLATFORM} Win${PLATFORM} x${PLATFORM})
endif ()
find_package(json-c REQUIRED CONFIG)
add_subdirectory(${AIR_LIB_DIR}/interface_lib/hidapi)
add_subdirectory(${AIR_LIB_DIR}/interface_lib/Fusion)
find_library(OPENVR_LIBRARIES
NAMES
openvr_api
PATHS
${OPENVR_LIB_DIR}/bin
${OPENVR_LIB_DIR}/lib
PATH_SUFFIXES
osx${PLATFORM}
linux${PLATFORM}
win${PLATFORM}
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)
find_library(AIR_LIBRARIES
NAMES
xrealAirLibrary
PATHS
${AIR_LIB_DIR}/build/interface_lib
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)
set(OPENVR_INCLUDE_DIR ${OPENVR_LIB_DIR}/headers)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}/bin/${ARCH_TARGET}>)
add_library(${DRIVER_NAME} SHARED
src/driver_air_glasses.h
src/driver_air_glasses.cpp
)
target_link_libraries(${DRIVER_NAME} PRIVATE ${OPENVR_LIBRARIES})
target_include_directories(${DRIVER_NAME} PRIVATE ${OPENVR_INCLUDE_DIR})
target_link_libraries(${DRIVER_NAME} PRIVATE ${AIR_LIBRARIES})
target_link_libraries(${DRIVER_NAME}
PRIVATE json-c::json-c hidapi::hidapi Fusion
)
# Copy driver assets to output folder
add_custom_command(
TARGET ${DRIVER_NAME}
PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}
${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}
)