Files
Seele/cmake/FindGLFW.cmake
T

97 lines
2.2 KiB
CMake
Raw Normal View History

2020-06-02 11:46:18 +02:00
#
# Find GLFW
#
# Try to find GLFW library.
# This module defines the following variables:
# - GLFW_INCLUDE_DIRS
# - GLFW_LIBRARIES
# - GLFW_FOUND
#
# The following variables can be set as arguments for the module.
# - GLFW_ROOT : Root library directory of GLFW
# - GLFW_USE_STATIC_LIBS : Specifies to use static version of GLFW library (Windows only)
#
# References:
# - https://github.com/progschj/OpenGL-Examples/blob/master/cmake_modules/FindGLFW.cmake
# - https://bitbucket.org/Ident8/cegui-mk2-opengl3-renderer/src/befd47200265/cmake/FindGLFW.cmake
#
# Additional modules
include(FindPackageHandleStandardArgs)
if (WIN32)
# Find include files
find_path(
GLFW_INCLUDE_DIR
NAMES GLFW/glfw3.h
PATHS
$ENV{PROGRAMFILES}/include
${GLFW_ROOT}/include
DOC "The directory where GLFW/glfw.h resides")
2020-08-11 21:23:20 +02:00
# Use glfw3(d).lib for static library
2020-06-02 11:46:18 +02:00
if (GLFW_USE_STATIC_LIBS)
2020-08-11 21:23:20 +02:00
set(GLFW_LIBRARY_NAME glfw3${CMAKE_DEBUG_POSTFIX})
2020-06-02 11:46:18 +02:00
else()
2020-08-11 21:23:20 +02:00
set(GLFW_LIBRARY_NAME glfw3${CMAKE_DEBUG_POSTFIX}dll)
2020-06-02 11:46:18 +02:00
endif()
# Find library files
find_library(
GLFW_LIBRARY
NAMES ${GLFW_LIBRARY_NAME}.lib
PATHS
$ENV{PROGRAMFILES}/lib
${GLFW_ROOT}/lib
${GLFW_ROOT}/src
PATH_SUFFIXES Debug Release)
unset(GLFW_LIBRARY_NAME)
2021-10-19 23:04:38 +02:00
#find_file(
# GLFW_BINARY
# NAMES glfw3${CMAKE_DEBUG_POSTFIX}.dll
# PATHS
# $ENV{PROGRAMFILES}/bin
# ${CMAKE_BINARY_DIR}
# ${GLFW_ROOT}/src
# ${GLFW_ROOT}/bin
# PATH_SUFFIXES Debug Release)
2020-06-02 11:46:18 +02:00
else()
# Find include files
find_path(
GLFW_INCLUDE_DIR
2021-04-01 16:40:14 +02:00
NAMES GLFW/glfw3.h
2020-06-02 11:46:18 +02:00
PATHS
/usr/include
/usr/local/include
/sw/include
/opt/local/include
DOC "The directory where GL/glfw.h resides")
2021-10-15 23:12:29 +02:00
# Find library files
2020-06-02 11:46:18 +02:00
find_file(
2021-10-15 23:12:29 +02:00
GLFW_LIBRARY
2021-04-01 16:40:14 +02:00
NAMES libglfw${CMAKE_DEBUG_POSTFIX}.so
2020-06-02 11:46:18 +02:00
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
2021-04-01 16:40:14 +02:00
${GLFW_ROOT}/src
2020-06-02 11:46:18 +02:00
)
endif()
# Handle REQUIRD argument, define *_FOUND variable
2021-10-15 23:12:29 +02:00
find_package_handle_standard_args(GLFW DEFAULT_MSG GLFW_INCLUDE_DIR GLFW_LIBRARY)
2020-06-02 11:46:18 +02:00
# Define GLFW_LIBRARIES and GLFW_INCLUDE_DIRS
if (GLFW_FOUND)
2020-08-11 21:23:20 +02:00
set(GLFW_LIBRARIES ${GLFW_LIBRARY})
2020-06-02 11:46:18 +02:00
set(GLFW_INCLUDE_DIRS ${GLFW_INCLUDE_DIR})
endif()
# Hide some variables
mark_as_advanced(GLFW_INCLUDE_DIR GLFW_LIBRARY)