Commit Graph

190 Commits

Author SHA1 Message Date
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
111c02d74e POSIX: Remove use of deprecated gettimeofday
POSIX.1-2008 deprecated gettimeofday, which we used as a fallback if the
monotonic clock was unavailable.

This replaces that fallback with the non-monotonic real-time clock.

Because of the Gordian knot of feature test macros across Unices, this
also includes the shift from some platform source files defining
_POSIX_C_SOURCE to various values to _DEFAULT_SOURCE being defined for
all source files on Linux.  This is because -std=c99 on Linux disables
_DEFAULT_SOURCE (POSIX 2008 and extensions).

Once runtime platform selection comes in, this kind of platform-specific
preprocessor logic can be moved into the platform glue files and won't
need to be replicated by third-party build setups, but for now, sorry.
2021-08-13 17:18:56 +02:00
Camilla Löwy
01778329ec Add custom target for updating gamepad mappings 2021-08-01 20:16:17 +02:00
Camilla Löwy
9a3a8bc267 Win32: Always define UNICODE and _UNICODE 2021-04-23 14:46:47 +02:00
Camilla Löwy
a646f51bca Win32: Fix macros being enabled for other backends
_UNICODE should not be defined for other backends even when built on
Windows.
2021-04-23 14:46:47 +02:00
Konstantin Podsvirov
e3f916808d Fix hardcoded runtime destination in CMake install
Closes #1883.
Closes #1884.
2021-04-22 22:47:16 +02:00
Camilla Löwy
061a0263a9 Win32: Fix compilation with standalone LLVM
The /clang: suffix passed to Clang-CL was accidentally also passed to
the regular standalone Clang, which caused compilation to fail.  We now
pass /W3 to Clang-CL, which it interprets as -Wall.

The _CRT_SECURE_NO_WARNINGS macro is now defined for both Clang and
Clang-CL.

The /entry: flag passed to link.exe is now also passed to lld-link,
letting the windows subsystem tests and examples link.

Fixes #1807.
Closes #1824.
Closes #1874.
2021-04-22 22:37:37 +02:00
Laurent Aphecetche
384ff74a46 Cocoa: Fix install name for installed dylib
The install name was incorrectly set to a relative path.

This change leaves the install name of the installed dylib as
@rpath/soname.  Those who wish to override this can set the
CMAKE_INSTALL_NAME_DIR variable.

Closes #1504.
2021-01-18 23:52:27 +01:00
Camilla Löwy
f8d6801a50 Simplify references in CMake if-statements 2021-01-18 23:52:27 +01:00
Camilla Löwy
3327050ca6 Cocoa: Fix ObjC being built as C with CMake 3.19
CMake 3.19 adds -xc when the LANGUAGE file property is C, breaking our
workaround for CMake 3.15 and earlier not understanding the .m suffix.

Fixes #1787.
2020-11-18 00:11:13 +01:00
Camilla Löwy
2f76f70c76 Wayland: Simplify adding of protocol sources 2020-11-11 19:11:38 +01:00
Camilla Löwy
420b165bff Wayland: Fix indentation 2020-11-11 19:11:38 +01:00
Camilla Löwy
a62a6c5019 Wayland: Scanner tool has input and output args 2020-11-11 19:11:38 +01:00
Camilla Löwy
d5f32dfb3b Wayland: Ensure paths are passed on in quoted form 2020-11-11 19:11:38 +01:00
Camilla Löwy
a6f8cc9d44 Fix unquoted paths with variable references
Whitespace is a field separator in CMake.
2020-11-11 19:11:38 +01:00
Joel Winarske
af8f9713dd Wayland: Fix CMake binary dir when built as subdir
Regression introduced by 2747e47393.

Related to #1782.
2020-11-11 19:10:19 +01:00
Camilla Löwy
ac627706ef Win32: Fix clang-cl interpreting -Wall as /Wall
Unlike -Wall, VS /Wall really means all warnings.

