Skip to content

Conversation

@Sand3r-
Copy link

@Sand3r- Sand3r- commented Sep 16, 2025

Currently when user builds SDL_shadercross along with a shared-library version of SDL3, the check if(NOT TARGET SDL3::SDL3-static) in CMakeLists.txt won't block the package search with find_package because it only verifies if the target of a static version of SDL3 library is present. If user doesn't have SDL3 installed in the system, the build will fail resulting with:

CMake Warning at external/SDL_shadercross/CMakeLists.txt:26 (find_package):
  By not providing "FindSDL3.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "SDL3", but
  CMake did not find one.

  Could not find a package configuration file provided by "SDL3" (requested
  version 3.1.3) with any of the following names:

    SDL3Config.cmake
    sdl3-config.cmake

  Add the installation prefix of "SDL3" to CMAKE_PREFIX_PATH or set
  "SDL3_DIR" to a directory containing one of the above files.  If "SDL3"
  provides a separate development package or SDK, be sure it has been
  installed.

This PR extends the check to also cover for the SDL3 shared library case.

CMakeLists.txt Outdated
include("${CMAKE_CURRENT_LIST_DIR}/cmake/sdlmanpages.cmake")

if(NOT TARGET SDL3::SDL3-static)
if(NOT TARGET SDL3::SDL3-static AND NOT TARGET SDL3::SDL3)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather do something smart as we do in SDL_image.

If SDLSHADERCROSS_SHARED is true, then the SDL3::SDL3-shared target must be available (SDL3-shared component)
If SDLSHADERCROSS_STATIC is true, then the SDL3::Headers target must be available (Headers component)

Copy link
Author

Choose a reason for hiding this comment

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

Updated

Copy link
Contributor

Choose a reason for hiding this comment

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

We're getting closer :)

SDL_shadercross' CMakeLists.txt is also different from that from SDL_image: SDL_image supports building only a single library: shared or static (not both). SDL_shadercross can build both a shared and static library.

So you need to keep the current if(BUILD_SHARED_LIBS) set(SDLSHADERCROSS_(SHARED|STATIC)_DEFAULT ) if/else,
then do these options

option(SDLSHADERCROSS_SHARED "Build shared SDL_shadercross library" ${SDLSHADERCROSS_SHARED_DEFAULT})
option(SDLSHADERCROSS_STATIC "Build static SDL_shadercross library" ${SDLSHADERCROSS_STATIC_DEFAULT})

And after these variables are correctly initialized can you calculate what targets/components you need, and call find_package.

Copy link
Author

@Sand3r- Sand3r- Sep 18, 2025

Choose a reason for hiding this comment

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

Thanks for the suggestion. I have moved the condition to be present after the options and it now checks for the appropriate targets depending on whether SDLSHADERCROSS_SHARED or SDLSHADERCROSS_STATIC are set to ON before running find_package.

@madebr
Copy link
Contributor

madebr commented Sep 20, 2025

@Sand3r- Can you check your use case with my change?

Note to maintainers: this PR should be merged with "Squash and merge"

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.

2 participants