Merge branch 'master' into multi-monitor

Conflicts:
	CMakeLists.txt
	readme.html
	src/CMakeLists.txt
	src/cocoa_platform.h
	src/win32_platform.h
	src/x11_platform.h
	tests/events.c
This commit is contained in:
Camilla Berglund
2012-12-02 20:52:03 +01:00
32 changed files with 1911 additions and 261 deletions
+117 -27
View File
@@ -15,7 +15,20 @@ option(GLFW_BUILD_TESTS "Build the GLFW test programs" ON)
option(GLFW_NATIVE_API "Build the GLFW native API" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
find_package(OpenGL REQUIRED)
if (NOT APPLE)
option(GLFW_USE_EGL "Use EGL for context creation" OFF)
endif()
if (GLFW_USE_EGL)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake/modules)
find_package(EGL REQUIRED)
set(GLFW_BUILD_EXAMPLES OFF)
set(GLFW_BUILD_TESTS OFF)
message(STATUS "NOTE: Examples and tests are disabled for EGL")
else()
find_package(OpenGL REQUIRED)
endif()
#--------------------------------------------------------------------
# Enable all warnings on GCC, regardless of OS
@@ -32,17 +45,40 @@ if (BUILD_SHARED_LIBS)
endif()
#--------------------------------------------------------------------
# Detect and select target platform
# Detect and select target APIs
#--------------------------------------------------------------------
if (WIN32)
set(_GLFW_WIN32_WGL 1)
message(STATUS "Building GLFW for WGL on a Win32 system")
elseif (UNIX AND APPLE)
set(_GLFW_COCOA_NSGL 1)
message(STATUS "Building GLFW for Cocoa and NSOpenGL on Mac OS X")
elseif (UNIX AND NOT APPLE)
set(_GLFW_X11_GLX 1)
message(STATUS "Building GLFW for X11 and GLX on a Unix-like system")
set(_GLFW_WIN32 1)
message(STATUS "Using Win32 for window creation")
if (GLFW_USE_EGL)
set(_GLFW_EGL 1)
message(STATUS "Using EGL for context creation")
else()
set(_GLFW_WGL 1)
message(STATUS "Using WGL for context creation")
endif()
elseif (APPLE)
set(_GLFW_COCOA 1)
message(STATUS "Using Cocoa for window creation")
if (GLFW_USE_EGL)
message(FATAL_ERROR "EGL not supported on Mac OS X")
else()
set(_GLFW_NSGL 1)
message(STATUS "Using NSGL for context creation")
endif()
elseif (UNIX)
set(_GLFW_X11 1)
message(STATUS "Using X11 for window creation")
if (GLFW_USE_EGL)
set(_GLFW_EGL 1)
message(STATUS "Using EGL for context creation")
else()
set(_GLFW_GLX 1)
message(STATUS "Using GLX for context creation")
endif()
else()
message(FATAL_ERROR "No supported platform was detected")
endif()
@@ -50,7 +86,7 @@ endif()
#--------------------------------------------------------------------
# Set up GLFW for Win32 and WGL on Windows
#--------------------------------------------------------------------
if (_GLFW_WIN32_WGL)
if (_GLFW_WIN32)
# Set up library and include paths
list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
@@ -79,26 +115,18 @@ if (_GLFW_WIN32_WGL)
endif()
#--------------------------------------------------------------------
# Set up GLFW for Xlib and GLX on Unix-like systems with X Windows
# Set up GLFW for Xlib and GLX or EGL on Unix-like systems with X Windows
#--------------------------------------------------------------------
if (_GLFW_X11_GLX)
if (_GLFW_X11)
find_package(X11 REQUIRED)
set(CMAKE_THREAD_PREFER_PTHREADS YES)
find_package(Threads)
if (CMAKE_THREAD_LIBS_INIT)
list(APPEND glfw_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif()
set(GLFW_PKG_LIBS "")
set(GLFW_PKG_DEPS "x11")
# Set up library and include paths
list(APPEND glfw_INCLUDE_DIRS ${X11_X11_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR})
list(APPEND glfw_LIBRARIES ${X11_X11_LIB} ${OPENGL_gl_LIBRARY})
set(GLFW_PKG_DEPS "gl x11")
set(GLFW_PKG_LIBS "")
include(CheckFunctionExists)
list(APPEND glfw_INCLUDE_DIRS ${X11_X11_INCLUDE_PATH})
list(APPEND glfw_LIBRARIES ${X11_X11_LIB})
# Check for XRandR (modern resolution switching extension)
if (X11_Xrandr_FOUND)
@@ -144,6 +172,21 @@ if (_GLFW_X11_GLX)
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lm")
endif()
endif()
#--------------------------------------------------------------------
# GLX Context
#--------------------------------------------------------------------
if (_GLFW_GLX)
# Set up library and include paths
list(APPEND glfw_INCLUDE_DIRS ${OPENGL_INCLUDE_DIR})
list(APPEND glfw_LIBRARIES ${OPENGL_gl_LIBRARY})
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} gl")
include(CheckFunctionExists)
set(CMAKE_REQUIRED_LIBRARIES ${OPENGL_gl_LIBRARY})
check_function_exists(glXGetProcAddress _GLFW_HAS_GLXGETPROCADDRESS)
@@ -182,12 +225,59 @@ if (_GLFW_X11_GLX)
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -ldl")
endif()
endif()
endif()
#--------------------------------------------------------------------
# EGL Context
#--------------------------------------------------------------------
if (_GLFW_EGL)
# Set up library and include paths
list(APPEND glfw_INCLUDE_DIRS ${EGL_INCLUDE_DIR})
list(APPEND glfw_LIBRARIES ${EGL_LIBRARY})
set(CMAKE_REQUIRED_LIBRARIES ${EGL_LIBRARY})
if (_GLFW_X11)
set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} egl")
include(CheckFunctionExists)
check_function_exists(eglGetProcAddress _GLFW_HAS_EGLGETPROCADDRESS)
if (NOT _GLFW_HAS_EGLGETPROCADDRESS)
message(WARNING "No eglGetProcAddress found")
# Check for dlopen support as a fallback
find_library(DL_LIBRARY dl)
mark_as_advanced(DL_LIBRARY)
if (DL_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES ${DL_LIBRARY})
else()
set(CMAKE_REQUIRED_LIBRARIES "")
endif()
check_function_exists(dlopen _GLFW_HAS_DLOPEN)
if (NOT _GLFW_HAS_DLOPEN)
message(FATAL_ERROR "No entry point retrieval mechanism found")
endif()
if (DL_LIBRARY)
list(APPEND glfw_LIBRARIES ${DL_LIBRARY})
set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -ldl")
endif()
endif()
endif()
endif()
#--------------------------------------------------------------------
# Set up GLFW for Cocoa and NSOpenGL on Mac OS X
#--------------------------------------------------------------------
if (_GLFW_COCOA_NSGL)
if (_GLFW_COCOA AND _GLFW_NSGL)
option(GLFW_BUILD_UNIVERSAL "Build GLFW as a Universal Binary" OFF)
@@ -269,7 +359,7 @@ install(FILES COPYING.txt readme.html
#--------------------------------------------------------------------
# Create and install pkg-config file on supported platforms
#--------------------------------------------------------------------
if (_GLFW_X11_GLX OR _GLFW_COCOA_NSGL)
if (UNIX)
configure_file(${GLFW_SOURCE_DIR}/src/glfw3.pc.in
${GLFW_BINARY_DIR}/src/glfw3.pc @ONLY)