Skip to content

test: New SDL_TESTS_LINK_SHARED option for dynamically linked tests#15907

Open
Antonios-C wants to merge 1 commit into
libsdl-org:SDL2from
Antonios-C:SDL_TESTS_SHARED_LIB
Open

test: New SDL_TESTS_LINK_SHARED option for dynamically linked tests#15907
Antonios-C wants to merge 1 commit into
libsdl-org:SDL2from
Antonios-C:SDL_TESTS_SHARED_LIB

Conversation

@Antonios-C

@Antonios-C Antonios-C commented Jun 30, 2026

Copy link
Copy Markdown

Introduce SDL_TESTS_LINK_SHARED to allow tests that expect dynamic linking to be built.

  • I confirm that I am the author of this code and release it to the SDL project under the Zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

Description

When enabling tests to be built right now, they come with libsdl2 statically compiled within. Introduce a new configuration option SDL_TESTS_LINK_SHARED to allow users to specify if they want the test executable to expect to be linked dynamically to libsdl2.

Since tests have been being built by default with static libs since 2018 (6cf4d0e), the default will remain still that. Users need to go out of their way to enable SDL_TESTS_LINK_SHARED.

Comment thread test/CMakeLists.txt Outdated

if(NOT TARGET SDL2::SDL2-static)
find_package(SDL2 2.0.23 REQUIRED COMPONENTS SDL2-static SDL2test)
option(SDL_TESTS_SHARED_LIB "Link test executables against the shared SDL2 library" OFF)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SDL3 has SDL_TESTS_LINK_SHARED that serves the same purpose. Perhaps re-use this name?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh didn't check SDL3. I'll reuse the name ! Will send revision

@sezero

sezero commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Why do we really want this at all? (And in SDL2??) None of the functions even go though export/visibility stuff.

I'd suggest not accepting this.

@Antonios-C

Copy link
Copy Markdown
Author

@sezero Not sure what you mean by "None of the functions even go though export/visibility stuff." can you elaborate ?

From my experience, test executable should at least have the option to dynamically link with libraries. After all, that is a test within itself, "hey are the necessary libraries to run this binary present on the filesystem? " .

Introduce SDL_TESTS_LINK_SHARED to allow tests that expect dynamic linking
to be built.

Signed-off-by: Antonios Christidis <a-christidis@ti.com>
@Antonios-C Antonios-C force-pushed the SDL_TESTS_SHARED_LIB branch from 9651241 to 0d864a7 Compare June 30, 2026 18:14
@Antonios-C Antonios-C changed the title test: New SDL_TESTS_SHARED_LIB option for dynamically linked tests test: New SDL_TESTS_LINK_SHARED option for dynamically linked tests Jun 30, 2026
@sezero

sezero commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

@sezero Not sure what you mean by "None of the functions even go though export/visibility stuff." can you elaborate ?

From my experience, test executable should at least have the option to dynamically link with libraries. After all, that is a test within itself, "hey are the necessary libraries to run this binary present on the filesystem? " .

It was a complete misunderstanding of the purpose of this patch on my part: Please ignore my remarks, and sorry for the noise.

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.

3 participants