Commit Graph

288 Commits

Author SHA1 Message Date
Camilla Löwy
56a4cb0a3a Add runtime platform selection
This adds compile-time support for multiple platforms and runtime
detection of them.  Window system related platform functions are now
called from shared code via the function pointer struct _GLFWplatform.

The timer, thread and module loading platform functions are still called
directly by name and the implementation chosen at link-time.  These
functions are the same for any backend on a given OS, including the Null
backend.

The platforms are now enabled via CMake dependent options following the
GLFW_BUILD_<platform> pattern instead of a mix of automagic and ad-hoc
option names.  There is no longer any option for the Null backend as it
is now always enabled.

Much of the struct stitching work in platform.h was based on an earlier
experimental branch for runtime platform selection by @ronchaine.

Every platform function related to windows, contexts, monitors, input,
event processing and Vulkan have been renamed so that multiple sets of
them can exist without colliding.  Calls to these are now routed through
the _glfw.platform struct member.  These changes makes up most of this
commit.

For Wayland and X11 the client library loading and display creation is
used to detect a running compositor/server.  The XDG_SESSION_TYPE
environment variable is ignored for now, as X11 is still by far the more
complete implementation.

Closes #1655
Closes #1958
2021-10-13 21:47:11 +02:00
Camilla Löwy
8b8d10bc01 Move library dependency logic to src directory
This finally eliminates the glfw_INCLUDE_DIRS and glfw_LIBRARIES CMake
variables entirely.
2021-10-12 12:54:35 +02:00
Camilla Löwy
0a9488e3f0 Remove configuration header 2021-10-12 12:54:35 +02:00
Camilla Löwy
8c8def5de5 Start making use of CMake 3.4 string(APPEND) 2021-08-26 16:03:58 +02:00
Camilla Löwy
4f077c4133 Raise minimum required CMake version to 3.4
CMake 3.4 was released in November 2015.
2021-08-26 16:03:58 +02:00
Camilla Löwy
d7b7c3b12a Raise maximum known CMake version to 3.20
This has seemed to work well on all platforms for a while.
2021-08-26 16:03:57 +02:00
Camilla Löwy
71829a0f0d Wayland: Remove unused pkg-config dependency
Related to #1934.
2021-08-15 23:34:13 +02:00
Camilla Löwy
244948e174 Export pkg-config dependencies via the CMake cache
This will be useful when building GLFW as a CMake object library and
linking it into a larger library that exports pkg-config information.

Partly based on #1307 by @a3f.

Closes #1307.
2021-08-15 23:03:21 +02:00
Camilla Löwy
d83849792b Add override variable for CMake library type
This adds the GLFW_LIBRARY_TYPE CMake cache variable, which allows users
and higher-level projects to set what type of library GLFW is built as.

When not empty, this value overrides the standard BUILD_SHARED_LIBS
option for GLFW while still allowing it to control the type of other
libraries in a larger project.

This also allows building GLFW as an object library without adding dummy
source files (as required by Xcode) or producing unused library
binaries.

Projects using CMake 3.12 or later can link the resulting GLFW object
library normally using target_link_libraries.

Fixes #279.
Related to #1307.
Closes #1497.
Closes #1574.
Closes #1928.
2021-08-15 22:44:43 +02:00
Camilla Löwy
dffe203c17 Wayland: Make libwayland-client dynamically loaded
The insight to use wayland.xml to resolve the difficult-to-redirect
interface symbols was gleaned from SDL.

Instead of compiling the code output of wayland-scanner separately it is
made part of the wl_init compilation unit.  This lets us do things like
transparently rename our copies of Wayland globals.

The OS version of wayland-client-protocol.h is no longer used by GLFW,
but it is presumably ABI compatible with the output of wayland-scanner.

Closes #1174.
Closes #1338.
Related to #1655.
Closes #1943.
2021-08-15 21:58:19 +02:00
Camilla Löwy
87d5646f5d Remove unneccessary quotes in CMake conditions 2021-08-13 17:27:38 +02:00
Camilla Löwy
9a0e88a016 Update comment for msvcrt CMake option 2021-08-13 17:27:38 +02:00
Camilla Löwy
f4a7329604 Update USE_MSVC_RUNTIME_LIBRARY_DLL for CMake 3.15
This makes USE_MSVC_RUNTIME_LIBRARY_DLL update the directory scope
CMAKE_MSVC_RUNTIME_LIBRARY variable instead of CMAKE_C_FLAGS on CMake
3.15 and later.

