Skip to content

Commit

Permalink
Fixup for sdl2 on ubuntu 20.04 CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ptheywood committed Nov 29, 2022
1 parent 3a76d08 commit bfbfcda
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cmake/dependencies/sdl2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,21 @@ if(UNIX)
if (NOT SDL2_FOUND)
message(FATAL_ERROR "sdl2 is required for building, install it via your package manager.\n"
"e.g. sudo apt install libsdl2-dev")
endif ()
else()
# If no imported targets are provided, make one, using variables from the older find_package(SDL2).
# Tested on ubuntu 20.04 / libsdl2-dev 2.0.10+dfsg1-3
if (NOT TARGET SDL2::SDL2)
# If we have a ${libdir} from the above find_package sdl2, use that.
if(${libdir})
set(SDL2_LIBDIR ${libdir})
endif()
add_library(SDL2::SDL2 SHARED IMPORTED)
set_target_properties(SDL2::SDL2 PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${SDL2_LIBDIR}/${CMAKE_SHARED_LIBRARY_PREFIX}SDL2${CMAKE_SHARED_LIBRARY_SUFFIX}")
endif()
endif()
elseif(WIN32)
# On windows, always download manually. There are issues with find_package and multi-config generators where a release library will be found, but no debug library, which can break things.
# Declare source properties
Expand Down Expand Up @@ -42,4 +56,4 @@ mark_as_advanced(FETCHCONTENT_FULLY_DISCONNECTED)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED)
mark_as_advanced(FETCHCONTENT_SOURCE_DIR_SDL2)
mark_as_advanced(FETCHCONTENT_UPDATES_DISCONNECTED_SDL2)
mark_as_advanced(SDL2_DIR)
mark_as_advanced(SDL2_DIR)

0 comments on commit bfbfcda

Please sign in to comment.