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 4234 - CMake doesn't correctly install libSDL2.dylib Mac OS
Summary: CMake doesn't correctly install libSDL2.dylib Mac OS
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.1
Hardware: x86_64 Mac OS X (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-08-18 21:47 UTC by Drew Pirrone-Brusse
Modified: 2018-09-24 15:45 UTC (History)
0 users

See Also:


Attachments
A patch that resolves this issue. (1.65 KB, text/plain)
2018-08-18 21:47 UTC, Drew Pirrone-Brusse
Details
The same patch as previously, built from release-2.0.8 (1.63 KB, patch)
2018-09-23 23:39 UTC, Drew Pirrone-Brusse
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Drew Pirrone-Brusse 2018-08-18 21:47:30 UTC
Created attachment 3285 [details]
A patch that resolves this issue.

When running `cmake --build . --target install`, libSDL2.dylib is not correctly installed on Mac OS.

A patch has been included that fixes this issues.

## Repro Steps

1. Set up next-to-source build and install directories,
    `mkdir build install; cd build`
2. Configure CMake (installing to a dummy directory),
    `cmake .. -G Ninja -DCMAKE_INSTALL_PREFIX=../install`
3. Build, but don't install,
    `cmake --build .`
4. Note a .dylib that has been built,
    `ls -l libSDL2.dylib`
    ```
    -rwxr-xr-x  1 drew  staff   1.4M Aug 18 13:37 libSDL2.dylib*
    ```
5. Install,
    `cmake --build . --target install`
6. Take a second look at that .dylib,
    `ls -l libSDL2.dylib`
    ```
    lrwxr-xr-x  1 drew  staff    17B Aug 18 13:39 libSDL2.dylib@ -> libSDL2-2.0.dylib
    ```

## Notes

The root issue are the target properties set on the `SDL2` target for the `APPLE` environment. `MACOSX_RPATH 1` is the only property set, and without `VERSION`, `SOVERSION`, or `OUTPUT_NAME`, the `-2.0` suffix isn't added to the generated dylib.

This patch file also modifies the proceeding `create_symlink` call that expects to target the generated .dylib in a couple ways;
  1. Use CMake's `CMAKE_SHARED_LIBRARY_SUFFIX` constant to choose between .so, .dylib, etc., rather than guessing based on platform.
  2. The `SDL` target's `OUTPUT_NAME` is used in place of a hard-coded string. This doesn't immediately affect anything, but should the target's output name change in the future, the `create_symlink` call won't need to be updated.
  3. Add the `SOPOSTFIX` ("d" for debug builds, "" for everything else) to the symlink's name to keep the symlink for debug builds distinct from the symlink for release builds.

This is a possible duplicate of or corollary to 3713.
Comment 1 Drew Pirrone-Brusse 2018-09-23 23:39:54 UTC
Created attachment 3309 [details]
The same patch as previously, built from release-2.0.8

The first patch I posted was cut from what was then master. I had cause to re-build the patch off of release-2.0.8, and decided that might be worth recording here.
Comment 2 Sam Lantinga 2018-09-24 15:45:22 UTC
Patch added, thanks!
https://hg.libsdl.org/SDL/rev/c0b17b32b95e