From 1e9730fd2098895dbc4d98702b70f4abc6fcbcc4 Mon Sep 17 00:00:00 2001 From: Carsten Teibes Date: Tue, 24 Oct 2023 17:26:39 +0200 Subject: [PATCH] Add SDL2 building to CMake as default Let homebrew platforms still use SDL1.2 --- CMakeLists.txt | 28 +++++++++++++++++----------- builds/cmake/Platform-Helpers.cmake | 10 ++++++++-- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10c150f5..af31a02d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 @@ -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 @@ -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 @@ -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 @@ -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() diff --git a/builds/cmake/Platform-Helpers.cmake b/builds/cmake/Platform-Helpers.cmake index 2f1b4379..b218ce6c 100644 --- a/builds/cmake/Platform-Helpers.cmake +++ b/builds/cmake/Platform-Helpers.cmake @@ -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) @@ -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)