Current status of SDL.
This commit is contained in:
+96
-13
@@ -12,28 +12,111 @@ project(hdk-sdl
|
||||
# hdk-sdl OPTIONS
|
||||
option(HDK_SDL_TESTS "Build hdk-sdl tests" ${HDK_TESTS})
|
||||
option(HDK_SDL_EXAMPLES "Build hdk-sdl examples" ${HDK_EXAMPLES})
|
||||
option(HDK_SDL_INSTALL_TARGETS "Enable hdk-sdl install/export stubs" ON)
|
||||
option(HDK_SDL_SYSTEM_SDL3 "Use system SDL3 instead of FetchContent for building" OFF)
|
||||
option(HDK_SDL_BUNDLE_SDL3 "Build and bundle SDL3 as a static lib with hdk-sdl install" OFF)
|
||||
|
||||
if(HDK_SDL_SYSTEM_SDL3 AND HDK_SDL_BUNDLE_SDL3)
|
||||
message(FATAL_ERROR "HDK_SDL_SYSTEM_SDL3 and HDK_SDL_BUNDLE_SDL3 are mutually exclusive")
|
||||
endif()
|
||||
|
||||
if(HDK_SDL_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
# FOR SDL Building
|
||||
set(SDL_TEST OFF CACHE BOOL "Disable SDL tests" FORCE)
|
||||
set(SDL_EXAMPLES OFF CACHE BOOL "Disable SDL examples" FORCE)
|
||||
set(SDL_INSTALL OFF CACHE BOOL "Disable SDL install" FORCE)
|
||||
# NOTE: Possibly disable SDL_PIPEWIRE and/or SDL_PIPEWIRE_SHARED?
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
||||
GIT_TAG release-3.4.8
|
||||
)
|
||||
FetchContent_MakeAvailable(SDL3)
|
||||
if(NOT HDK_SDL_SYSTEM_SDL3)
|
||||
set(SDL_TEST OFF CACHE BOOL "Disable SDL tests" FORCE)
|
||||
set(SDL_EXAMPLES OFF CACHE BOOL "Disable SDL examples" FORCE)
|
||||
set(SDL_INSTALL OFF CACHE BOOL "Disable SDL install" FORCE)
|
||||
# NOTE: Possibly disable SDL_PIPEWIRE and/or SDL_PIPEWIRE_SHARED?
|
||||
|
||||
if(HDK_SDL_BUNDLE_SDL3)
|
||||
set(SDL_STATIC ON CACHE BOOL "Build SDL3 as static library for bundling" FORCE)
|
||||
set(SDL_SHARED OFF CACHE BOOL "Disable SDL3 shared library for bundling" FORCE)
|
||||
endif()
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
SDL3
|
||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
|
||||
GIT_TAG release-3.4.8
|
||||
)
|
||||
FetchContent_MakeAvailable(SDL3)
|
||||
else()
|
||||
find_package(SDL3 REQUIRED)
|
||||
endif()
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
add_library(hdk-sdl INTERFACE)
|
||||
target_link_libraries(hdk-sdl INTERFACE SDL3::SDL3 hdk-grid)
|
||||
target_include_directories(hdk-sdl INTERFACE ${SDL3_SOURCE_DIR}/include ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||
target_link_libraries(hdk-sdl INTERFACE
|
||||
$<BUILD_INTERFACE:SDL3::SDL3>
|
||||
$<BUILD_INTERFACE:hdk-grid>
|
||||
$<INSTALL_INTERFACE:SDL3::SDL3>
|
||||
$<INSTALL_INTERFACE:hdk::hdk-grid>
|
||||
)
|
||||
target_include_directories(hdk-sdl INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
||||
)
|
||||
target_compile_features(hdk-sdl INTERFACE cxx_std_17)
|
||||
|
||||
if(HDK_SDL_INSTALL_TARGETS)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
# Choose config file based on bundle mode
|
||||
if(HDK_SDL_BUNDLE_SDL3)
|
||||
set(_hdk_sdl_config_file hdk-sdlConfig-bundled.cmake.in)
|
||||
else()
|
||||
set(_hdk_sdl_config_file hdk-sdlConfig.cmake.in)
|
||||
endif()
|
||||
|
||||
configure_package_config_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${_hdk_sdl_config_file}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/hdk-sdlConfig.cmake
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hdk-sdl
|
||||
PATH_VARS CMAKE_INSTALL_INCLUDEDIR CMAKE_INSTALL_LIBDIR
|
||||
)
|
||||
|
||||
write_basic_package_version_file(
|
||||
${CMAKE_CURRENT_BINARY_DIR}/hdk-sdlConfigVersion.cmake
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/hdk-sdlConfig.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/hdk-sdlConfigVersion.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hdk-sdl
|
||||
)
|
||||
|
||||
# Bundled SDL3 install rules
|
||||
if(HDK_SDL_BUNDLE_SDL3)
|
||||
install(FILES $<TARGET_FILE:SDL3-static>
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hdk-sdl/sdl3-static
|
||||
)
|
||||
|
||||
install(DIRECTORY ${sdl3_SOURCE_DIR}/include/
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/hdk-sdlBundledSDL3Targets.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/hdk-sdlBundledSDL3Targets.cmake
|
||||
@ONLY
|
||||
)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hdk-sdlBundledSDL3Targets.cmake
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/hdk-sdl
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HDK_SDL_TESTS)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user