mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-25 16:18:57 +08:00
update to SDL 2.26
This commit is contained in:
parent
c58eb0142e
commit
5e7c2bec90
232
CMakeLists.txt
232
CMakeLists.txt
|
@ -1,116 +1,116 @@
|
||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
project(blah)
|
project(blah)
|
||||||
|
|
||||||
# C++ version
|
# C++ version
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
add_library(blah
|
add_library(blah
|
||||||
src/blah_app.cpp
|
src/blah_app.cpp
|
||||||
src/blah_filesystem.cpp
|
src/blah_filesystem.cpp
|
||||||
src/blah_common.cpp
|
src/blah_common.cpp
|
||||||
src/blah_time.cpp
|
src/blah_time.cpp
|
||||||
src/blah_input.cpp
|
src/blah_input.cpp
|
||||||
src/blah_stream.cpp
|
src/blah_stream.cpp
|
||||||
src/blah_graphics.cpp
|
src/blah_graphics.cpp
|
||||||
src/blah_string.cpp
|
src/blah_string.cpp
|
||||||
src/blah_batch.cpp
|
src/blah_batch.cpp
|
||||||
src/blah_spritefont.cpp
|
src/blah_spritefont.cpp
|
||||||
src/blah_subtexture.cpp
|
src/blah_subtexture.cpp
|
||||||
src/blah_aseprite.cpp
|
src/blah_aseprite.cpp
|
||||||
src/blah_audio.cpp
|
src/blah_audio.cpp
|
||||||
src/blah_font.cpp
|
src/blah_font.cpp
|
||||||
src/blah_image.cpp
|
src/blah_image.cpp
|
||||||
src/blah_packer.cpp
|
src/blah_packer.cpp
|
||||||
src/blah_audio.cpp
|
src/blah_audio.cpp
|
||||||
src/internal/blah_renderer_opengl.cpp
|
src/internal/blah_renderer_opengl.cpp
|
||||||
src/internal/blah_renderer_d3d11.cpp
|
src/internal/blah_renderer_d3d11.cpp
|
||||||
src/internal/blah_platform_sdl2.cpp
|
src/internal/blah_platform_sdl2.cpp
|
||||||
src/internal/blah_platform_win32.cpp
|
src/internal/blah_platform_win32.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
target_include_directories(blah
|
target_include_directories(blah
|
||||||
PUBLIC
|
PUBLIC
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
PRIVATE
|
PRIVATE
|
||||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
||||||
)
|
)
|
||||||
|
|
||||||
# Platform Variables
|
# Platform Variables
|
||||||
option(BLAH_PLATFORM_SDL2 "Use SDL2 Platform Backend" ON)
|
option(BLAH_PLATFORM_SDL2 "Use SDL2 Platform Backend" ON)
|
||||||
option(BLAH_PLATFORM_WIN32 "Use Win32 Platform Backend" OFF)
|
option(BLAH_PLATFORM_WIN32 "Use Win32 Platform Backend" OFF)
|
||||||
option(BLAH_RENDERER_OPENGL "Make OpenGL Renderer available" ON)
|
option(BLAH_RENDERER_OPENGL "Make OpenGL Renderer available" ON)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
option(BLAH_RENDERER_D3D11 "Make D3D11 Renderer available" ON)
|
option(BLAH_RENDERER_D3D11 "Make D3D11 Renderer available" ON)
|
||||||
endif()
|
endif()
|
||||||
option(BLAH_NO_FUNCTIONAL "Don't use std::function" OFF)
|
option(BLAH_NO_FUNCTIONAL "Don't use std::function" OFF)
|
||||||
option(BLAH_NO_SHARED_PTR "Don't use std::shared_ptr for Resources" OFF)
|
option(BLAH_NO_SHARED_PTR "Don't use std::shared_ptr for Resources" OFF)
|
||||||
option(BLAH_NO_THREADING "Don't use threading" OFF)
|
option(BLAH_NO_THREADING "Don't use threading" OFF)
|
||||||
|
|
||||||
# tracks which libraries we need to link, depends on Options above
|
# tracks which libraries we need to link, depends on Options above
|
||||||
set(LIBS "")
|
set(LIBS "")
|
||||||
|
|
||||||
# use the OpenGL Renderer Backend
|
# use the OpenGL Renderer Backend
|
||||||
if (BLAH_RENDERER_OPENGL)
|
if (BLAH_RENDERER_OPENGL)
|
||||||
add_compile_definitions(BLAH_RENDERER_OPENGL)
|
add_compile_definitions(BLAH_RENDERER_OPENGL)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# use the D3D11 Renderer Backend
|
# use the D3D11 Renderer Backend
|
||||||
if (BLAH_RENDERER_D3D11)
|
if (BLAH_RENDERER_D3D11)
|
||||||
add_compile_definitions(BLAH_RENDERER_D3D11)
|
add_compile_definitions(BLAH_RENDERER_D3D11)
|
||||||
set(LIBS ${LIBS} d3d11.lib dxguid.lib D3Dcompiler.lib)
|
set(LIBS ${LIBS} d3d11.lib dxguid.lib D3Dcompiler.lib)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# use the SDL2 Platform Backend
|
# use the SDL2 Platform Backend
|
||||||
# Link and create SDL2 Definition
|
# Link and create SDL2 Definition
|
||||||
if (BLAH_PLATFORM_SDL2)
|
if (BLAH_PLATFORM_SDL2)
|
||||||
add_compile_definitions(BLAH_PLATFORM_SDL2)
|
add_compile_definitions(BLAH_PLATFORM_SDL2)
|
||||||
|
|
||||||
# Emscripten can import SDL2 directly
|
# Emscripten can import SDL2 directly
|
||||||
if (EMSCRIPTEN)
|
if (EMSCRIPTEN)
|
||||||
|
|
||||||
set_target_properties(blah PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
|
set_target_properties(blah PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
|
||||||
target_link_libraries(blah "-s USE_SDL=2 -s USE_WEBGL2=1")
|
target_link_libraries(blah "-s USE_SDL=2 -s USE_WEBGL2=1")
|
||||||
|
|
||||||
# Pull SDL2 from its Github repo
|
# Pull SDL2 from its Github repo
|
||||||
else()
|
else()
|
||||||
if (NOT DEFINED BLAH_SDL2_LIBS)
|
if (NOT DEFINED BLAH_SDL2_LIBS)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
set(FETCHCONTENT_QUIET FALSE)
|
set(FETCHCONTENT_QUIET FALSE)
|
||||||
|
|
||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
SDL2
|
SDL2
|
||||||
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
||||||
GIT_TAG release-2.24.0 # grab latest stable release
|
GIT_TAG release-2.26.0 # grab latest stable release
|
||||||
GIT_PROGRESS TRUE
|
GIT_PROGRESS TRUE
|
||||||
)
|
)
|
||||||
FetchContent_MakeAvailable(SDL2)
|
FetchContent_MakeAvailable(SDL2)
|
||||||
set(BLAH_SDL2_LIBS SDL2main SDL2-static)
|
set(BLAH_SDL2_LIBS SDL2main SDL2-static)
|
||||||
set(BLAH_SDL2_INCLUDE ${sdl2_SOURCE_DIRS}/include)
|
set(BLAH_SDL2_INCLUDE ${sdl2_SOURCE_DIRS}/include)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# statically link SDL2 since we're building it ourselves
|
# statically link SDL2 since we're building it ourselves
|
||||||
set(LIBS ${LIBS} ${BLAH_SDL2_LIBS})
|
set(LIBS ${LIBS} ${BLAH_SDL2_LIBS})
|
||||||
target_include_directories(blah PRIVATE ${BLAH_SDL2_INCLUDE})
|
target_include_directories(blah PRIVATE ${BLAH_SDL2_INCLUDE})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# use the Win32 Platform Backend
|
# use the Win32 Platform Backend
|
||||||
elseif (BLAH_PLATFORM_WIN32)
|
elseif (BLAH_PLATFORM_WIN32)
|
||||||
|
|
||||||
add_compile_definitions(BLAH_PLATFORM_WIN32)
|
add_compile_definitions(BLAH_PLATFORM_WIN32)
|
||||||
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(blah PRIVATE ${LIBS})
|
target_link_libraries(blah PRIVATE ${LIBS})
|
||||||
|
|
||||||
# toggle options
|
# toggle options
|
||||||
if (BLAH_NO_FUNCTIONAL)
|
if (BLAH_NO_FUNCTIONAL)
|
||||||
add_compile_definitions(BLAH_NO_FUNCTIONAL)
|
add_compile_definitions(BLAH_NO_FUNCTIONAL)
|
||||||
endif()
|
endif()
|
||||||
if (BLAH_NO_SHARED_PTR)
|
if (BLAH_NO_SHARED_PTR)
|
||||||
add_compile_definitions(BLAH_NO_SHARED_PTR)
|
add_compile_definitions(BLAH_NO_SHARED_PTR)
|
||||||
endif()
|
endif()
|
||||||
if (BLAH_NO_THREADING)
|
if (BLAH_NO_THREADING)
|
||||||
add_compile_definitions(BLAH_NO_THREADING)
|
add_compile_definitions(BLAH_NO_THREADING)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user