forked from ivlab/VRBase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
196 lines (161 loc) · 7.36 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# ================================================================================
#
# This file is part of the VRBase project.
#
# File: CMakeLists.txt
#
# Original Author(s) of this File:
# Dan Orban, 2015, University of Minnesota
#
# Author(s) of Significant Updates/Modifications to the File:
# ...
#
# -----------------------------------------------------------------------------------
# Copyright (c) 2015 Regents of the University of Minnesota
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice, this
# list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# * The name of the University of Minnesota, nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# ================================================================================
# CMakeLists files in this project can refer to the root source directory of the
cmake_minimum_required (VERSION 2.8.2)
project (VRBase)
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
#set (CMAKE_INSTALL_PREFIX "${${PROJECT_NAME}_SOURCE_DIR}/build/install" CACHE PATH "default install path" FORCE )
set (CMAKE_INSTALL_PREFIX "$ENV{MinVR_DIR}" CACHE PATH "default install path" FORCE )
endif()
# Use the root of the MinVR tree as an include dir, then include headers like this:
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
############################################################
#Start of library detection
#Any libraries outside of your source should have a corresponding
#find_package method should be used here.
############################################################
set(MinVR_DIR $ENV{MinVR_DIR})
find_package(MinVR COMPONENTS MVRCore AppKit_GLFW REQUIRED)
include_directories(${MinVR_INCLUDE_DIRS})
include(ExternalProject)
message(${${PROJECT_NAME}_INSTALL_PREFIX} ${PROJECT_NAME})
set(plugin_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/PluginFW")
set(plugin_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${plugin_INSTALL_DIR})
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(GIT_EXECUTABLE "C:/Program Files (x86)/Git/bin/git.exe")
endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
ExternalProject_add(PluginFW
PREFIX "${CMAKE_SOURCE_DIR}/dependencies/${CMAKE_BUILD_TYPE}/PluginFW"
GIT_REPOSITORY https://github.com/ivlab/PluginFramework.git
GIT_TAG master
INSTALL_DIR "${plugin_INSTALL_DIR}"
CMAKE_ARGS "${plugin_CMAKE_ARGS}"
PATCH_COMMAND ""
UPDATE_COMMAND ""
)
############################################################
#End external library searching
############################################################
############################################################
#OS Specific flags should go here
############################################################
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++11")
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
find_library(COCOA_LIB Cocoa)
find_library(IOKIT_LIB IOKit)
find_library(CORE_FOUNDATION_FRAMEWORK CoreFoundation)
find_library(CORE_VIDEO_FRAMEWORK CoreVideo)
set(LIBS_ALL ${LIBS_ALL} ${COCOA_LIB} ${IOKIT_LIB} ${CORE_FOUNDATION_FRAMEWORK} ${CORE_VIDEO_FRAMEWORK})
message(STATUS "${CORE_VIDEO_FRAMEWORK}")
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
# Linux specific code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
set(Lib_Config "none")
set(MinVR_LIBS)
FOREACH (LIB ${MinVR_LIBRARIES})
if("${LIB}" STREQUAL "debug" OR "${LIB}" STREQUAL "optimized")
set(Lib_Config ${LIB})
else()
list(APPEND MinVR_LIBS ${LIB})
if("${Lib_Config}" STREQUAL "debug" OR "${Lib_Config}" STREQUAL "optimized")
list(APPEND MinVR_LIBS ${Lib_Config})
endif()
set(Lib_Config none)
endif()
ENDFOREACH(LIB)
LIST(REVERSE MinVR_LIBS)
set(MinVR_LIBRARIES)
FOREACH (LIB ${MinVR_LIBS})
list(APPEND MinVR_LIBRARIES ${LIB})
ENDFOREACH(LIB)
find_package(Threads)
find_package(X11)
set(LIBS_ALL ${LIBS_ALL} ${CMAKE_THREAD_LIBS_INIT} rt Xrandr Xxf86vm Xi m dl ${X11_LIBRARIES})
endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
# Windows specific code
endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
if (MSVC)
# Windows specific code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
endif (MSVC)
############################################################
# Add POSTFIX info
############################################################
# Let's follow the convention of putting all of the libs in "build/lib" and all
# of the exes in "build/bin". To distingusih between debugging, release, and
# other builds, we'll add a postfix to the name of the lib or exe that we generate.
set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_RELEASE_POSTFIX "")
set(CMAKE_RELWITHDEBINFO_POSTFIX "rd")
set(CMAKE_MINSIZEREL_POSTFIX "s")
if (CMAKE_BUILD_TYPE MATCHES "Release")
set(CMAKE_BUILD_POSTFIX "${CMAKE_RELEASE_POSTFIX}")
elseif (CMAKE_BUILD_TYPE MATCHES "MinSizeRel")
set(CMAKE_BUILD_POSTFIX "${CMAKE_MINSIZEREL_POSTFIX}")
elseif (CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
set(CMAKE_BUILD_POSTFIX "${CMAKE_RELWITHDEBINFO_POSTFIX}")
elseif (CMAKE_BUILD_TYPE MATCHES "Debug")
set(CMAKE_BUILD_POSTFIX "${CMAKE_DEBUG_POSTFIX}")
else()
set(CMAKE_BUILD_POSTFIX "")
endif()
make_directory(${CMAKE_BINARY_DIR}/lib)
make_directory(${CMAKE_BINARY_DIR}/bin)
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)
foreach (CONF ${CMAKE_CONFIGURATION_TYPES})
string (TOUPPER ${CONF} CONF)
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CONF} ${CMAKE_BINARY_DIR}/bin)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CONF} ${CMAKE_BINARY_DIR}/lib)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CONF} ${CMAKE_BINARY_DIR}/lib)
endforeach(CONF CMAKE_CONFIGURATION_TYPES)
# Recurse into the following subdirs to build the core MinVR set of libraries:
# (Uncomment the lines below as we add .cpp files to those directories.)
add_subdirectory (vrbase)
# Now, build some programs, such as tests, that depend upon the MinVR libraries:
#add_subdirectory (tests/app)