-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
129 lines (95 loc) · 3.24 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
120
121
122
123
124
125
126
127
128
129
cmake_minimum_required(VERSION 3.0.2)
project(OculusVTKBoilerplate)
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
include("FindOculusSDK.cmake")
set(EXTERNAL_DIR "${CMAKE_SOURCE_DIR}/external")
set(RESOURCES_DIR "${CMAKE_SOURCE_DIR}/resources")
set(TEMPLATES_DIR "${CMAKE_SOURCE_DIR}/templates")
set(INCLUDES_DIR "${CMAKE_SOURCE_DIR}/includes")
set(GLFW_SOURCE_DIR "${EXTERNAL_DIR}/glfw")
set(GLM_SOURCE_DIR "${EXTERNAL_DIR}/glm")
set(GLEW_SOURCE_DIR "${EXTERNAL_DIR}/glew")
if(EXISTS "${GLFW_SOURCE_DIR}/src/CMakeLists.txt")
else()
file(REMOVE_RECURSE ${GLFW_SOURCE_DIR})
execute_process(COMMAND git clone https://github.com/glfw/glfw.git ${GLFW_SOURCE_DIR})
endif()
if(EXISTS "${GLM_SOURCE_DIR}/CMakeLists.txt")
else()
file(REMOVE_RECURSE ${GLM_SOURCE_DIR})
execute_process(COMMAND git clone https://github.com/g-truc/glm.git ${GLM_SOURCE_DIR})
endif()
if(EXISTS "${GLEW_SOURCE_DIR}/build/cmake/CMakeLists.txt")
else()
file(REMOVE_RECURSE ${GLEW_SOURCE_DIR})
message(STATUS "Downloading glew")
file(DOWNLOAD "https://sourceforge.net/projects/glew/files/glew/1.13.0/glew-1.13.0.tgz/download"
"${CMAKE_SOURCE_DIR}/glew.tgz"
STATUS Status
SHOW_PROGRESS
)
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xfz "${CMAKE_SOURCE_DIR}/glew.tgz"
WORKING_DIRECTORY ${EXTERNAL_DIR}
RESULT_VARIABLE Result
)
if(NOT Result EQUAL "0")
message(FATAL_ERROR "Failed extracting glew")
endif()
file(RENAME "${EXTERNAL_DIR}/glew-1.13.0" "${GLEW_SOURCE_DIR}")
file(REMOVE "${CMAKE_SOURCE_DIR}/glew.tgz")
endif()
# OpenGL
FIND_PACKAGE(OpenGL REQUIRED)
if(NOT OPENGL_FOUND)
message(ERROR " OPENGL not found!")
endif(NOT OPENGL_FOUND)
# Check that Oculus SDK match the desired version
IF(NOT OCULUS_SDK_VERSION VERSION_EQUAL 0.8.0 AND
NOT OCULUS_SDK_VERSION VERSION_GREATER 0.8.0)
MESSAGE(FATAL_ERROR "ERROR: This library required SDK version 1.3.0 or later!")
ENDIF()
# Building only the GLFW lib
set(BUILD_SHARED_LIBS OFF CACHE BOOL "")
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "")
set(GLFW_BUILD_TESTS OFF CACHE BOOL "")
set(GLFW_BUILD_DOCS OFF CACHE BOOL "")
set(GLFW_INSTALL OFF CACHE BOOL "")
add_subdirectory(${GLFW_SOURCE_DIR} ${GLEW_SOURCE_DIR})
include_directories(
${GLFW_SOURCE_DIR}/include
${GLFW_SOURCE_DIR}/deps
${GLM_SOURCE_DIR}
${GLEW_SOURCE_DIR}/include
${OCULUS_SDK_INCLUDE_DIRS}
includes
)
add_library(glew STATIC
${GLEW_SOURCE_DIR}/src/glew.c
${GLEW_SOURCE_DIR}/include
)
target_link_libraries(glew ${GLFW_LIBRARIES} ${OPENGL_LIBRARIES})
add_definitions( -DGLEW_STATIC)
configure_file( "${TEMPLATES_DIR}/paths.h.in" "${INCLUDES_DIR}/paths.h" )
set(SOURCES
main.cxx
VTKModel.cxx
VTKGLBuffer.cxx
OVRHelper.cxx
includes/VTKModel.h
includes/OVRHelper.h
includes/VTKGLBuffer.h
includes/definitions.h
includes/OVRBuffers.h
includes/paths.h
)
add_executable(OculusVTKBoilerplate ${SOURCES})
target_link_libraries(
OculusVTKBoilerplate
glfw
${GLFW_LIBRARIES}
glew
${OCULUS_SDK_LIBRARIES}
${VTK_LIBRARIES}
)