We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4225 - MacOS - sdl2-config.cmake is missing and if you ./configure it got the wrong path
Summary: MacOS - sdl2-config.cmake is missing and if you ./configure it got the wrong ...
Status: NEW
Alias: None
Product: SDL
Classification: Unclassified
Component: build (show other bugs)
Version: 2.0.8
Hardware: x86_64 macOS 10.13
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-11 13:12 UTC by Anders Nauman
Modified: 2019-04-14 14:41 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anders Nauman 2018-08-11 13:12:43 UTC
I started with the pre-compiled package from the website https://www.libsdl.org/release/SDL2-2.0.8.dmg which have this note inside:

"To Install:
Copy the SDL2.framework to /Library/Frameworks"

But this package doesnt add any file related to CMake.

If you configure(./configure) the source code and copy the sdl2-config.cmake to /Library/Frameworks/SDL2.framework/Resources/ CMake will then find the config-file.
But it now contains the wrong paths to headers etc:

cat sdl2-config.cmake
# sdl2 cmake project-config input for ./configure scripts

set(prefix "/usr/local") 
set(exec_prefix "${prefix}")
set(libdir "${exec_prefix}/lib")
set(SDL2_PREFIX "/usr/local")
set(SDL2_EXEC_PREFIX "/usr/local")
set(SDL2_LIBDIR "${exec_prefix}/lib")
set(SDL2_INCLUDE_DIRS "${prefix}/include/SDL2")
set(SDL2_LIBRARIES "-L${SDL2_LIBDIR}  -lSDL2")
string(STRIP "${SDL2_LIBRARIES}" SDL2_LIBRARIES)

For example, SDL2_INCLUDE_DIRS should point to /Library/Frameworks/SDL2.framework/Headers but it tries to find everything at /usr/local/include/SDL2.

I have not done a make && make install since the install instructions in the .dmg-file says something different.

Guess the solution is either ship the .dmg with correct files or make all MacOS users compile it themselves.
In meanwhile im providing myself with a FindSDL2.cmake file to solve this issue but it would be nice to have it working out of the box(with a .dmg).

I am not a pro in CMake but if you want me to help in any way, please let me know.
Comment 1 Leonardo 2019-04-13 18:57:58 UTC
Hey, I have created bug 5497 that tries to partially addresses your issue, it incorporate features of FindSDL2.cmake into sdl2-config.cmake. Would you mind trying replacing the current sdl2-config.cmake with it and reporting back if it works?

As for the .dmg having the sdl2-config.cmake bundled in, I suppose this is not an CMake issue but how the dmg was created, which I don't know yet how to fix.
Comment 2 Leonardo 2019-04-13 18:58:26 UTC
Sorry, it's bug 4597 :)
Comment 3 foo.null 2019-04-14 14:41:36 UTC
cmake is probably doing the "right" thing by assuming SDL headers are where autoconf installed to.

The dmg path ought to be treated as a different path. Also anyone familiar with macOS development ought to know that copying frameworks to /Library/ or other global path is bad advice, because frameworks have to be copied/bundled inside app bundles and having frameworks there may create false sense of working-ness.

The dmg path should be "copy SDL.framework into your project", link it, bundle it in your app. Common workflow.