[client] ds: make SDL display server optional

This commit also moved the SDL dependencies into the SDL backend so that
-DENABLE_SDL=NO builds do not link against SDL.
This commit is contained in:
Quantum 2021-02-25 18:07:56 -05:00 committed by Geoffrey McRae
parent f3b46e6d4f
commit c34fe10f23
3 changed files with 14 additions and 13 deletions

View File

@ -32,12 +32,19 @@ add_feature_info(ENABLE_ASAN ENABLE_ASAN "AddressSanitizer support.")
option(ENABLE_UBSAN "Build with UndefinedBehaviorSanitizer" OFF) option(ENABLE_UBSAN "Build with UndefinedBehaviorSanitizer" OFF)
add_feature_info(ENABLE_UBSAN ENABLE_UBSAN "UndefinedBehaviorSanitizer support.") add_feature_info(ENABLE_UBSAN ENABLE_UBSAN "UndefinedBehaviorSanitizer support.")
option(ENABLE_SDL "Build with SDL support" OFF)
add_feature_info(ENABLE_SDL ENABLE_SDL "SDL support.")
option(ENABLE_X11 "Build with X11 support" ON) option(ENABLE_X11 "Build with X11 support" ON)
add_feature_info(ENABLE_X11 ENABLE_X11 "X11 support.") add_feature_info(ENABLE_X11 ENABLE_X11 "X11 support.")
option(ENABLE_WAYLAND "Build with Wayland support" ON) option(ENABLE_WAYLAND "Build with Wayland support" ON)
add_feature_info(ENABLE_WAYLAND ENABLE_WAYLAND "Wayland support.") add_feature_info(ENABLE_WAYLAND ENABLE_WAYLAND "Wayland support.")
if (NOT ENABLE_SDL AND NOT ENABLE_X11 AND NOT ENABLE_WAYLAND)
message(FATAL_ERROR "One of ENABLE_SDL, ENABLE_X11, or ENABLE_WAYLAND must be on")
endif()
add_compile_options( add_compile_options(
"-Wall" "-Wall"
"-Wextra" "-Wextra"
@ -73,11 +80,6 @@ if(ENABLE_UBSAN)
set(EXE_FLAGS "${EXE_FLAGS} -fsanitize=undefined") set(EXE_FLAGS "${EXE_FLAGS} -fsanitize=undefined")
endif() endif()
find_package(PkgConfig)
pkg_check_modules(PKGCONFIG REQUIRED
sdl2
)
find_package(GMP) find_package(GMP)
add_definitions(-D ATOMIC_LOCKING) add_definitions(-D ATOMIC_LOCKING)
@ -94,12 +96,10 @@ add_custom_command(
include_directories( include_directories(
${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/include ${CMAKE_BINARY_DIR}/include
${PKGCONFIG_INCLUDE_DIRS} ${PKGCONFIG_OPT_INCLUDE_DIRS}
${GMP_INCLUDE_DIR} ${GMP_INCLUDE_DIR}
) )
link_libraries( link_libraries(
${PKGCONFIG_LIBRARIES} ${PKGCONFIG_OPT_LIBRARIES}
${GMP_LIBRARIES} ${GMP_LIBRARIES}
${CMAKE_DL_LIBS} ${CMAKE_DL_LIBS}
rt rt
@ -130,7 +130,6 @@ add_subdirectory(renderers)
add_subdirectory(fonts) add_subdirectory(fonts)
add_executable(looking-glass-client ${SOURCES}) add_executable(looking-glass-client ${SOURCES})
target_compile_options(looking-glass-client PUBLIC ${PKGCONFIG_CFLAGS_OTHER} ${PKGCONFIG_OPT_CFLAGS_OTHER})
target_link_libraries(looking-glass-client target_link_libraries(looking-glass-client
${EXE_FLAGS} ${EXE_FLAGS}
lg_common lg_common

View File

@ -28,7 +28,9 @@ if (ENABLE_X11)
endif() endif()
# SDL must be last as it's the fallback implemntation # SDL must be last as it's the fallback implemntation
if (ENABLE_SDL)
add_displayserver(SDL) add_displayserver(SDL)
endif()
list(REMOVE_AT DISPLAYSERVERS 0) list(REMOVE_AT DISPLAYSERVERS 0)
list(REMOVE_AT DISPLAYSERVERS_LINK 0) list(REMOVE_AT DISPLAYSERVERS_LINK 0)

View File

@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(displayserver_SDL LANGUAGES C) project(displayserver_SDL LANGUAGES C)
#find_package(PkgConfig) find_package(PkgConfig)
#pkg_check_modules(DISPLAYSERVER_SDL_PKGCONFIG REQUIRED pkg_check_modules(DISPLAYSERVER_SDL_PKGCONFIG REQUIRED
# #sdl2 sdl2
#) )
add_library(displayserver_SDL STATIC add_library(displayserver_SDL STATIC
sdl.c sdl.c