Skip to content

Commit

Permalink
Merge pull request #64 from FosterFramework/revert-63-main
Browse files Browse the repository at this point in the history
Revert "Correct SDL2 cmake for non-ubuntu platforms"
  • Loading branch information
NoelFB authored Feb 7, 2024
2 parents 426b195 + dfa2ab1 commit a407a16
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions Platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,34 +99,31 @@ if (EMSCRIPTEN)

# Pull SDL2 from its Github repo
else()
if (DEFINED FOSTER_SDL2_LIBS)
set(SDL2_LIBRARIES ${FOSTER_SDL2_LIBS})
set(SDL2_INDLUDE_DIRS ${FOSTER_SDL2_INCLUDE})
# Tell external SDL it's going to be a shared lib
set_property(TARGET ${FOSTER_SDL2_LIBS} PROPERTY POSITION_INDEPENDENT_CODE ON)
else()
if (NOT DEFINED FOSTER_SDL2_LIBS)
include(FetchContent)
set(FETCHCONTENT_QUIET FALSE)
set(FETCHCONTENT_TRY_FIND_PACKAGE_MODE ALWAYS)
set(SDL_VERSION 2.30.0)
set(SDL_TEST_ENABLED_BY_DEFAULT OFF)
set(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
set(SDL_STATIC_ENABLED_BY_DEFAULT ON)

FetchContent_Declare(
SDL2
GIT_REPOSITORY https://github.com/libsdl-org/SDL
GIT_TAG release-${SDL_VERSION}
GIT_TAG release-2.30.0
GIT_PROGRESS TRUE
FIND_PACKAGE_ARGS ${SDL_VERSION}
)
set(SDL_TEST OFF)
set(SDL_SHARED OFF)
set(SDL_STATIC ON)
set(SDL_STATIC_PIC ON)
FetchContent_MakeAvailable(SDL2)
set(SDL2_LIBRARIES ${SDL2_LIBRARIES} SDL2-static)
set(SDL2_INCLUDE_DIRS ${SDL2_SOURCE_DIR}/include)
set(FOSTER_SDL2_LIBS SDL2-static)
set(FOSTER_SDL2_INCLUDE ${sdl2_SOURCE_DIRS}/include)
endif()
set(LIBS ${LIBS} ${SDL2_LIBRARIES})
target_include_directories(${TARGET_NAME} PRIVATE ${SDL2_INCLUDE_DIRS})

# statically link SDL2 since we're building it ourselve
set(LIBS ${LIBS} ${FOSTER_SDL2_LIBS})
target_include_directories(${TARGET_NAME} PRIVATE ${FOSTER_SDL2_INCLUDE})
endif()

# Tell SDL it's going to be a shared lib
set_property(TARGET ${FOSTER_SDL2_LIBS} PROPERTY POSITION_INDEPENDENT_CODE ON)

# Link SDL
target_link_libraries(${TARGET_NAME} PRIVATE ${LIBS})

0 comments on commit a407a16

Please sign in to comment.