File: FindGLEW.cmake

package info (click to toggle)
openclonk 8.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 169,656 kB
  • sloc: cpp: 180,484; ansic: 108,988; xml: 31,371; python: 1,223; php: 767; makefile: 148; sh: 101; javascript: 34
file content (63 lines) | stat: -rw-r--r-- 2,391 bytes parent folder | download | duplicates (5)
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
# OpenClonk, http://www.openclonk.org
#
# Copyright (c) 2015-2016, The OpenClonk Team and contributors
#
# Distributed under the terms of the ISC license; see accompanying file
# "COPYING" for details.
#
# "Clonk" is a registered trademark of Matthes Bender, used with permission.
# See accompanying file "TRADEMARK" for details.
#
# To redistribute this file separately, substitute the full license texts
# for the above references.

# Locate GLEW.
# This module defines
#  GLEW_INCLUDE_DIRS - a list of directories that need to be added to the include path
#  GLEW_LIBRARIES - a list of libraries to link against to use GLEW
#  GLEW_DEFINITIONS - a list of compile-time macros that need to be defined to use GLEW
#  GLEW_FOUND - if false, GLEW cannot be used

find_path(GLEW_INCLUDE_DIR GL/glew.h PATH_SUFFIXES)
mark_as_advanced(GLEW_INCLUDE_DIR)

# Read GLEW version from header
if (GLEW_INCLUDE_DIR AND EXISTS "${GLEW_INCLUDE_DIR}/GL/glew.h")
	file(STRINGS "${GLEW_INCLUDE_DIR}/GL/glew.h" glew_version_str REGEX "^VERSION .+")
	string(REGEX REPLACE "^VERSION (.+)" "\\1" GLEW_VERSION_STRING "${glew_version_str}")
	unset(glew_version_str)
endif()

# On OS other than Windows, it doesn't matter whether we confuse the shared
# library and the static one. On Windows, we need to #define GLEW_STATIC if
# (and only if) we're linking against the static library. "glew32" may match
# the static library on MinGW, so we have to test for that explicitly.
find_library(GLEW_STATIC_LIBRARY glew32s)
mark_as_advanced(GLEW_STATIC_LIBRARY)
find_library(GLEW_SHARED_LIBRARY NAMES GLEW glew32)
mark_as_advanced(GLEW_SHARED_LIBRARY)

if (GLEW_SHARED_LIBRARY)
	set(GLEW_LIBRARY "${GLEW_SHARED_LIBRARY}")
	if (WIN32 AND MINGW AND GLEW_SHARED_LIBRARY MATCHES "\\.a$")
		# not actually a shared library
		set(GLEW_DEFINITIONS "-DGLEW_STATIC")
	else()
		set(GLEW_DEFINITIONS)
	endif()
elseif (GLEW_STATIC_LIBRARY)
	set(GLEW_LIBRARY "${GLEW_STATIC_LIBRARY}")
	set(GLEW_DEFINITIONS "-DGLEW_STATIC")
endif()

include(FindPackageHandleStandardArgs)
if (NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.3")
	find_package_handle_standard_args(GLEW VERSION_VAR GLEW_VERSION_STRING REQUIRED_VARS GLEW_LIBRARY GLEW_INCLUDE_DIR)
else()
	find_package_handle_standard_args(GLEW GLEW_LIBRARY GLEW_INCLUDE_DIR)
endif()

if (GLEW_FOUND)
	set(GLEW_LIBRARIES "${GLEW_LIBRARY}")
	set(GLEW_INCLUDE_DIRS "${GLEW_INCLUDE_DIR}")
endif()