Skip to content

Commit

Permalink
Merged pull request "Add option to compile against shared SDL2": #393
Browse files Browse the repository at this point in the history
  • Loading branch information
apanteleev committed Apr 1, 2024
2 parents 1ae8c8e + bc64bc7 commit e72b80c
Show file tree
Hide file tree
Showing 17 changed files with 47 additions and 31 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ OPTION(CONFIG_BUILD_SHADER_DEBUG_INFO "Build shaders with debug info" OFF)
OPTION(USE_SYSTEM_ZLIB "Prefer system ZLIB instead of the bundled one" OFF)
OPTION(USE_SYSTEM_OPENAL "Prefer system OpenAL Soft instead of the bundled one" OFF)
OPTION(USE_SYSTEM_CURL "Prefer system cURL instead of the bundled one" OFF)
OPTION(USE_SYSTEM_SDL2 "Prefer system SDL2 instead of the bundled one" OFF)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

# use dynamic zlib for steam runtime
Expand Down
1 change: 1 addition & 0 deletions VC/inc/SDL2/SDL.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <SDL.h>
1 change: 1 addition & 0 deletions VC/inc/SDL2/SDL_gamecontroller.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <SDL_gamecontroller.h>
1 change: 1 addition & 0 deletions VC/inc/SDL2/SDL_joystick.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <SDL_joystick.h>
1 change: 1 addition & 0 deletions VC/inc/SDL2/SDL_messagebox.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <SDL_messagebox.h>
1 change: 1 addition & 0 deletions VC/inc/SDL2/SDL_opengl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <SDL_opengl.h>
1 change: 1 addition & 0 deletions VC/inc/SDL2/SDL_video.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <SDL_video.h>
1 change: 1 addition & 0 deletions VC/inc/SDL2/SDL_vulkan.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <SDL_vulkan.h>
34 changes: 19 additions & 15 deletions extern/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,25 @@ endif()

# On a 32-bit target, only the server is built, and it doesn't need SDL
if (IS_64_BIT)
option(SDL_SHARED "" OFF)
option(SDL_STATIC "" ON)
option(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
option(SDL_TEST OFF)

if (CONFIG_LINUX_STEAM_RUNTIME_SUPPORT)
option(INPUT_TSLIB OFF)
endif()

add_subdirectory(SDL2)

set_target_properties(SDL2main PROPERTIES FOLDER extern)
set_target_properties(SDL2-static PROPERTIES FOLDER extern)
set_target_properties(uninstall PROPERTIES FOLDER extern)
set_target_properties(sdl_headers_copy PROPERTIES FOLDER extern)
if (USE_SYSTEM_SDL2)
find_package(SDL2 REQUIRED)
else()
option(SDL_SHARED "" OFF)
option(SDL_STATIC "" ON)
option(SDL_SHARED_ENABLED_BY_DEFAULT OFF)
option(SDL_TEST OFF)

if (CONFIG_LINUX_STEAM_RUNTIME_SUPPORT)
option(INPUT_TSLIB OFF)
endif()

add_subdirectory(SDL2)

set_target_properties(SDL2main PROPERTIES FOLDER extern)
set_target_properties(SDL2-static PROPERTIES FOLDER extern)
set_target_properties(uninstall PROPERTIES FOLDER extern)
set_target_properties(sdl_headers_copy PROPERTIES FOLDER extern)
endif()
endif()

#
Expand Down
12 changes: 8 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,16 @@ ENDIF()

TARGET_INCLUDE_DIRECTORIES(server PRIVATE ../inc)

if(NOT USE_SYSTEM_ZLIB)
TARGET_INCLUDE_DIRECTORIES(server PRIVATE "${ZLIB_INCLUDE_DIRS}")
if(TARGET client)
if (USE_SYSTEM_SDL2)
TARGET_LINK_LIBRARIES(client SDL2)
else()
TARGET_LINK_LIBRARIES(client SDL2main SDL2-static)
endif()
endif()

if(TARGET client)
TARGET_LINK_LIBRARIES(client SDL2main SDL2-static)
if(NOT USE_SYSTEM_ZLIB)
TARGET_INCLUDE_DIRECTORIES(server PRIVATE "${ZLIB_INCLUDE_DIRS}")
endif()

if(USE_SYSTEM_ZLIB)
Expand Down
2 changes: 1 addition & 1 deletion src/refresh/gl/qgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define QGL_H

#if USE_SDL
#include <SDL_opengl.h>
#include <SDL2/SDL_opengl.h>
#else
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN 1
Expand Down
4 changes: 2 additions & 2 deletions src/refresh/vkpt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "shader/vertex_buffer.h"

#include <vulkan/vulkan.h>
#include <SDL.h>
#include <SDL_vulkan.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_vulkan.h>

#include <stdio.h>
#include <stdlib.h>
Expand Down
4 changes: 2 additions & 2 deletions src/refresh/vkpt/physical_sky.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "../../client/client.h"
#include <time.h>

#include <SDL_joystick.h>
#include <SDL_gamecontroller.h>
#include <SDL2/SDL_joystick.h>
#include <SDL2/SDL_gamecontroller.h>

static VkImage img_envmap = 0;
static VkImageView imv_envmap = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/refresh/vkpt/vkpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define __VKPT_H__

#include <vulkan/vulkan.h>
#include <SDL.h>
#include <SDL_vulkan.h>
#include <SDL2/SDL.h>
#include <SDL2/SDL_vulkan.h>

#if !defined(HAVE_M_PI)
#define HAVE_M_PI
Expand Down
2 changes: 1 addition & 1 deletion src/unix/sound/sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "shared/shared.h"
#include "common/zone.h"
#include "client/sound/dma.h"
#include "SDL.h"
#include "SDL2/SDL.h"

static void Filler(void *userdata, Uint8 *stream, int len)
{
Expand Down
6 changes: 3 additions & 3 deletions src/unix/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <errno.h>

#if USE_CLIENT
#include <SDL_video.h>
#include <SDL_messagebox.h>
#include <SDL.h>
#include <SDL2/SDL_video.h>
#include <SDL2/SDL_messagebox.h>
#include <SDL2/SDL.h>

extern SDL_Window *get_sdl_window(void);

Expand Down
2 changes: 1 addition & 1 deletion src/unix/video/sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "refresh/refresh.h"
#include "system/system.h"
#include "../res/q2pro.xbm"
#include <SDL.h>
#include <SDL2/SDL.h>

#ifdef _WINDOWS
#include <ShellScalingAPI.h>
Expand Down

0 comments on commit e72b80c

Please sign in to comment.