Files
yaze/cmake/sdl2.cmake

56 lines
1.8 KiB
CMake

# SDL2
if (UNIX OR MINGW OR WIN32)
add_subdirectory(src/lib/SDL)
# When using bundled SDL, use the static target and set include directories
set(SDL_TARGETS SDL2-static)
set(SDL2_INCLUDE_DIR
${CMAKE_SOURCE_DIR}/src/lib/SDL/include
${CMAKE_BINARY_DIR}/src/lib/SDL/include
${CMAKE_BINARY_DIR}/src/lib/SDL/include-config-${CMAKE_BUILD_TYPE}
)
# Also set for consistency with bundled SDL
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR})
else()
find_package(SDL2)
# When using system SDL, use the imported targets
set(SDL_TARGETS SDL2::SDL2)
if(WIN32)
list(PREPEND SDL_TARGETS SDL2::SDL2main ws2_32)
add_definitions("-DSDL_MAIN_HANDLED")
endif()
endif()
# libpng and ZLIB dependencies
if(WIN32)
# Windows builds with vcpkg (Abseil removed to avoid MSYS2 issues)
if(NOT YAZE_MINIMAL_BUILD)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(GLEW REQUIRED)
else()
# For CI/minimal builds, try to find but don't require
find_package(ZLIB QUIET)
find_package(PNG QUIET)
find_package(GLEW QUIET)
if(NOT ZLIB_FOUND OR NOT PNG_FOUND)
message(STATUS "PNG/ZLIB not found in minimal build, some features may be disabled")
set(PNG_FOUND FALSE)
set(PNG_LIBRARIES "")
set(PNG_INCLUDE_DIRS "")
endif()
endif()
elseif(YAZE_MINIMAL_BUILD)
# For CI builds on other platforms, try to find but don't require
find_package(ZLIB QUIET)
find_package(PNG QUIET)
if(NOT ZLIB_FOUND OR NOT PNG_FOUND)
message(STATUS "PNG/ZLIB not found in minimal build, some features may be disabled")
set(PNG_FOUND FALSE)
set(PNG_LIBRARIES "")
set(PNG_INCLUDE_DIRS "")
endif()
else()
# Regular builds require these dependencies
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
endif()