Closes #1780.
2020-11-11 19:10:05 +01:00
Camilla Löwy
6b78419c9a Win32: Enable /W3 on VS for library sources
/W3 is the default for new VS projects and the library builds cleanly
with it on VS 2010-2019 so let's try to keep it that way.
2020-11-11 19:09:10 +01:00
Camilla Löwy
9b140d08d7 Remove ignored Clang compiler flag
Clang ignores this when C99 is enabled, while GCC does not.  Removing
the checks for Clang to hopefully avoid a false sense of security.
2020-11-11 19:07:26 +01:00
Emmanuel Gil Peyrot
2e6fb7fe22 Wayland: Remove extra trailing whitespace 2020-09-30 17:02: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
c1f60ab5dc Make compiler specific workarounds more consistent 2020-06-08 01:07:35 +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
bc3be40f21 Enable strict C99 for non-VS compilers 2019-12-16 12:48:32 +01:00
Camilla Löwy
fb0028c766 Win32: Enable Unicode mode for all compilers 2019-12-15 18:37:57 +01:00
Camilla Löwy
994c3b4e48 Cocoa: Remove stale GCC workaround 2019-12-15 18:37:57 +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
a5ed740d9d Fix use of CMake 3.13 command target_link_options 2019-12-15 18:37:56 +01:00
Camilla Löwy
a264d32987 Replace CMake list variables with target_sources 2019-12-15 18:37:56 +01:00
Camilla Löwy
2551829f75 Win32: Add VERSIONINFO resource to GLFW DLL
This will let people see the API version in the Explorer property box.
2019-12-11 21:02:08 +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
c194193797 Replace CMake generator expression with variable
Generator expressions are amazing but best used in moderation.
2019-12-09 23:35:51 +01:00
Camilla Löwy
9dc365f192 Merge GCC/Clang specific CMake blocks 2019-12-09 23:35:51 +01:00
Camilla Löwy
197193ac0b Fix source list for Objective-C fix 2019-12-09 23:35:51 +01:00
Camilla Löwy
9486ec0c02 Fix source list for -Wdeclaration-after-statement
The context creation files were not included on platforms other than
Win32.
2019-12-09 23:35:50 +01:00
Camilla Löwy
bc7b19cbd1 Remove tab character 2019-12-09 23:35:50 +01:00
Camilla Löwy
f6d44cedfd Trust CMake to do the right thing for static libs
CMake understands what private library dependencies for a static library
means and handles it correctly.
2019-12-09 23:35:40 +01:00
Camilla Löwy
33683ec60e Remove stray characters from hardcoded CFLAGS
The additional '>' characters were appended to the compiler option.

Related to #1576.
2019-10-29 12:04:47 +01:00
Camilla Löwy
04f7f55f07 Cleanup
Related to #1585.
2019-10-29 12:04:47 +01:00
Pablo Prietz
4d0ae4ffa7 Fix CMake 3.0 - 3.6 support regression
Replaces `VERSION_GREATER_EQUAL` with `VERSION_EQUAL OR
VERSION_GREATER`.  `VERSION_GREATER_EQUAL` was only added in CMake 3.7.

Fixes #1584.
Closes #1585.
2019-10-29 12:04:46 +01:00
Guillaume Racicot
8f852e0833 Enable C99 explicitly with CMake where available
This enables compilation as C99 where supported by the compiler.
A workaround with per-compiler hardcoded flags is used for CMake 3.0,
which does not support the C_STANDARD target property.

Fixes #1560.
Closes #1576.
2019-10-16 02:33:12 +02:00
Camilla Löwy
3ec8f4a7f5 Win32: Disable dynamic libgcc for MinGW DLL 2019-10-03 21:05:49 +02:00
Ave Milia
2e039d9275 CMake: remove -DGLFW_DLL on non-Windows targets
When using GLFW with CMake and installed GLFW binaries, `-DGLFW_DLL` is
passed on Linux, which should not happen.

Closes #1530.
2019-07-22 21:37:22 +02:00
Camilla Löwy
b430bc4935 Cocoa: Fix internal symbol hiding for dylib
The default symbol visibility was not set to hidden on macOS.
2019-07-16 23:14:16 +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
Konstantin Podsvirov
15af302f77 Fix use of absolute path in INSTALL_INTERFACE
Closes #1470.
2019-05-17 16:12:52 +02:00