-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
59 lines (44 loc) · 1.62 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
cmake_minimum_required(VERSION 3.0)
project(openxr-example)
if (POLICY CMP0072)
cmake_policy (SET CMP0072 NEW)
endif(POLICY CMP0072)
IF (WIN32)
SET(EXTRA_INCLUDES "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/GL")
ENDIF()
find_package(OpenGL REQUIRED)
IF (WIN32)
find_package(SDL2 REQUIRED)
ELSE()
INCLUDE(FindPkgConfig)
PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2)
find_package(X11 REQUIRED)
SET(LINUX_LIBS "Xrandr ${X11_LIBRARIES}" m)
ENDIF()
add_executable(openxr-example main.c)
# First try openxr.pc from OpenXR SDK
include(FindPkgConfig)
pkg_search_module(OPENXR openxr)
if (OPENXR_FOUND)
MESSAGE("OpenXR found with pkg-config")
target_link_libraries(openxr-example PRIVATE ${OPENXR_LIBRARIES})
# Second, try OpenXRConfig.cmake from OpenXR SDK
else()
MESSAGE("OpenXR not found with pkg-config, trying cmake script")
# current issue in upstream OpenXR cmake files requires us to find Threads on our own
find_package(Threads REQUIRED)
find_package(OpenXR REQUIRED)
if (NOT OpenXR_FOUND)
MESSAGE(FATAL_ERROR "OpenXR not found!")
endif()
target_include_directories(openxr-example PRIVATE ${OpenXR_INCLUDE_DIR})
target_link_libraries(openxr-example PRIVATE OpenXR::openxr_loader)
endif()
target_link_libraries(openxr-example PRIVATE ${LINUX_LIBS} ${OPENGL_LIBRARIES} ${SDL2_LIBRARIES})
target_include_directories(openxr-example PRIVATE ${SDL2_INCLUDE_DIRS} ${EXTRA_INCLUDES})
if(MSVC)
target_compile_options(openxr-example PRIVATE /W4 /WX)
else(MSVC)
target_compile_options(openxr-example PRIVATE -pedantic -Wall -Wextra -Wno-unused-parameter)
endif(MSVC)
install(TARGETS openxr-example RUNTIME DESTINATION bin)