CMake: Only find and link to SDL when needed

This commit is contained in:
Alexander Babikov
2025-07-26 03:09:05 +05:00
parent 437ecbde6c
commit 8915fa9263
3 changed files with 19 additions and 10 deletions

View File

@@ -284,6 +284,15 @@ if(WIN32 AND NOT SDL_JOYSTICK)
target_sources(plat PRIVATE win_joystick_rawinput.c)
target_link_libraries(86Box hid)
else()
find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})
if(STATIC_BUILD AND TARGET SDL2::SDL2-static)
target_link_libraries(86Box SDL2::SDL2-static)
elseif(TARGET SDL2::SDL2)
target_link_libraries(86Box SDL2::SDL2)
else()
target_link_libraries(86Box ${SDL2_LIBRARIES})
endif()
target_sources(plat PRIVATE sdl_joystick.c)
endif()