-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[macOS] SDL2::SDL2main target is not defined. #6119
Comments
Indeed, Lines 62 to 73 in 50c5d23
This should probably be changed to something behaving as follows (removing the if(_sdl2_libraries MATCHES ".*SDL2main.*")
list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main)
list(INSERT SDL2_STATIC_LIBRARIES 0 SDL2::SDL2main)
endif()
if(1)
set(_sdl2main_library ${SDL2_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}SDL2main${CMAKE_STATIC_LIBRARY_SUFFIX})
if(EXISTS "${_sdl2main_library}")
set(SDL2MAIN_LIBRARY SDL2::SDL2main)
if(NOT TARGET SDL2::SDL2main)
add_library(SDL2::SDL2main STATIC IMPORTED)
set_target_properties(SDL2::SDL2main
PROPERTIES
IMPORTED_LOCATION "${_sdl2main_library}"
) |
When I last extracted the dmg (I don't own a Mac), I only saw a single SDL2 thing which I presumed to be the SDL2 shared library. FYI, this is how the SDL/Xcode/SDL/pkg-support/resources/CMake/sdl2-config.cmake Lines 51 to 61 in 50c5d23
|
I can confirm that this patch works for the homebrew version.
SDL2main does nothing on macOS and it's not shipped in the framework. If you build from source the library just defines a |
I'll create a pr for it. It's very small and probably a candidate for 2.24.x.
We can't create an imported cmake target for a library that does not exist.
I think(!) the reason the dmg does not ship an SDL2main static library is because Macos does not need it. Neither In the CMake test, it is not assumed |
Previously, if you were trying to find the framework through CMake you'd have to use With that in mind, I would tend to say that the target should remain available to avoid breaking existing projects. Looking at the framework's headers, it should be safe to simply create a dummy if(NOT TARGET SDL2::SDL2main)
add_library(SDL2::SDL2main INTERFACE IMPORTED)
endif() |
I'll add that to the pr :) |
SDL2 2.24.0 has a bug in its cmake for macOS: libsdl-org/SDL#6119 This bug has already been fixed upstream. This is a workaround until the next version of SDL2 is released.
SDL2 2.24.0 has a bug in its cmake for macOS: libsdl-org/SDL#6119 This bug has already been fixed upstream. This is a workaround until the next version of SDL2 is released.
SDL2 2.24.0 has a bug in its cmake for macOS: libsdl-org/SDL#6119 This bug has already been fixed upstream. This is a workaround until the next version of SDL2 is released.
SDL2 2.24.0 has a bug in its cmake for macOS: libsdl-org/SDL#6119 This bug has already been fixed upstream. This is a workaround until the next version of SDL2 is released.
SDL2 2.24.0 has a bug in its cmake for macOS: libsdl-org/SDL#6119 This bug has already been fixed upstream. This is a workaround until the next version of SDL2 is released.
Starting version 2.24.0, the CMake target
SDL2::SDL2main
is no longer defined on macOS even when the library itself is present.I have already seen a few reports of that issue from other macOS users in the discord server and one on the discourse forum.
The error happens when using SDL2 packaged from homebrew (uses
autotools
and installs alibSDL2main.a
file), as well as the official release using the Apple framework.Here is a sample project to reproduce the issue and the exact error message:
The text was updated successfully, but these errors were encountered: