Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 1 | # 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 Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 13 | if (WIN32) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 14 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 15 | if(CYGWIN) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 16 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 17 | find_path( GLEW_INCLUDE_DIR GL/glew.h) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 18 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 19 | find_library( GLEW_GLEW_LIBRARY glew32 |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 20 | ${OPENGL_LIBRARY_DIR} |
| 21 | /usr/lib/w32api |
| 22 | /usr/X11R6/lib |
| 23 | ) |
| 24 | |
| 25 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 26 | else(CYGWIN) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 27 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 28 | find_path( GLEW_INCLUDE_DIR GL/glew.h |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 29 | $ENV{GLEW_ROOT_PATH}/include |
| 30 | ) |
| 31 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 32 | find_library( GLEW_GLEW_LIBRARY |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 33 | NAMES glew glew32 |
| 34 | PATHS |
| 35 | $ENV{GLEW_ROOT_PATH}/lib |
| 36 | ${OPENGL_LIBRARY_DIR} |
| 37 | ) |
| 38 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 39 | endif(CYGWIN) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 40 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 41 | else (WIN32) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 42 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 43 | if (APPLE) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 44 | # These values for Apple could probably do with improvement. |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 45 | find_path( GLEW_INCLUDE_DIR glew.h |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 46 | /System/Library/Frameworks/GLEW.framework/Versions/A/Headers |
| 47 | ${OPENGL_LIBRARY_DIR} |
| 48 | ) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 49 | 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 Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 52 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 53 | find_path( GLEW_INCLUDE_DIR GL/glew.h |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 54 | /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 Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 63 | find_library( GLEW_GLEW_LIBRARY GLEW |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 64 | /usr/openwin/lib |
| 65 | /usr/X11R6/lib |
| 66 | ) |
| 67 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 68 | endif (APPLE) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 69 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 70 | endif (WIN32) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 71 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 72 | set( GLEW_FOUND "NO" ) |
| 73 | if(GLEW_INCLUDE_DIR) |
| 74 | if(GLEW_GLEW_LIBRARY) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 75 | # 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 Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 77 | set( GLEW_LIBRARIES |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 78 | ${GLEW_GLEW_LIBRARY} |
| 79 | ${GLEW_cocoa_LIBRARY} |
| 80 | ) |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 81 | set( GLEW_FOUND "YES" ) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 82 | |
| 83 | #The following deprecated settings are for backwards compatibility with CMake1.4 |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 84 | set (GLEW_LIBRARY ${GLEW_LIBRARIES}) |
| 85 | set (GLEW_INCLUDE_PATH ${GLEW_INCLUDE_DIR}) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 86 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 87 | endif(GLEW_GLEW_LIBRARY) |
| 88 | endif(GLEW_INCLUDE_DIR) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 89 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 90 | if(GLEW_FOUND) |
| 91 | if(NOT GLEW_FIND_QUIETLY) |
| 92 | message(STATUS "Found Glew: ${GLEW_LIBRARIES}") |
| 93 | endif(NOT GLEW_FIND_QUIETLY) |
| 94 | else(GLEW_FOUND) |
| 95 | if(GLEW_FIND_REQUIRED) |
| 96 | message(FATAL_ERROR "Could not find Glew") |
| 97 | endif(GLEW_FIND_REQUIRED) |
| 98 | endif(GLEW_FOUND) |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 99 | |
Austin Schuh | c55b017 | 2022-02-20 17:52:35 -0800 | [diff] [blame] | 100 | mark_as_advanced( |
Brian Silverman | 72890c2 | 2015-09-19 14:37:37 -0400 | [diff] [blame] | 101 | GLEW_INCLUDE_DIR |
| 102 | GLEW_GLEW_LIBRARY |
| 103 | GLEW_Xmu_LIBRARY |
| 104 | GLEW_Xi_LIBRARY |
| 105 | ) |