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 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273
|
#
# Copyright 2013 Pixar
#
# Licensed under the Apache License, Version 2.0 (the "Apache License")
# with the following modification; you may not use this file except in
# compliance with the Apache License and the following modification to it:
# Section 6. Trademarks. is deleted and replaced with:
#
# 6. Trademarks. This License does not grant permission to use the trade
# names, trademarks, service marks, or product names of the Licensor
# and its affiliates, except as required to comply with Section 4(c) of
# the License and to reproduce the content of the NOTICE file.
#
# You may obtain a copy of the Apache License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the Apache License with the above modification is
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#
# Try to find GLFW library and include path.
# Once done this will define
#
# GLFW_FOUND
# GLFW_INCLUDE_DIR
# GLFW_LIBRARIES
#
if(NOT NO_GLFW_X11)
set(GLFW_X11_INCLUDE_DIRS
"/usr/X11R6/include"
"/usr/include/X11"
)
set(GLFW_X11_LIB_DIRS
"/usr/X11R6/lib"
)
else()
set(GLFW_X11_INCLUDE_DIRS "")
set(GLFW_X11_LIB_DIRS "")
endif()
find_path( GLFW_INCLUDE_DIR
NAMES
GLFW/glfw3.h
HINTS
"${GLFW_LOCATION}/include"
"$ENV{GLFW_LOCATION}/include"
PATHS
"$ENV{PROGRAMFILES}/GLFW/include"
"${OPENGL_INCLUDE_DIR}"
/usr/openwin/share/include
/usr/openwin/include
"${GLFW_X11_INCLUDE_DIRS}"
/opt/graphics/OpenGL/include
/opt/graphics/OpenGL/contrib/libglfw
/usr/local/include
/usr/include/GL
/usr/include
DOC
"The directory where GLFW/glfw3.h resides"
)
#
# XXX: Do we still need to search for GL/glfw.h?
#
find_path( GLFW_INCLUDE_DIR
NAMES
GL/glfw.h
HINTS
"${GLFW_LOCATION}/include"
"$ENV{GLFW_LOCATION}/include"
PATHS
"$ENV{PROGRAMFILES}/GLFW/include"
"${OPENGL_INCLUDE_DIR}"
/usr/openwin/share/include
/usr/openwin/include
"${GLFW_X11_INCLUDE_DIRS}"
/opt/graphics/OpenGL/include
/opt/graphics/OpenGL/contrib/libglfw
/usr/local/include
/usr/include/GL
/usr/include
DOC
"The directory where GL/glfw.h resides"
)
if (WIN32)
if(CYGWIN)
find_library( GLFW_glfw_LIBRARY
NAMES
glfw32
HINTS
"${GLFW_LOCATION}/lib"
"${GLFW_LOCATION}/lib/x64"
"$ENV{GLFW_LOCATION}/lib"
PATHS
"${OPENGL_LIBRARY_DIR}"
/usr/lib
/usr/lib/w32api
/usr/local/lib
"${GLFW_X11_LIB_DIRS}"
DOC
"The GLFW library"
)
else()
find_library( GLFW_glfw_LIBRARY
NAMES
glfw32
glfw32s
glfw
glfw3
HINTS
"${GLFW_LOCATION}/lib"
"${GLFW_LOCATION}/lib/x64"
"${GLFW_LOCATION}/lib-msvc110"
"${GLFW_LOCATION}/lib-vc2012"
"$ENV{GLFW_LOCATION}/lib"
"$ENV{GLFW_LOCATION}/lib/x64"
"$ENV{GLFW_LOCATION}/lib-msvc110"
"$ENV{GLFW_LOCATION}/lib-vc2012"
PATHS
"$ENV{PROGRAMFILES}/GLFW/lib"
"${OPENGL_LIBRARY_DIR}"
DOC
"The GLFW library"
)
endif()
else ()
if (APPLE)
find_library( GLFW_glfw_LIBRARY glfw
NAMES
glfw
glfw3
HINTS
"${GLFW_LOCATION}/lib"
"${GLFW_LOCATION}/lib/cocoa"
"$ENV{GLFW_LOCATION}/lib"
"$ENV{GLFW_LOCATION}/lib/cocoa"
PATHS
/usr/local/lib
)
set(GLFW_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX")
set(GLFW_corevideo_LIBRARY "-framework CoreVideo" CACHE STRING "CoreVideo framework for OSX")
set(GLFW_iokit_LIBRARY "-framework IOKit" CACHE STRING "IOKit framework for OSX")
else ()
# (*)NIX
find_package(Threads REQUIRED)
if(NOT NO_GLFW_X11)
find_package(X11 REQUIRED)
if(NOT X11_Xrandr_FOUND)
message(FATAL_ERROR "Xrandr library not found - required for GLFW")
endif()
if(NOT X11_xf86vmode_FOUND)
message(FATAL_ERROR "xf86vmode library not found - required for GLFW")
endif()
if(NOT X11_Xcursor_FOUND)
message(FATAL_ERROR "Xcursor library not found - required for GLFW")
endif()
if(NOT X11_Xinerama_FOUND)
message(FATAL_ERROR "Xinerama library not found - required for GLFW")
endif()
if(NOT X11_Xi_FOUND)
message(FATAL_ERROR "Xi library not found - required for GLFW")
endif()
list(APPEND GLFW_x11_LIBRARY "${X11_Xrandr_LIB}" "${X11_Xxf86vm_LIB}" "${X11_Xcursor_LIB}" "${X11_Xinerama_LIB}" "${X11_Xi_LIB}" "${X11_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}" -lrt -ldl)
endif (NOT NO_GLFW_X11)
find_library( GLFW_glfw_LIBRARY
NAMES
glfw
glfw3
HINTS
"${GLFW_LOCATION}/lib"
"$ENV{GLFW_LOCATION}/lib"
"${GLFW_LOCATION}/lib/x11"
"$ENV{GLFW_LOCATION}/lib/x11"
PATHS
/usr/lib64
/usr/lib
/usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/local/lib64
/usr/local/lib
/usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
/usr/openwin/lib
"${GLFW_X11_LIB_DIRS}"
DOC
"The GLFW library"
)
endif (APPLE)
endif (WIN32)
set( GLFW_FOUND "NO" )
if(GLFW_INCLUDE_DIR)
if(GLFW_glfw_LIBRARY)
set( GLFW_LIBRARIES "${GLFW_glfw_LIBRARY}"
"${GLFW_x11_LIBRARY}"
"${GLFW_cocoa_LIBRARY}"
"${GLFW_iokit_LIBRARY}"
"${GLFW_corevideo_LIBRARY}" )
set( GLFW_FOUND "YES" )
set (GLFW_LIBRARY "${GLFW_LIBRARIES}")
set (GLFW_INCLUDE_PATH "${GLFW_INCLUDE_DIR}")
endif(GLFW_glfw_LIBRARY)
# Tease the GLFW_VERSION numbers from the lib headers
function(parseVersion FILENAME VARNAME)
set(PATTERN "^#define ${VARNAME}.*$")
file(STRINGS "${GLFW_INCLUDE_DIR}/${FILENAME}" TMP REGEX ${PATTERN})
string(REGEX MATCHALL "[0-9]+" TMP ${TMP})
set(${VARNAME} ${TMP} PARENT_SCOPE)
endfunction()
if(EXISTS "${GLFW_INCLUDE_DIR}/GL/glfw.h")
parseVersion(GL/glfw.h GLFW_VERSION_MAJOR)
parseVersion(GL/glfw.h GLFW_VERSION_MINOR)
parseVersion(GL/glfw.h GLFW_VERSION_REVISION)
elseif(EXISTS "${GLFW_INCLUDE_DIR}/GLFW/glfw3.h")
parseVersion(GLFW/glfw3.h GLFW_VERSION_MAJOR)
parseVersion(GLFW/glfw3.h GLFW_VERSION_MINOR)
parseVersion(GLFW/glfw3.h GLFW_VERSION_REVISION)
endif()
if(${GLFW_VERSION_MAJOR} OR ${GLFW_VERSION_MINOR} OR ${GLFW_VERSION_REVISION})
set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}.${GLFW_VERSION_REVISION}")
set(GLFW_VERSION_STRING "${GLFW_VERSION}")
mark_as_advanced(GLFW_VERSION)
endif()
endif(GLFW_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLFW
REQUIRED_VARS
GLFW_INCLUDE_DIR
GLFW_LIBRARIES
VERSION_VAR
GLFW_VERSION
)
mark_as_advanced(
GLFW_INCLUDE_DIR
GLFW_LIBRARIES
GLFW_glfw_LIBRARY
GLFW_cocoa_LIBRARY
)
|