-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
61 lines (51 loc) · 1.71 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
cmake_minimum_required(VERSION 3.0.2)
project(ViveTrackerPosition)
set(OPENVR_DIR "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/openvr")
set(OPENVR_LIB_DIR "${OPENVR_DIR}/lib" "${OPENVR_DIR}/bin")
set(OPENVR_INCLUDE_DIR "${OPENVR_DIR}/headers")
# -----------------------------------------------------------------------------
# Taken from OpenVR CMakeLists.txt
## SYSTEM PROPERTIES ##
# If not set, determines the running 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.")
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()
## OpenVR API path
find_library(OPENVR_LIBRARIES
NAMES
openvr_api
PATHS
${OPENVR_DIR}/bin
${OPENVR_DIR}/lib
PATH_SUFFIXES
osx32
linux64
${WINDOWS_PATH_SUFFIXES}
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)
# -----------------------------------------------------------------------------
add_executable(ViveTrackerPos src/main.cpp)
target_include_directories(ViveTrackerPos PUBLIC ${OPENVR_INCLUDE_DIR})
target_link_libraries(ViveTrackerPos PUBLIC ${OPENVR_LIBRARIES})