blob: 9d486d5ba8a2221b1a764b5abb345015e6a2679e [file] [log] [blame]
Brian Silverman72890c22015-09-19 14:37:37 -04001# Copyright (c) 2009 Boudewijn Rempt <boud@valdyas.org>
2#
3# Redistribution and use is allowed according to the terms of the BSD license.
4# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
5#
6# - try to find glew library and include files
7# GLEW_INCLUDE_DIR, where to find GL/glew.h, etc.
8# GLEW_LIBRARIES, the libraries to link against
9# GLEW_FOUND, If false, do not try to use GLEW.
10# Also defined, but not for general use are:
11# GLEW_GLEW_LIBRARY = the full path to the glew library.
12
Austin Schuhc55b0172022-02-20 17:52:35 -080013if (WIN32)
Brian Silverman72890c22015-09-19 14:37:37 -040014
Austin Schuhc55b0172022-02-20 17:52:35 -080015 if(CYGWIN)
Brian Silverman72890c22015-09-19 14:37:37 -040016
Austin Schuhc55b0172022-02-20 17:52:35 -080017 find_path( GLEW_INCLUDE_DIR GL/glew.h)
Brian Silverman72890c22015-09-19 14:37:37 -040018
Austin Schuhc55b0172022-02-20 17:52:35 -080019 find_library( GLEW_GLEW_LIBRARY glew32
Brian Silverman72890c22015-09-19 14:37:37 -040020 ${OPENGL_LIBRARY_DIR}
21 /usr/lib/w32api
22 /usr/X11R6/lib
23 )
24
25
Austin Schuhc55b0172022-02-20 17:52:35 -080026 else(CYGWIN)
Brian Silverman72890c22015-09-19 14:37:37 -040027
Austin Schuhc55b0172022-02-20 17:52:35 -080028 find_path( GLEW_INCLUDE_DIR GL/glew.h
Brian Silverman72890c22015-09-19 14:37:37 -040029 $ENV{GLEW_ROOT_PATH}/include
30 )
31
Austin Schuhc55b0172022-02-20 17:52:35 -080032 find_library( GLEW_GLEW_LIBRARY
Brian Silverman72890c22015-09-19 14:37:37 -040033 NAMES glew glew32
34 PATHS
35 $ENV{GLEW_ROOT_PATH}/lib
36 ${OPENGL_LIBRARY_DIR}
37 )
38
Austin Schuhc55b0172022-02-20 17:52:35 -080039 endif(CYGWIN)
Brian Silverman72890c22015-09-19 14:37:37 -040040
Austin Schuhc55b0172022-02-20 17:52:35 -080041else (WIN32)
Brian Silverman72890c22015-09-19 14:37:37 -040042
Austin Schuhc55b0172022-02-20 17:52:35 -080043 if (APPLE)
Brian Silverman72890c22015-09-19 14:37:37 -040044# These values for Apple could probably do with improvement.
Austin Schuhc55b0172022-02-20 17:52:35 -080045 find_path( GLEW_INCLUDE_DIR glew.h
Brian Silverman72890c22015-09-19 14:37:37 -040046 /System/Library/Frameworks/GLEW.framework/Versions/A/Headers
47 ${OPENGL_LIBRARY_DIR}
48 )
Austin Schuhc55b0172022-02-20 17:52:35 -080049 set(GLEW_GLEW_LIBRARY "-framework GLEW" CACHE STRING "GLEW library for OSX")
50 set(GLEW_cocoa_LIBRARY "-framework Cocoa" CACHE STRING "Cocoa framework for OSX")
51 else (APPLE)
Brian Silverman72890c22015-09-19 14:37:37 -040052
Austin Schuhc55b0172022-02-20 17:52:35 -080053 find_path( GLEW_INCLUDE_DIR GL/glew.h
Brian Silverman72890c22015-09-19 14:37:37 -040054 /usr/include/GL
55 /usr/openwin/share/include
56 /usr/openwin/include
57 /usr/X11R6/include
58 /usr/include/X11
59 /opt/graphics/OpenGL/include
60 /opt/graphics/OpenGL/contrib/libglew
61 )
62
Austin Schuhc55b0172022-02-20 17:52:35 -080063 find_library( GLEW_GLEW_LIBRARY GLEW
Brian Silverman72890c22015-09-19 14:37:37 -040064 /usr/openwin/lib
65 /usr/X11R6/lib
66 )
67
Austin Schuhc55b0172022-02-20 17:52:35 -080068 endif (APPLE)
Brian Silverman72890c22015-09-19 14:37:37 -040069
Austin Schuhc55b0172022-02-20 17:52:35 -080070endif (WIN32)
Brian Silverman72890c22015-09-19 14:37:37 -040071
Austin Schuhc55b0172022-02-20 17:52:35 -080072set( GLEW_FOUND "NO" )
73if(GLEW_INCLUDE_DIR)
74 if(GLEW_GLEW_LIBRARY)
Brian Silverman72890c22015-09-19 14:37:37 -040075 # Is -lXi and -lXmu required on all platforms that have it?
76 # If not, we need some way to figure out what platform we are on.
Austin Schuhc55b0172022-02-20 17:52:35 -080077 set( GLEW_LIBRARIES
Brian Silverman72890c22015-09-19 14:37:37 -040078 ${GLEW_GLEW_LIBRARY}
79 ${GLEW_cocoa_LIBRARY}
80 )
Austin Schuhc55b0172022-02-20 17:52:35 -080081 set( GLEW_FOUND "YES" )
Brian Silverman72890c22015-09-19 14:37:37 -040082
83#The following deprecated settings are for backwards compatibility with CMake1.4
Austin Schuhc55b0172022-02-20 17:52:35 -080084 set (GLEW_LIBRARY ${GLEW_LIBRARIES})
85 set (GLEW_INCLUDE_PATH ${GLEW_INCLUDE_DIR})
Brian Silverman72890c22015-09-19 14:37:37 -040086
Austin Schuhc55b0172022-02-20 17:52:35 -080087 endif(GLEW_GLEW_LIBRARY)
88endif(GLEW_INCLUDE_DIR)
Brian Silverman72890c22015-09-19 14:37:37 -040089
Austin Schuhc55b0172022-02-20 17:52:35 -080090if(GLEW_FOUND)
91 if(NOT GLEW_FIND_QUIETLY)
92 message(STATUS "Found Glew: ${GLEW_LIBRARIES}")
93 endif(NOT GLEW_FIND_QUIETLY)
94else(GLEW_FOUND)
95 if(GLEW_FIND_REQUIRED)
96 message(FATAL_ERROR "Could not find Glew")
97 endif(GLEW_FIND_REQUIRED)
98endif(GLEW_FOUND)
Brian Silverman72890c22015-09-19 14:37:37 -040099
Austin Schuhc55b0172022-02-20 17:52:35 -0800100mark_as_advanced(
Brian Silverman72890c22015-09-19 14:37:37 -0400101 GLEW_INCLUDE_DIR
102 GLEW_GLEW_LIBRARY
103 GLEW_Xmu_LIBRARY
104 GLEW_Xi_LIBRARY
105)