diff --git a/.gitmodules b/.gitmodules index 99e41138b..61b6c2ff6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/madler/zlib [submodule "thirdparty/SDL2"] path = thirdparty/SDL2 - url = https://github.com/spurious/SDL-mirror.git + url = https://github.com/libsdl-org/SDL diff --git a/CMakeLists.txt b/CMakeLists.txt index 790138484..711605317 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 4.0) if(CMAKE_MAJOR_VERSION STRGREATER 3) cmake_policy(SET CMP0054 NEW) endif() diff --git a/CMakeModules/FindOrBuild.cmake b/CMakeModules/FindOrBuild.cmake index 904b9ddaf..37a8a0bcd 100644 --- a/CMakeModules/FindOrBuild.cmake +++ b/CMakeModules/FindOrBuild.cmake @@ -30,16 +30,25 @@ macro(FindOrBuildSDL2) set(SDL_AUDIO FALSE) set(SDL_JOYSTICK FALSE) set(SDL_HAPTIC FALSE) - set(SDL_SHARED FALSE) + # Forcing static build on Windows as SDL2main is often needed and easier to link statically. + # Set SDL_SHARED to OFF *before* adding the subdirectory to influence its build. + set(SDL_SHARED OFF CACHE BOOL "Build SDL2 as a static library" FORCE) endif() - add_subdirectory(${CMAKE_SOURCE_DIR}/thirdparty/SDL2) + # Add the subdirectory. This creates targets like SDL2::SDL2, SDL2::SDL2-static, SDL2::SDL2main + add_subdirectory(${CMAKE_SOURCE_DIR}/thirdparty/SDL2 ${CMAKE_BINARY_DIR}/thirdparty/SDL2) set(SDL2_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/thirdparty/SDL2/include ${CMAKE_BINARY_DIR}/thirdparty/SDL2) + # Linking against SDL2::SDL2 below handles includes automatically. if(EMSCRIPTEN) - set(SDL2_LIBRARY SDL2-static) + # Emscripten typically uses static linking + set(SDL2_LIBRARY SDL2::SDL2-static) # Use the CMake target else() - set(SDL2_LIBRARY SDL2) + # Link against SDL2 (shared or static based on SDL_SHARED) and SDL2main + # SDL2::SDL2 resolves to the correct shared/static target. + # SDL2::SDL2main is needed on many platforms, especially Windows. + set(SDL2_LIBRARY SDL2::SDL2 SDL2::SDL2main) # Use the CMake targets endif() elseif(NOT EMSCRIPTEN) + # If not building from source, use the find_package module find_package(SDL2) endif() endmacro() @@ -228,4 +237,3 @@ endmacro() macro(FindOrBuildPSPSDK) find_package(PSPSDK COMPONENTS psppower pspmpeg pspaudiocodec pspaudiolib pspaudio pspmp3 pspgum pspgu psprtc pspfpu REQUIRED) endmacro() - diff --git a/thirdparty/libpng/png.h b/thirdparty/libpng/png.h index 315cf2c03..80929899d 100644 --- a/thirdparty/libpng/png.h +++ b/thirdparty/libpng/png.h @@ -474,7 +474,7 @@ #ifndef PNG_VERSION_INFO_ONLY /* include the compression library's header */ -#include "../include/zlib.h" +#include "zlib.h" #endif /* include all user configurable info, including optional assembler routines */