CMakeLists.txt 2.29 KB
Newer Older
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
1
2
3
4
5
6
7
8
# Copyright 2018-2019, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0

cmake_minimum_required(VERSION 3.10.0)
project(XRT VERSION 0.1.0)

# CMake 3.11 introduced CMP0072 - Prefer GLVND
if(POLICY CMP0072)
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
9
	cmake_policy(SET CMP0072 NEW)
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
10
11
12
endif()

option(OPENXR_USE_LOADER "Application uses loader" ON)
13
option(VULKAN_ENABLE_VALIDATION "Enable Vulkan validation for Compositor" ON)
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
14
15
16
17
18
19
20
21
22
23

###
# Dependencies
###
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(CMakeDependentOption)
include(SPIR-V)

find_package(Eigen3 REQUIRED)
find_package(Vulkan REQUIRED)
24
find_package(OpenGL REQUIRED COMPONENTS GLX)
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
25
find_package(HIDAPI)
Ryan Pavlik's avatar
Ryan Pavlik committed
26
find_package(OpenHMD)
27
find_package(OpenCV)
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
28

29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Export OpenCV definition if found
if(OpenCV_FOUND)
	add_definitions(-DXRT_HAVE_OPENCV)
endif()

# @TODO Turn into a find_package LIBUSB-1.0 file.
pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
add_definitions(-DXRT_HAVE_LIBUSB)

# @TODO Turn into a find_package LIBUVC file.
pkg_check_modules(LIBUVC libuvc)
if(LIBUVC_FOUND)
	add_definitions(-DXRT_HAVE_LIBUVC)
endif()

# @TODO Turn into a find_package FFMPEG file.
pkg_check_modules(FFMPEG libavcodec)
if(FFMPEG_FOUND)
	add_definitions(-DXRT_HAVE_FFMPEG)
endif()
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
49
50

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
51
52
53
	find_package(X11)
	find_package(Wayland)
	pkg_check_modules(XCB xcb xcb-randr)
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
54
55
56
endif()

cmake_dependent_option(BUILD_WITH_OPENHMD "Enable OpenHMD driver" ON "OPENHMD_FOUND" OFF)
57
cmake_dependent_option(BUILD_WITH_HIDAPI "Enable HIDAPI-based OSVR HDK driver" ON "HIDAPI_FOUND" OFF)
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
58
59
60
61
cmake_dependent_option(BUILD_WITH_WAYLAND "Enable Wayland support" ON "WAYLAND_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_XLIB "Enable xlib support" ON "X11_FOUND" OFF)
cmake_dependent_option(BUILD_WITH_OPENGL "Enable OpenGL Graphics API support?" ON "OPENGL_FOUND" OFF)

62
if(NOT BUILD_WITH_OPENHMD AND NOT BUILD_WITH_HIDAPI)
Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
63
	message(FATAL_ERROR "You must enable at least one driver: either provide OpenHMD and enable BUILD_WITH_OPENHMD (for a variety of devices via OpenHMD), or provide HIDAPI and enable BUILD_WITH_HIDAPI (for the HDK driver)")
64
65
endif()

Jakob Bornecrantz's avatar
Jakob Bornecrantz committed
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

###
# Flags
###

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic -Wall -Wextra -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter")


###
# Decend into madness.
###

add_subdirectory(src)
add_subdirectory(doc)