Open Source Tomb Raider Engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. #
  2. # Copyright 2013 Pixar
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "Apache License")
  5. # with the following modification; you may not use this file except in
  6. # compliance with the Apache License and the following modification to it:
  7. # Section 6. Trademarks. is deleted and replaced with:
  8. #
  9. # 6. Trademarks. This License does not grant permission to use the trade
  10. # names, trademarks, service marks, or product names of the Licensor
  11. # and its affiliates, except as required to comply with Section 4(c) of
  12. # the License and to reproduce the content of the NOTICE file.
  13. #
  14. # You may obtain a copy of the Apache License at
  15. #
  16. # http://www.apache.org/licenses/LICENSE-2.0
  17. #
  18. # Unless required by applicable law or agreed to in writing, software
  19. # distributed under the Apache License with the above modification is
  20. # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  21. # KIND, either express or implied. See the Apache License for the specific
  22. # language governing permissions and limitations under the Apache License.
  23. #
  24. # Try to find GLFW library and include path.
  25. # Once done this will define
  26. #
  27. # GLFW_FOUND
  28. # GLFW_INCLUDE_DIR
  29. # GLFW_LIBRARIES
  30. #
  31. find_path( GLFW_INCLUDE_DIR
  32. NAMES
  33. GL/glfw.h
  34. GLFW/glfw3.h
  35. PATHS
  36. "${GLFW_LOCATION}/include"
  37. "$ENV{GLFW_LOCATION}/include"
  38. "$ENV{PROGRAMFILES}/GLFW/include"
  39. "${OPENGL_INCLUDE_DIR}"
  40. /usr/openwin/share/include
  41. /usr/openwin/include
  42. /usr/X11R6/include
  43. /usr/include/X11
  44. /opt/graphics/OpenGL/include
  45. /opt/graphics/OpenGL/contrib/libglfw
  46. /usr/local/include
  47. /usr/include/GL
  48. /usr/include
  49. DOC
  50. "The directory where GL/glfw.h resides"
  51. )
  52. if (WIN32)
  53. if(CYGWIN)
  54. find_library( GLFW_glfw_LIBRARY
  55. NAMES
  56. glfw32
  57. PATHS
  58. "${GLFW_LOCATION}/lib"
  59. "${GLFW_LOCATION}/lib/x64"
  60. "$ENV{GLFW_LOCATION}/lib"
  61. "${OPENGL_LIBRARY_DIR}"
  62. /usr/lib
  63. /usr/lib/w32api
  64. /usr/local/lib
  65. /usr/X11R6/lib
  66. DOC
  67. "The GLFW library"
  68. )
  69. else()
  70. find_library( GLFW_glfw_LIBRARY
  71. NAMES
  72. glfw32
  73. glfw32s
  74. glfw
  75. glfw3
  76. PATHS
  77. "${GLFW_LOCATION}/lib"
  78. "${GLFW_LOCATION}/lib/x64"
  79. "${GLFW_LOCATION}/lib-msvc110"
  80. "$ENV{GLFW_LOCATION}/lib"
  81. "$ENV{GLFW_LOCATION}/lib/x64"
  82. "$ENV{GLFW_LOCATION}/lib-msvc110"
  83. "${PROJECT_SOURCE_DIR}/extern/glfw/bin"
  84. "${PROJECT_SOURCE_DIR}/extern/glfw/lib"
  85. "$ENV{PROGRAMFILES}/GLFW/lib"
  86. "${OPENGL_LIBRARY_DIR}"
  87. DOC
  88. "The GLFW library"
  89. )
  90. endif()
  91. else ()
  92. if (APPLE)
  93. find_library( GLFW_glfw_LIBRARY glfw
  94. NAMES
  95. glfw
  96. glfw3
  97. PATHS
  98. "${GLFW_LOCATION}/lib"
  99. "${GLFW_LOCATION}/lib/cocoa"
  100. "$ENV{GLFW_LOCATION}/lib"
  101. "$ENV{GLFW_LOCATION}/lib/cocoa"
  102. /usr/local/lib
  103. )
  104. set(GLFW_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX")
  105. set(GLFW_corevideo_LIBRARY "-framework CoreVideo" CACHE STRING "CoreVideo framework for OSX")
  106. set(GLFW_iokit_LIBRARY "-framework IOKit" CACHE STRING "IOKit framework for OSX")
  107. else ()
  108. # (*)NIX
  109. find_package(X11 REQUIRED)
  110. if(NOT X11_Xrandr_FOUND)
  111. message(FATAL_ERROR "Xrandr library not found - required for GLFW")
  112. endif()
  113. if(NOT X11_xf86vmode_FOUND)
  114. message(FATAL_ERROR "xf86vmode library not found - required for GLFW")
  115. endif()
  116. if(NOT X11_Xcursor_FOUND)
  117. message(FATAL_ERROR "Xcursor library not found - required for GLFW")
  118. endif()
  119. list(APPEND GLFW_x11_LIBRARY "${X11_Xrandr_LIB}" "${X11_Xxf86vm_LIB}" "${X11_Xcursor_LIB}" -lrt)
  120. find_library( GLFW_glfw_LIBRARY
  121. NAMES
  122. glfw
  123. glfw3
  124. PATHS
  125. "${GLFW_LOCATION}/lib"
  126. "$ENV{GLFW_LOCATION}/lib"
  127. "${GLFW_LOCATION}/lib/x11"
  128. "$ENV{GLFW_LOCATION}/lib/x11"
  129. /usr/lib64
  130. /usr/lib
  131. /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}
  132. /usr/local/lib64
  133. /usr/local/lib
  134. /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE}
  135. /usr/openwin/lib
  136. /usr/X11R6/lib
  137. DOC
  138. "The GLFW library"
  139. )
  140. endif (APPLE)
  141. endif (WIN32)
  142. set( GLFW_FOUND "NO" )
  143. if(GLFW_INCLUDE_DIR)
  144. if(GLFW_glfw_LIBRARY)
  145. set( GLFW_LIBRARIES "${GLFW_glfw_LIBRARY}"
  146. "${GLFW_x11_LIBRARY}"
  147. "${GLFW_cocoa_LIBRARY}"
  148. "${GLFW_iokit_LIBRARY}"
  149. "${GLFW_corevideo_LIBRARY}" )
  150. set( GLFW_FOUND "YES" )
  151. set (GLFW_LIBRARY "${GLFW_LIBRARIES}")
  152. set (GLFW_INCLUDE_PATH "${GLFW_INCLUDE_DIR}")
  153. endif(GLFW_glfw_LIBRARY)
  154. # Tease the GLFW_VERSION numbers from the lib headers
  155. function(parseVersion FILENAME VARNAME)
  156. set(PATTERN "^#define ${VARNAME}.*$")
  157. file(STRINGS "${GLFW_INCLUDE_DIR}/${FILENAME}" TMP REGEX ${PATTERN})
  158. string(REGEX MATCHALL "[0-9]+" TMP ${TMP})
  159. set(${VARNAME} ${TMP} PARENT_SCOPE)
  160. endfunction()
  161. if(EXISTS "${GLFW_INCLUDE_DIR}/GL/glfw.h")
  162. parseVersion(GL/glfw.h GLFW_VERSION_MAJOR)
  163. parseVersion(GL/glfw.h GLFW_VERSION_MINOR)
  164. parseVersion(GL/glfw.h GLFW_VERSION_REVISION)
  165. elseif(EXISTS "${GLFW_INCLUDE_DIR}/GLFW/glfw3.h")
  166. parseVersion(GLFW/glfw3.h GLFW_VERSION_MAJOR)
  167. parseVersion(GLFW/glfw3.h GLFW_VERSION_MINOR)
  168. parseVersion(GLFW/glfw3.h GLFW_VERSION_REVISION)
  169. endif()
  170. if(${GLFW_VERSION_MAJOR} OR ${GLFW_VERSION_MINOR} OR ${GLFW_VERSION_REVISION})
  171. set(GLFW_VERSION "${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR}.${GLFW_VERSION_REVISION}")
  172. set(GLFW_VERSION_STRING "${GLFW_VERSION}")
  173. mark_as_advanced(GLFW_VERSION)
  174. endif()
  175. endif(GLFW_INCLUDE_DIR)
  176. include(FindPackageHandleStandardArgs)
  177. find_package_handle_standard_args(GLFW
  178. REQUIRED_VARS
  179. GLFW_INCLUDE_DIR
  180. GLFW_LIBRARIES
  181. VERSION_VAR
  182. GLFW_VERSION
  183. )
  184. mark_as_advanced(
  185. GLFW_INCLUDE_DIR
  186. GLFW_LIBRARIES
  187. GLFW_glfw_LIBRARY
  188. GLFW_cocoa_LIBRARY
  189. )