From dfa2ab1804f72570561e96b77cdf87c57a793e25 Mon Sep 17 00:00:00 2001 From: Noel Berry Date: Wed, 7 Feb 2024 12:29:42 -0800 Subject: [PATCH] Revert "Correct SDL2 cmake for non-ubuntu platforms" --- Platform/CMakeLists.txt | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/Platform/CMakeLists.txt b/Platform/CMakeLists.txt index ad0bdf9..6f5b410 100644 --- a/Platform/CMakeLists.txt +++ b/Platform/CMakeLists.txt @@ -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})