diff --git a/CMakeLists.txt b/CMakeLists.txt index fbe4e7a39..68668c93b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,7 @@ ENDIF() OPTION(CONFIG_BUILD_GLSLANG "Build glslangValidator from source instead of using the SDK" ${DEFAULT_BUILD_GLSLANG}) OPTION(CONFIG_BUILD_IPO "Enable interprocedural optimizations" OFF) OPTION(CONFIG_BUILD_SHADER_DEBUG_INFO "Build shaders with debug info" OFF) +OPTION(USE_SYSTEM_SDL2 "Prefer system SDL2 instead of the bundled one" 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) diff --git a/VC/inc/SDL2/SDL.h b/VC/inc/SDL2/SDL.h new file mode 100644 index 000000000..5d64d2e6f --- /dev/null +++ b/VC/inc/SDL2/SDL.h @@ -0,0 +1 @@ +#include diff --git a/VC/inc/SDL2/SDL_gamecontroller.h b/VC/inc/SDL2/SDL_gamecontroller.h new file mode 100644 index 000000000..0bd77c659 --- /dev/null +++ b/VC/inc/SDL2/SDL_gamecontroller.h @@ -0,0 +1 @@ +#include diff --git a/VC/inc/SDL2/SDL_joystick.h b/VC/inc/SDL2/SDL_joystick.h new file mode 100644 index 000000000..4bd0beb41 --- /dev/null +++ b/VC/inc/SDL2/SDL_joystick.h @@ -0,0 +1 @@ +#include diff --git a/VC/inc/SDL2/SDL_messagebox.h b/VC/inc/SDL2/SDL_messagebox.h new file mode 100644 index 000000000..c5a0cf822 --- /dev/null +++ b/VC/inc/SDL2/SDL_messagebox.h @@ -0,0 +1 @@ +#include diff --git a/VC/inc/SDL2/SDL_opengl.h b/VC/inc/SDL2/SDL_opengl.h new file mode 100644 index 000000000..0bb6e405f --- /dev/null +++ b/VC/inc/SDL2/SDL_opengl.h @@ -0,0 +1 @@ +#include diff --git a/VC/inc/SDL2/SDL_video.h b/VC/inc/SDL2/SDL_video.h new file mode 100644 index 000000000..db437744b --- /dev/null +++ b/VC/inc/SDL2/SDL_video.h @@ -0,0 +1 @@ +#include diff --git a/VC/inc/SDL2/SDL_vulkan.h b/VC/inc/SDL2/SDL_vulkan.h new file mode 100644 index 000000000..6e9cb44a7 --- /dev/null +++ b/VC/inc/SDL2/SDL_vulkan.h @@ -0,0 +1 @@ +#include diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt index eb8e5b1b0..49fcf137f 100644 --- a/extern/CMakeLists.txt +++ b/extern/CMakeLists.txt @@ -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() # diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 14dc75163..a5d02dce8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/refresh/gl/qgl.h b/src/refresh/gl/qgl.h index 7af569f35..f9e1a53f4 100644 --- a/src/refresh/gl/qgl.h +++ b/src/refresh/gl/qgl.h @@ -20,7 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define QGL_H #if USE_SDL - #include + #include #else #ifdef _WIN32 #define WIN32_LEAN_AND_MEAN 1 diff --git a/src/refresh/vkpt/main.c b/src/refresh/vkpt/main.c index d8a6e13e2..3cccc86bb 100644 --- a/src/refresh/vkpt/main.c +++ b/src/refresh/vkpt/main.c @@ -42,8 +42,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "shader/vertex_buffer.h" #include -#include -#include +#include +#include #include #include diff --git a/src/refresh/vkpt/physical_sky.c b/src/refresh/vkpt/physical_sky.c index 95ec568c3..260bde2aa 100644 --- a/src/refresh/vkpt/physical_sky.c +++ b/src/refresh/vkpt/physical_sky.c @@ -22,8 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "../../client/client.h" #include -#include -#include +#include +#include static VkImage img_envmap = 0; static VkImageView imv_envmap = 0; diff --git a/src/refresh/vkpt/vkpt.h b/src/refresh/vkpt/vkpt.h index 744b5a895..5ececfffc 100644 --- a/src/refresh/vkpt/vkpt.h +++ b/src/refresh/vkpt/vkpt.h @@ -21,8 +21,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #define __VKPT_H__ #include -#include -#include +#include +#include #if !defined(HAVE_M_PI) #define HAVE_M_PI diff --git a/src/unix/sound/sdl.c b/src/unix/sound/sdl.c index 25cf24a07..480bbeaf0 100644 --- a/src/unix/sound/sdl.c +++ b/src/unix/sound/sdl.c @@ -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) { diff --git a/src/unix/system.c b/src/unix/system.c index e98b9a75c..2fd4f3d8a 100644 --- a/src/unix/system.c +++ b/src/unix/system.c @@ -40,9 +40,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #if USE_CLIENT -#include -#include -#include +#include +#include +#include extern SDL_Window *get_sdl_window(void); diff --git a/src/unix/video/sdl.c b/src/unix/video/sdl.c index 805d497bf..e03c5203c 100644 --- a/src/unix/video/sdl.c +++ b/src/unix/video/sdl.c @@ -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 +#include #ifdef _WINDOWS #include