From cfb7d2f036ced45bb34612a462cf1e88af4c9e38 Mon Sep 17 00:00:00 2001 From: BrandonSchaefer Date: Thu, 6 Nov 2014 00:15:37 -0800 Subject: [PATCH] Start with the skeleton code for Mir support. --- CMakeLists.txt | 29 +++++++++++++++++++++++++++++ src/CMakeLists.txt | 5 +++++ src/glfw_config.h.in | 2 ++ src/internal.h | 2 ++ 4 files changed, 38 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa57cc67..be1c6b66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ endif() if (UNIX AND NOT APPLE) option(GLFW_USE_WAYLAND "Use Wayland for context creation (implies EGL as well)" OFF) + option(GLFW_USE_MIR "Use Mir for context creation (implies EGL as well)" OFF) endif() if (MSVC) @@ -45,6 +46,8 @@ endif() if (GLFW_USE_WAYLAND) set(GLFW_USE_EGL ON) +elseif (GLFW_USE_MIR) + set(GLFW_USE_EGL ON) endif() if (GLFW_USE_EGL) @@ -174,6 +177,9 @@ elseif (UNIX) if (GLFW_USE_WAYLAND) set(_GLFW_WAYLAND 1) message(STATUS "Using Wayland for window creation") + elseif (GLFW_USE_MIR) + set(_GLFW_MIR 1) + message(STATUS "Using Mir for window creation") else() set(_GLFW_X11 1) message(STATUS "Using X11 for window creation") @@ -343,6 +349,29 @@ if (_GLFW_WAYLAND) endif() endif() +#-------------------------------------------------------------------- +# Use Mir for window creation +#-------------------------------------------------------------------- +if (_GLFW_MIR) + find_package(Mir REQUIRED) + set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} mirclient") + + list(APPEND glfw_INCLUDE_DIRS "${MIR_INCLUDE_DIR}") + list(APPEND glfw_LIBRARIES "${MIR_LIBRARIES}" "${CMAKE_THREAD_LIBS_INIT}") + + find_package(XKBCommon REQUIRED) + set(GLFW_PKG_DEPS "${GLFW_PKG_DEPS} xkbcommon") + list(APPEND glfw_INCLUDE_DIRS "${XKBCOMMON_INCLUDE_DIRS}") + list(APPEND glfw_LIBRARIES "${XKBCOMMON_LIBRARY}") + + find_library(MATH_LIBRARY m) + mark_as_advanced(MATH_LIBRARY) + if (MATH_LIBRARY) + list(APPEND glfw_LIBRARIES "${MATH_LIBRARY}") + set(GLFW_PKG_LIBS "${GLFW_PKG_LIBS} -lm") + endif() +endif() + #-------------------------------------------------------------------- # Use GLX for context creation #-------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e006a8f1..9ba9fc56 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,6 +30,11 @@ elseif (_GLFW_WAYLAND) posix_time.h posix_tls.h xkb_unicode.h) set(glfw_SOURCES ${common_SOURCES} wl_init.c wl_monitor.c wl_window.c linux_joystick.c posix_time.c posix_tls.c xkb_unicode.c) +elseif (_GLFW_MIR) + set(glfw_HEADERS ${common_HEADERS} mir_platform.h linux_joystick.h + posix_time.h posix_tls.h xkb_unicode.h) + set(glfw_SOURCES ${common_SOURCES} mir_init.c mir_monitor.c mir_window.c + linux_joystick.c posix_time.c posix_tls.c xkb_unicode.c) endif() if (_GLFW_EGL) diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index 11c2aa76..485cac58 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -42,6 +42,8 @@ #cmakedefine _GLFW_COCOA // Define this to 1 if building GLFW for Wayland #cmakedefine _GLFW_WAYLAND +// Define this to 1 if building GLFW for Mir +#cmakedefine _GLFW_MIR // Define this to 1 if building GLFW for EGL #cmakedefine _GLFW_EGL diff --git a/src/internal.h b/src/internal.h index 62504e4f..0565256c 100644 --- a/src/internal.h +++ b/src/internal.h @@ -74,6 +74,8 @@ typedef struct _GLFWcursor _GLFWcursor; #include "x11_platform.h" #elif defined(_GLFW_WAYLAND) #include "wl_platform.h" +#elif defined(_GLFW_MIR) + #include "mir_platform.h" #else #error "No supported window creation API selected" #endif