forked from bjornblissing/osgoculusviewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
116 lines (95 loc) · 4 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT TRUE)
SET(CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES FALSE)
PROJECT(OsgOculusViewer)
SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Check if we are doing out of source builds
STRING(COMPARE NOTEQUAL ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR} CMAKE_OUT_OF_SOURCE_BUILD)
# Relative paths can be trouble when doing out of source builds
IF(CMAKE_OUT_OF_SOURCE_BUILD)
SET(DEFAULT_RELATIVE_PATHS OFF)
ELSE()
SET(DEFAULT_RELATIVE_PATHS ON)
ENDIF()
# Show relative paths options
OPTION(CMAKE_USE_RELATIVE_PATHS "If true, cmake will use relative paths in makefiles and projects." ${DEFAULT_RELATIVE_PATHS})
MARK_AS_ADVANCED(CMAKE_USE_RELATIVE_PATHS)
# Build example viewers
OPTION(BUILD_EXAMPLES "Enable to build viewer examples" ON)
IF (WIN32)
# Path to find OpenSceneGraph
SET(OSG_DIR $ENV{OSG_DIR} CACHE PATH "Path where to find the OpenSceneGraph")
IF(NOT OSG_DIR)
MESSAGE(FATAL_ERROR "Error: OpenSceneGraph not found.")
ENDIF(NOT OSG_DIR)
# Where to find OpenSceneGraph third party dependencies
SET(OSG_THIRD_PARTY_DIR $ENV{OSG_THIRD_PARTY_DIR} CACHE PATH "Path where to find the OpenSceneGraph third party dependencies")
IF(NOT OSG_THIRD_PARTY_DIR)
MESSAGE(FATAL_ERROR "Error: OpenSceneGraph 3rd Party Directory not found.")
ENDIF(NOT OSG_THIRD_PARTY_DIR)
# Where to find Oculus SDK
SET(OCULUS_SDK_ROOT_DIR $ENV{OCULUS_SDK_ROOT_DIR} CACHE PATH "Path where to find the Oculus SDK")
IF(NOT OCULUS_SDK_ROOT_DIR)
MESSAGE(FATAL_ERROR "Error: Oculus SDK not found.")
ENDIF(NOT OCULUS_SDK_ROOT_DIR)
ENDIF(WIN32)
#Solution
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
#######################################
# Library files
#######################################
FIND_PACKAGE( OpenGL REQUIRED )
FIND_PACKAGE( OpenSceneGraph REQUIRED osgViewer osgDB osgGA osgUtil)
FIND_PACKAGE( OculusSDK REQUIRED)
IF(CMAKE_CONFIGURATION_TYPES)
IF(OCULUS_SDK_LIBRARY_DEBUG_AVAILABLE)
SET(CMAKE_CONFIGURATION_TYPES Debug Release)
ELSE()
SET(CMAKE_CONFIGURATION_TYPES Release)
ENDIF()
SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
"Reset the configurations to what we need"
FORCE)
MARK_AS_ADVANCED(CMAKE_CONFIGURATION_TYPES)
ENDIF()
# Check that Oculus SDK match the desired version
IF(NOT OCULUS_SDK_VERSION VERSION_EQUAL 1.3.0 AND
NOT OCULUS_SDK_VERSION VERSION_GREATER 1.3.0)
MESSAGE(FATAL_ERROR "ERROR: This library required SDK version 1.3.0 or later!")
ENDIF()
INCLUDE_DIRECTORIES(BEFORE
${OPENGL_INCLUDE_DIR}
${OPENSCENEGRAPH_INCLUDE_DIR}
${OCULUS_SDK_INCLUDE_DIRS}
)
IF(VISUAL_STUDIO_EXPRESS)
INCLUDE_DIRECTORIES(BEFORE
${ATL_INCLUDE_DIR}
)
ENDIF(VISUAL_STUDIO_EXPRESS)
###############################################################################
# Compiler Options
################################################################################
IF(MSVC)
# Make sure we use minimal windows.h library without min max macros
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"WIN32_LEAN_AND_MEAN\"")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D \"NOMINMAX\"")
# Use Link Time Code Generation
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG")
OPTION(BUILD_MULTI_PROCESSOR_COMPILATION "Use multiple processors when compiling" ON)
MARK_AS_ADVANCED(BUILD_MULTI_PROCESSOR_COMPILATION)
IF(BUILD_MULTI_PROCESSOR_COMPILATION)
# Set multi processor build
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
ENDIF(BUILD_MULTI_PROCESSOR_COMPILATION)
# Set warnings to level 4
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
IF (WARNINGS_AS_ERRORS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
ENDIF (WARNINGS_AS_ERRORS)
ENDIF(MSVC)
###############################################################################
# Compile subdirectory
################################################################################
ADD_SUBDIRECTORY(src)