forked from collabora/OSVR-Vive-Libre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
119 lines (95 loc) · 3.11 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
#
# Libre HTC Vive plugin for OSVR
#
cmake_minimum_required(VERSION 3.1.0)
project(org_osvr_Vive_Libre)
set (org_osvr_Vive_Libre_VERSION_MAJOR 0)
set (org_osvr_Vive_Libre_VERSION_MINOR 2)
include(GNUInstallDirs)
include(FindPkgConfig)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(osvr REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(OpenCV REQUIRED)
PKG_CHECK_MODULES (LIBUSB REQUIRED libusb-1.0)
PKG_CHECK_MODULES (ZLIB REQUIRED zlib)
PKG_CHECK_MODULES (JSONCPP REQUIRED jsoncpp)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
function(add_cxxflag FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FLAG}" PARENT_SCOPE)
endfunction(add_cxxflag)
# enable some gcc warnings
add_cxxflag("-Wall -Wno-long-long -Wextra -Wundef -Woverflow")
add_cxxflag("-Woverloaded-virtual -Wformat=2 -Wpointer-arith -Wcast-qual")
add_cxxflag("-Wredundant-decls")
#add_cxxflag("-Wmissing-declarations")
include_directories(
${EIGEN3_INCLUDE_DIR}
${LIBUSB_INCLUDE_DIRS}
${JSONCPP_INCLUDE_DIRS}
src)
# Build the plugin
osvr_convert_json(org_osvr_Vive_Libre_json
config/org_osvr_Vive_Libre.json
"${CMAKE_BINARY_DIR}/org_osvr_Vive_Libre_json.h")
set(SOURCES
src/vl_synchronous.h
src/vl_hid_reports.h
src/vl_driver.cpp
src/vl_driver.h
src/vl_enums.h
src/vl_fusion.cpp
src/vl_fusion.h
src/vl_magic.h
src/vl_messages.h
src/vl_config.h
src/vl_config.cpp
src/vl_math.h
src/vl_light.cpp
src/vl_light.h
src/vl_log.h
src/vl_log.cpp)
add_library(vive-libre SHARED ${SOURCES})
target_link_libraries(vive-libre
${LIBUSB_LIBRARIES}
${ZLIB_LIBRARIES}
${JSONCPP_LIBRARIES}
${OpenCV_LIBRARIES})
set(OSVR_PLUGIN_SOURCES
src/org_osvr_Vive_Libre.cpp
${SOURCES}
"${CMAKE_BINARY_DIR}/org_osvr_Vive_Libre_json.h")
osvr_add_plugin(org_osvr_Vive_Libre ${OSVR_PLUGIN_SOURCES})
target_link_libraries(org_osvr_Vive_Libre
osvr::osvrPluginKit
osvr::osvrCommon
osvr::osvrUtil
${LIBUSB_LIBRARIES}
${ZLIB_LIBRARIES}
vive-libre)
# Install files for the plugin.
install(
FILES
config/osvr_server_config.vive_libre.sample.json config/HTC_Vive_meshdata.json
DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/osvrcore/sample-configs)
install(TARGETS vive-libre DESTINATION ${CMAKE_INSTALL_LIBDIR})
# Build tool
add_executable(vivectl tools/vivectl.cpp)
target_link_libraries(vivectl vive-libre)
install(TARGETS vivectl DESTINATION ${CMAKE_INSTALL_BINDIR})
# tests
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
#add_executable(test-minimal-hid EXCLUDE_FROM_ALL tests/minimal-hid.cpp)
#target_link_libraries(test-minimal-hid ${LIBUSB_LIBRARIES})
#add_test(some-test bin/test-minimal-hid)
#add_dependencies(check test-minimal-hid)
add_executable(test-hid-enumerate EXCLUDE_FROM_ALL tests/hid-enumerate.cpp)
target_link_libraries(test-hid-enumerate ${LIBUSB_LIBRARIES})
add_test(hid bin/test-hid-enumerate)
add_dependencies(check test-hid-enumerate)