Skip to content

Commit

Permalink
Add SDL2 building to CMake as default
Browse files Browse the repository at this point in the history
Let homebrew platforms still use SDL1.2
  • Loading branch information
carstene1ns committed Oct 24, 2023
1 parent 5f4c3ba commit 1e9730f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
28 changes: 17 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ set(CMAKE_CXX_STANDARD_REQUIRED OFF)
include(Platform-Helpers)

# Endianess check

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
include(TestBigEndian)
test_big_endian(PLATFORM_BIGENDIAN)
if(PLATFORM_BIGENDIAN)
add_compile_definitions(WORDS_BIGENDIAN=1)
endif()
include(TestBigEndian)
test_big_endian(PLATFORM_BIGENDIAN)
if(PLATFORM_BIGENDIAN)
add_compile_definitions(WORDS_BIGENDIAN=1)
endif()

# OpenJazz
Expand Down Expand Up @@ -131,7 +128,7 @@ target_include_directories(OpenJazz PUBLIC src)
option(SCALE "Allow scaling" ${OJ_SCALE})
if(SCALE)
target_compile_definitions(OpenJazz PRIVATE SCALE)
set(OJ_SCALE_LIBS scale2x)
set(OJ_LIBS_SCALE scale2x)
endif()

# path to game data
Expand All @@ -143,8 +140,16 @@ endif()

# libraries

find_package(SDL REQUIRED)
target_include_directories(OpenJazz PRIVATE ${SDL_INCLUDE_DIR})
if(SDL_LEGACY)
find_package(SDL REQUIRED)
target_include_directories(OpenJazz PRIVATE ${SDL_INCLUDE_DIR})
set(OJ_LIBS_SDL ${SDL_LIBRARY})
set(OJ_SDL "SDL1.2 (legacy)")
else()
find_package(SDL2 REQUIRED)
set(OJ_LIBS_SDL ${SDL2_LIBRARIES})
set(OJ_SDL "SDL2")
endif()

# bundled libraries

Expand Down Expand Up @@ -177,7 +182,7 @@ if(NETWORK)
endif()

target_link_libraries(OpenJazz
argparse miniz psmplug ${OJ_SCALE_LIBS} ${SDL_LIBRARY} ${OJ_LIBS_NET} ${OJ_LIBS_HOST})
argparse miniz psmplug ${OJ_LIBS_SCALE} ${OJ_LIBS_SDL} ${OJ_LIBS_NET} ${OJ_LIBS_HOST})

# platform stuff

Expand Down Expand Up @@ -333,6 +338,7 @@ message(STATUS "")
message(STATUS "OpenJazz")
message(STATUS "========")
message(STATUS "Target system: ${OJ_HOST}")
message(STATUS "Platform abstraction: ${OJ_SDL}")
if(ROMFS)
message(STATUS "RomFS: Embedding directory \"${ROMFS_PATH}\"")
endif()
Expand Down
10 changes: 8 additions & 2 deletions builds/cmake/Platform-Helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ option(GP2X "Build for GP2X" OFF) # arm-open2x-linux
option(DINGOO "Build for Dingoo" OFF) # mipsel-linux*
option(GAMESHELL "Build for GameShell" OFF) # armv7l-unknown-linux-gnueabihf
option(RISCOS "Build for RISC OS" OFF) # arm-unknown-riscos
# "Official" Toolchain files define these

# Official/Homebrew Toolchain files define these
if(NINTENDO_3DS)
set(3DS ON)
set(OJ_HOST "3DS")
list(APPEND PLATFORM_LIST ${OJ_HOST})
set(OJ_SCALE OFF)
option(ROMFS "Embedd a directory in the executable" OFF)
option(ROMFS "Embed a directory in the executable" OFF)
set(ROMFS_PATH "romfs" CACHE PATH "Directory to include in executable as romfs:/ path")
set(ROMFS_ARG "NO_ROMFS_IGNORE_ME")
if(ROMFS)
Expand Down Expand Up @@ -91,6 +92,11 @@ elseif(RISCOS)
endfunction()
endif()

include(CMakeDependentOption)
# choose SDL library for Linux/Windows/Mac/etc., but not homebrew platforms
cmake_dependent_option(SDL_LEGACY "Build for SDL 1.2" FALSE
"${OJ_HOST} STREQUAL \"Unknown\"" TRUE)

# sanity check

list(LENGTH PLATFORM_LIST NUM_PLATFORMS)
Expand Down

0 comments on commit 1e9730f

Please sign in to comment.