summaryrefslogtreecommitdiff
path: root/tests/FindGLEW.cmake
blob: 674741ddaebf83bb0877a961484e81dcb60f4fd4 (plain)
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
64
65
#
# Try to find GLEW library and include path.
# Once done this will define
#
# GLEW_FOUND
# GLEW_INCLUDE_DIR
# GLEW_LIBRARY
# 

# a few lines of this file are based on the LGPL code found at 
# http://openlibraries.org/browser/trunk/FindGLEW.cmake?rev=1383 

if (WIN32 AND MSVC)
  if (WIN32_STATIC_BUILD) # passed from caller
    set(GLEW_LIB_SEARCH_NAME glew32s.lib) # static, non-debug (Release)
  else ()
    set(GLEW_LIB_SEARCH_NAME glew32.lib) # other. untested with OpenSCAD
  endif()
else () # GCC
  set(GLEW_LIB_SEARCH_NAME "libglew32s.a")
endif ()

if (WIN32)
  find_path(GLEW_INCLUDE_DIR GL/glew.h
    $ENV{PROGRAMFILES}/GLEW/include
    ${PROJECT_SOURCE_DIR}/src/nvgl/glew/include
    DOC "The directory where GL/glew.h resides")
  find_library(GLEW_LIBRARY
    NAMES ${GLEW_LIB_SEARCH_NAME}
    PATHS
    $ENV{PROGRAMFILES}/GLEW/lib
    ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
    ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
    DOC "The GLEW library")
else()
  find_path(GLEW_INCLUDE_DIR GL/glew.h
    PATHS /usr/include /usr/local/include /usr/pkg/include
    DOC "The directory where GL/glew.h resides")
  find_library(GLEW_LIBRARY
    NAMES GLEW glew
    PATHS /usr/lib /usr/local/lib /usr/pkg/lib /lib /lib64 /usr/lib64
    DOC "The GLEW library")
endif()

if ("${GLEW_INCLUDE_DIR}" STREQUAL "" AND "${GLEW_LIBRARY}" STREQUAL "")
  set(GLEW_FOUND 0 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
else()
  set(GLEW_FOUND 1 CACHE STRING "Set to 1 if GLEW is found, 0 otherwise")
endif()

if (NOT GLEW_FOUND)
  find_package(PkgConfig REQUIRED)
  if (PKG_CONFIG_FOUND)
    message(STATUS "Doing pkg config glew check...")
    pkg_search_module(GLEW glew)
    if (GLEW_FOUND)
			set(GLEW_INCLUDE_DIR "${GLEW_INCLUDEDIR}")
      set(GLEW_LIBRARY "-L${GLEW_LIBRARY_DIRS} -l${GLEW_LIBRARIES}")
    endif()
  endif()
endif()

if (NOT GLEW_FOUND)
  message(FATAL_ERROR "GLEW not found")
endif()
contact: Jan Huwald // Impressum