FindGLEW

Finds the OpenGL Extension Wrangler Library (GLEW).

GLEW is a cross-platform C/C++ library that helps manage OpenGL extensions by providing efficient run-time mechanisms to query and load OpenGL functionality beyond the core specification.

Added in version 3.7: Debug and Release library variants are found separately.

Added in version 3.15: If GLEW is built using its CMake-based build system, it provides a CMake package configuration file (GLEWConfig.cmake). This module now takes that into account and first attempts to find GLEW in config mode. If the configuration file is not available, it falls back to module mode and searches standard locations.

Imported Targets

This module provides the following Imported Targets:

GLEW::GLEW

Added in version 3.1.

The main imported target encapsulating the GLEW usage requirements, available if GLEW is found. It maps usage requirements of either GLEW::glew or GLEW::glew_s target depending on their availability.

GLEW::glew

Added in version 3.15.

Target encapsulating the usage requirements for a shared GLEW library. This target is available if GLEW is found and static libraries aren't requested via the GLEW_USE_STATIC_LIBS hint variable (see below).

GLEW::glew_s

Added in version 3.15.

Target encapsulating the usage requirements for a static GLEW library. This target is available if GLEW is found and the GLEW_USE_STATIC_LIBS hint variable is set to boolean true.

Result Variables

This module defines the following variables:

GLEW_FOUND

Boolean indicating whether GLEW is found.

GLEW_VERSION

Added in version 3.15.

The version of GLEW found.

GLEW_VERSION_MAJOR

Added in version 3.15.

The major version of GLEW found.

GLEW_VERSION_MINOR

Added in version 3.15.

The minor version of GLEW found.

GLEW_VERSION_MICRO

Added in version 3.15.

The micro version of GLEW found.

GLEW_INCLUDE_DIRS

Include directories needed to use GLEW library.

GLEW_LIBRARIES

Libraries needed to link against to use GLEW library (shared or static depending on configuration).

GLEW_SHARED_LIBRARIES

Added in version 3.15.

Libraries needed to link against to use shared GLEW library.

GLEW_STATIC_LIBRARIES

Added in version 3.15.

Libraries needed to link against to use static GLEW library.

Hints

This module accepts the following variables before calling find_package(GLEW) to influence this module's behavior:

GLEW_USE_STATIC_LIBS

Added in version 3.15.

Set to boolean true to find static GLEW library and create the GLEW::glew_s imported target for static linkage.

GLEW_VERBOSE

Added in version 3.15.

Set to boolean true to output a detailed log of this module. Can be used, for example, for debugging.

Examples

Finding GLEW and linking it to a project target:

find_package(GLEW)
target_link_libraries(project_target PRIVATE GLEW::GLEW)

Using the static GLEW library, if found:

set(GLEW_USE_STATIC_LIBS TRUE)
find_package(GLEW)
target_link_libraries(project_target PRIVATE GLEW::GLEW)