Skip to content
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

Fix static linking to Autotools builds using CMake #412

Merged
merged 3 commits into from Jun 17, 2022

Conversation

smcv
Copy link
Contributor

@smcv smcv commented Jun 17, 2022

  • autotools: Move mandatory dependencies from EXTRA_LDFLAGS to MIXER_LIBS

    Autotools variables whose names end with _LDFLAGS are usually for
    linker options such as -Wl,--export-dynamic which would not be
    appropriate to copy into the pkg-config or CMake metadata.

    Move these dependencies into a separate _LIBS variable, which is
    conventionally a list of -L and -l options (only) and can be copied
    into pkg-config or CMake metadata. This follows the same pattern as
    IMG_LIBS and TTF_LIBS in SDL_image and SDL_ttf.

    Exclude SDL_LIBS from this, because the CMake metadata has a special
    case for finding SDL, and linking to a different SDL causes link failure
    on our macOS CI. Link SDL via $(SDL_LIBS) instead.

  • sdl2_mixer-config.cmake.in: Use MIXER_LIBS for static linking

    We can't rely on all mandatory dependencies being in PC_LIBS, because
    if we found a dependency such as libflac via pkg-config, we would have
    put the name of the pkg-config module in PC_REQUIRES instead.

    Resolves: Static linking of dependent program with CMake fails in Autotools build with --disable-foo-shared #411

smcv added 2 commits June 17, 2022 12:39
Autotools variables whose names end with _LDFLAGS are usually for
linker options such as -Wl,--export-dynamic which would not be
appropriate to copy into the pkg-config or CMake metadata.

Move these dependencies into a separate _LIBS variable, which is
conventionally a list of -L and -l options (only) and *can* be copied
into pkg-config or CMake metadata. This follows the same pattern as
IMG_LIBS and TTF_LIBS in SDL_image and SDL_ttf.

Exclude SDL_LIBS from this, because the CMake metadata has a special
case for finding SDL, and linking to a different SDL causes link failure
on our macOS CI. Link SDL via $(SDL_LIBS) instead.

Signed-off-by: Simon McVittie <smcv@collabora.com>
We can't rely on all mandatory dependencies being in PC_LIBS, because
if we found a dependency such as libflac via pkg-config, we would have
put the name of the pkg-config module in PC_REQUIRES instead.

Resolves: libsdl-org#411
Signed-off-by: Simon McVittie <smcv@collabora.com>
@smcv smcv marked this pull request as ready for review June 17, 2022 11:49
@madebr madebr merged commit f1d5e8f into libsdl-org:main Jun 17, 2022
@madebr
Copy link
Contributor

madebr commented Jun 17, 2022

Thanks!
The cmake config script now works with all dependencies being non-dynamic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Static linking of dependent program with CMake fails in Autotools build with --disable-foo-shared
2 participants