Solution proposed by @moritz-h.

Fixes #1783.
Closes #1796.
2021-04-14 22:50:32 +02:00
Joel Winarske
2747e47393 Wayland: Remove extra-cmake-modules dependency
Fixes #1774.
2020-09-30 17:02:26 +02:00
Camilla Löwy
1353f37a51 Make unsupported versions of CMake fail early 2020-09-23 20:07:34 +02:00
Camilla Löwy
539535a367 Specify maximum version of CMake known to work
Related to #1753.
2020-09-23 20:06:18 +02:00
Camilla Löwy
9d7897f961 Support interprocedural optimization override
This policy applies the CMAKE_INTERPROCEDURAL_OPTIMIZATION override to
the GLFW target.

Fixes #1753.
2020-09-02 21:27:43 +02:00
Camilla Löwy
68e4261d73 X11: Include X Shape extension headers
Related to #1568.
2020-07-15 18:00:00 +02:00
Camilla Löwy
e47705d8fb Move more compiler workarounds to library setup
These are details of the glfw CMake target and belong in the creation of
that target.
2020-06-08 01:07:34 +02:00
Camilla Löwy
8369880b56 Only look for OSMesa module if building examples
GLFW itself doesn't need the OSMesa headers to build.
2020-06-08 01:07:34 +02:00
Camilla Löwy
cfc23cd087 Fix MinGW linker flag tests breaking later tests 2020-06-08 01:07:34 +02:00
Camilla Löwy
6aca3e99f0 Wayland: Remove unused link-time dependency
The wayland-egl library is now loaded dynamically at init.  This narrows
the pkgconfig dependencies to the link-time depdendencies.
2020-02-12 19:02:46 +01:00
Camilla Löwy
a0a5cc57df X11: Make libX11 dynamically loaded
This completes the dynamic loading of all X11 libraries in preparation
for run-time platform selection.
2020-02-10 17:44:56 +01:00
Camilla Löwy
40c7e471e3 Move more non-source template files to CMake dir 2020-02-08 17:42:53 +01:00
Crunkle
d862d56acb Fix docs install condition
Closes #1624.
2020-01-16 23:52:38 +01:00
Camilla Löwy
15d91801b7 Cocoa: Select Vulkan surface extension at runtime
This mostly just follows the pattern established by X11.

Related to #1619.
2020-01-16 21:53:18 +01:00
ByunghoonKim
c5cb4a253a Cocoa: Add support for VK_EXT_metal_surface
This adds optional support for the VK_EXT_metal_surface instance
extension.

Closes #1619.
2020-01-16 05:28:24 +01:00
Camilla Löwy
4ec7daf3e9 Cocoa: Replace display link with IOKit query
This removes the final dependency on CoreVideo, using a display link to
get the refresh rate of monitors where Core Graphics report a refresh
rate of zero.  Instead we now query the I/O registry directly, similarly
to what the display link does at creation.

Thanks to @OneSadCookie for pointers to this solution.
2019-12-25 21:53:04 +01:00
Camilla Löwy
18307467b4 Gather CMake setup of configuration header 2019-12-15 18:37:57 +01:00
Camilla Löwy
49c5d837b4 Replace CMake threads variable with modern target 2019-12-15 18:37:56 +01:00
Camilla Löwy
8a5fd0c5a4 Replace ad-hoc CMake code with DEFINE_SYMBOL
This target property does what we were doing manually.
2019-12-15 18:37:56 +01:00
Camilla Löwy
a43f545677 Add dependency name hints to CMake error messages
Fixes #1605.
2019-12-10 10:56:39 +01:00
Camilla Löwy
59055d585f Update minimum required CMake version to 3.1 2019-12-09 23:48:26 +01:00
Camilla Löwy
135d87aa3c Remove inclusion of X11 extension header paths
They should be found in X11/extensions on every platform.
2019-12-09 23:35:50 +01:00
Camilla Löwy
dff6253ca7 Add installation of HTML documentation 2019-12-09 23:35:50 +01:00
Camilla Löwy
b5d4f24f74 Move CMake uninstall template file to CMake subdir 2019-11-14 21:49:14 +01:00
Camilla Löwy
71e6ff386d Enable CMake policy CMP0077 where available
This will let higher-level projects override GLFW CMake options with
normal variables instead of having to use cache variables.

