-
Notifications
You must be signed in to change notification settings - Fork 58
Don't trigger find_package when user builds a shared-lib version of SDL3
#174
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
base: main
Are you sure you want to change the base?
Conversation
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) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
@Sand3r- Can you check your use case with my change? Note to maintainers: this PR should be merged with "Squash and merge" |
Currently when user builds SDL_shadercross along with a shared-library version of SDL3, the check
if(NOT TARGET SDL3::SDL3-static)inCMakeLists.txtwon't block the package search withfind_packagebecause 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:This PR extends the check to also cover for the SDL3 shared library case.