Commit Graph

22 Commits

Author SHA1 Message Date
Anonymous Maarten 20c2fa18fe cmake: assume autotools static libraries with lib prefix and .a suffix 2023-02-01 19:15:05 +01:00
Anonymous Maarten 653e433c08 cmake: only add -Wl,--undefined=WinMain when building an executable 2022-09-27 07:00:02 +03:00
Anonymous Maarten 8a08d62ff7 cmake: fix location of SDL2::SDL2test imported library 2022-09-05 21:53:50 +02:00
Anonymous Maarten 5eb0f4328d cmake: always create SDL2::SDL2main target in autotools' cmake config script 2022-08-24 06:20:28 -07:00
Anonymous Maarten 996eb2edb3 cmake: add library directories & pthread to imported targets of sdl2-config.cmake
This fixes linking to SDL2::SDL2-static on systems where external libraries such as X11 are not in a standard location.
Pthread also needs special care.
2022-08-20 19:16:48 -07:00
Anonymous Maarten 53141a56b4
Expand CMake documentation a bit (#5961)
* cmake: remove duplicate check_required_components macro

* Expand docs/README-cmake.md a bit

* cmake: path needs `/` infix
2022-08-09 13:05:03 -07:00
Anonymous Maarten 65473ae36d autoconf: use ax_compute_relative_paths 2022-07-27 21:06:31 +02:00
Anonymous Maarten db7dfece16 cmake: fix name+location of SDL2.dll in configure generated SDL2::SDL2 target 2022-06-28 23:09:28 +02:00
Anonymous Maarten 6d1dfc8322 cmake: make sure SDL2::SDL2 is always available 2022-06-14 20:15:34 -07:00
Simon McVittie 7321537971 cmake: Fix static linking to dependencies with "-" in library name
When SDL is built with Wayland support on Linux, and Wayland libraries
are linked as dependencies instead of being loaded with dlopen(), its
dependencies will include libraries whose names contain a dash, like
`-lwayland-client` and `-ldecor-0`. Don't replace such libraries with
`-lwayland` and `-ldecor`: those don't exist and linking them will fail.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-06-13 06:16:02 -07:00
Anonymous Maarten 246f3ba52c cmake: rewrite autotools' sdl2-config.cmake.in with IMPORTED targets + no more -lmingw32 2022-06-03 12:41:36 -07:00
Daniel Gibson 501fe46597 sdl2-config.cmake.in: Make SDL2::SDL2 work with MinGW, fixes #3665
It didn't work at all because shared libs defined in CMake with
add_library() need something like IMPORTED_IMPLIB (pointing to a .dll.a
or .lib for th DLLs) set to link on Windows.
But even with that it didn't work because the order of the libs is very
important: it must be -lmingw32 -lSDL2main -lSDL -mwindows - but
with normal add_library(SDL2::SDL2 SHARED IMPORTED) libs, SDL2 itself
is always linked first.
So I use an "INTERFACE" library (usually used for header-only libs), which
doesn't implicitly/automatically link anything so I can specify the whole
order of the linked libs.
(SDL2::SDL2-static is completely untested)
2021-07-08 14:55:33 -07:00
Daniel Gibson fac6e9f1e2 sdl2-config.cmake.in: Use more CMake variables and less autotools ones
this makes it easier to create a portable sdl2-config.cmake that doesn't
hardcode its path (by replacing the hardcoded prefix with something
like "${CMAKE_CURRENT_LIST_DIR}/../../..")
2021-07-08 14:55:33 -07:00
Daniel Gibson 3ea11f9acb Make SDL2Config.cmake export SDL2_LIBRARIES etc (on Windows)
still WIP and other platforms than windows still TODO and open
questions etc

see https://github.com/libsdl-org/SDL/issues/4004
2021-07-08 14:55:33 -07:00
James Le Cuirot 99f87a7158 build: Merge pkg-config Libs.private into Libs for static-only builds
A project being built entirely statically will call pkg-config with
--static, which utilises the Libs.private field. Conversely it will
not use --static when not being built entirely statically, even if
there is only a static build of SDL available. This will most likely
cause the build to fail due to underlinking unless we merge the Libs
fields.

This is what the Meson build system does when it generates pkg-config
files. This also also follows the behaviour of sdl2-config.

At the same time, the runtime linker flags are not applicable to
static-only builds so only add them for shared builds.
2020-04-11 23:38:34 +01:00
Flamefire ccc8c5d2cf Fix shared library suffix on OSX 2020-03-17 08:46:34 +01:00
Ryan C. Gordon dd1d8ab62c cmake: more proper sdl2-config.cmake work (thanks, Alexander!)
Fixes Bugzilla #4970.
2020-02-21 15:52:35 -05:00
Ryan C. Gordon be4d488e04 cmake: Backed out changeset 9009d85d3762
This is being replaced by a different patch (see Bugzilla #4970).
2020-02-21 15:51:04 -05:00
Ryan C. Gordon 229c2f8f5f cmake: Add PACKAGE_VERSION and SDL2_VERSION to sdl2-config.cmake.in
Fixes Bugzilla #4970.
2020-02-14 13:37:32 -05:00
Sam Lantinga 5c1ab40302 Applied Ubuntu patch bug_822210_fix_sdl2-config.cmake_whitespace.patch 2016-10-07 15:08:37 -07:00
Ryan C. Gordon 2f59284971 Fixed typo in sdl2-config.cmake.in (thanks, Rafal!).
Partially fixes Bugzilla #3208.
2015-12-28 23:29:11 -05:00
Sam Lantinga bf9bd59c01 Fixed bug 2464 - Configure a sdl2-config.cmake.in together with sdl2.pc.in
Leonardo

Despite having a CMakeLists.txt file, SDL2 seems to be mainly built using the autotools system by package-managers. It is nice to have it but it is only useful if you are building SDL2 by yourself.

People that want to use CMake to find their already-installed SDL2 are using a FindSDL2.cmake module based on the old FindSDL.cmake. This is not deprecated but it is discouraged by the CMake devs (see http://www.cmake.org/Bug/view.php?id=14826), as these modules needs maintainers to be included in the official CMake installation.

To fix that, SDL and its accompanying libraries could configure a simple sdl2-config.cmake file, much like it does with sdl2.pc.in. We don't need to configure a full sdl2-config.cmake as in this post, http://forums.libsdl.org/viewtopic.php?t=10068&sid=ccf8abbf0d73fb03ae9cded991e60959 (because it depends on it being built with CMake). Using something as simple as http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Package_Configuration_Files is deemed enough. Here is another: http://quickgit.kde.org/?p=prison.git&a=blob&f=lib%2Fprison%2FPrisonConfig.cmake.in
2015-06-29 22:24:00 -07:00