This means with CMake 3.13 and later you can now do:

set(GLFW_BUILD_TESTS ON)
add_subdirectory(path/to/glfw)

Instead of the more verbose:

set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE)
add_subdirectory(path/to/glfw)
2019-05-24 14:58:54 +02:00
Camilla Löwy
98dde03ce1 Fix variable dereferencing 2019-05-24 14:58:54 +02:00
Camilla Löwy
ceb16cb5f1 X11: Fix CMake check for XInput headers
The X11_Xinput_* variables have been removed in recent CMake, leaving
only the X11_Xi_* set.

Related to #1480.
2019-05-17 17:26:46 +02:00
Camilla Löwy
8ee589e43b Disable examples and tests when a subproject
This changes the default value of the GLFW_BUILD_EXAMPLES and
GLFW_BUILD_TESTS CMake options to false when GLFW is being added as
a subdirectory by another CMake project.

If you want the previous behavior, force these options to true before
adding the GLFW subdirectory:

set(GLFW_BUILD_EXAMPLES ON CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS ON CACHE BOOL "" FORCE)
add_subdirectory(path/to/glfw)

Doing this is backward compatible with earlier versions of GLFW.

The GLFW_BUILD_DOCS option is left enabled as it also requires Doxygen
to have any effect, is quicker to build and is more likely to be useful
when GLFW is a subproject.
2019-05-17 16:12:52 +02:00
Camilla Löwy
cd290f767f Use CMakeDependentOption for dependent options
This replaces the earlier manual logic for dependent CMake options with
the cmake_dependent_option function from CMakeDependentOption.
2019-05-17 16:12:52 +02:00
Camilla Löwy
a255e7ace6 Move to the modern CMake project version option
This replaces the manual ad-hoc version variables we have used since
CMake 2.x (and GLFW 2.x lite).
2019-05-17 16:12:52 +02:00
Camilla Löwy
5c5963f1c0 X11: Only check for headers at build time
GLFW does not require the X11 extension libraries to build or run, so
only fail if the headers are unavailable.
2019-05-17 16:12:52 +02:00
Camilla Löwy
090b16bfae X11: Fix CMake not checking for XInput2 headers
Fixes #1480.
2019-05-17 16:12:52 +02:00
Camilla Löwy
a337c56848 Start 3.4 2019-04-16 23:08:39 +02:00
Camilla Löwy
bd23be2594 Add pkgconfig dependency for GLFW_VULKAN_STATIC 2019-04-15 02:46:07 +02:00
Camilla Löwy
d7e30b1c74 Replace glad and the Vulkan SDK with glad2
This removes all dependencies from the GLFW test programs on the Vulkan
SDK.

It also removes support for linking the GLFW shared library (dynamic
library, DLL) against the Vulkan loader static library.
2019-04-15 02:45:48 +02:00
Rolf Eike Beer
f9923e9095 Use GNUInstallDirs for install destinations
This has the advantage that the user may override e.g. the include
location, and the correct libdir (lib, lib64, lib/something) is
automatically determined.

Closes #1367.
2018-12-03 19:28:31 +01:00
Rolf Eike Beer
df7f36a316 Simplify check for CMake policy CMP0054
Related to #1367.
2018-12-03 19:25:41 +01:00
Emmanuel Gil Peyrot
cc805c0963 Mir: Remove this experimental backend
As of the release of Mir 1.0, libmirclient has been deprecated[1] and
its developers recommend clients using it to switch to Wayland.  This
patch removes support for libmirclient and instruct users to use the
experimental Wayland backend instead.

[1] https://discourse.ubuntu.com/t/mir-news-28th-september-2018/8184
2018-10-05 11:59:26 +02:00