mirror of
https://github.com/NoelFB/blah.git
synced 2025-07-15 18:51:53 +08:00
Merge branch 'master' into master
This commit is contained in:
@ -9,28 +9,26 @@ add_library(blah
|
||||
|
||||
src/core/app.cpp
|
||||
src/core/filesystem.cpp
|
||||
src/core/log.cpp
|
||||
src/core/common.cpp
|
||||
src/core/time.cpp
|
||||
|
||||
|
||||
src/graphics/batch.cpp
|
||||
src/graphics/blend.cpp
|
||||
src/graphics/framebuffer.cpp
|
||||
src/graphics/material.cpp
|
||||
src/graphics/mesh.cpp
|
||||
src/graphics/renderpass.cpp
|
||||
src/graphics/shader.cpp
|
||||
src/graphics/spritefont.cpp
|
||||
src/graphics/subtexture.cpp
|
||||
src/graphics/texture.cpp
|
||||
|
||||
src/input/input.cpp
|
||||
src/input/virtual_stick.cpp
|
||||
src/input/virtual_button.cpp
|
||||
src/input/virtual_axis.cpp
|
||||
|
||||
src/input/binding.cpp
|
||||
src/input/binding_registry.cpp
|
||||
|
||||
src/containers/str.cpp
|
||||
|
||||
src/drawing/batch.cpp
|
||||
src/drawing/spritefont.cpp
|
||||
src/drawing/subtexture.cpp
|
||||
|
||||
src/images/aseprite.cpp
|
||||
src/images/font.cpp
|
||||
src/images/image.cpp
|
||||
@ -54,11 +52,11 @@ add_library(blah
|
||||
src/streams/memorystream.cpp
|
||||
src/streams/stream.cpp
|
||||
|
||||
|
||||
src/internal/graphics_backend_gl.cpp
|
||||
src/internal/graphics_backend_d3d11.cpp
|
||||
src/internal/graphics_backend_dummy.cpp
|
||||
src/internal/platform_backend_sdl2.cpp
|
||||
src/internal/platform_backend_win32.cpp
|
||||
)
|
||||
|
||||
target_include_directories(blah
|
||||
@ -69,34 +67,49 @@ target_include_directories(blah
|
||||
)
|
||||
|
||||
# Platform Variables
|
||||
set(SDL2_ENABLED true CACHE BOOL "Use SDL2 as the System implementation")
|
||||
set(OPENGL_ENABLED true CACHE BOOL "Use OpenGL graphics implementation")
|
||||
set(D3D11_ENABLED false CACHE BOOL "Use D3D11 graphics implementation")
|
||||
set(PLATFORM_SDL2 true CACHE BOOL "Use SDL2 Platform Backend")
|
||||
set(PLATFORM_WIN32 false CACHE BOOL "Use Win32 Platform Backend")
|
||||
set(GRAPHICS_OPENGL true CACHE BOOL "Use OpenGL Graphics Backend")
|
||||
set(GRAPHICS_D3D11 false CACHE BOOL "Use D3D11 Graphics Backend")
|
||||
|
||||
set(LIBS "")
|
||||
|
||||
# add OpenGL definition if we're using it
|
||||
if (OPENGL_ENABLED)
|
||||
add_compile_definitions(BLAH_USE_OPENGL)
|
||||
endif()
|
||||
# use the OpenGL Graphics Backend
|
||||
if (GRAPHICS_OPENGL)
|
||||
|
||||
# add D3D11 definition if we're using it
|
||||
if (D3D11_ENABLED)
|
||||
add_compile_definitions(BLAH_USE_D3D11)
|
||||
add_compile_definitions(BLAH_GRAPHICS_OPENGL)
|
||||
|
||||
# use the D3D11 Graphics Backend
|
||||
elseif (GRAPHICS_D3D11)
|
||||
|
||||
add_compile_definitions(BLAH_GRAPHICS_D3D11)
|
||||
set(LIBS ${LIBS} d3d11.lib dxguid.lib D3Dcompiler.lib)
|
||||
|
||||
endif()
|
||||
|
||||
# Link and create SDL2 Definition if we're using it
|
||||
if (SDL2_ENABLED)
|
||||
add_compile_definitions(BLAH_USE_SDL2)
|
||||
if (EMSCRIPTEN)
|
||||
set_target_properties(blah PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
|
||||
else()
|
||||
# Attempt to find SDL2
|
||||
find_package(SDL2 QUIET)
|
||||
# use the SDL2 Platform Backend
|
||||
# Link and create SDL2 Definition
|
||||
if (PLATFORM_SDL2)
|
||||
add_compile_definitions(BLAH_PLATFORM_SDL2)
|
||||
|
||||
# Emscripten can import SDL2 directly
|
||||
if (EMSCRIPTEN)
|
||||
|
||||
set_target_properties(blah PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
|
||||
|
||||
# Load SDL2 Normally
|
||||
else()
|
||||
|
||||
# Try to find SDL2
|
||||
if (DEFINED SDL2_LIBRARIES AND DEFINED SDL2_INCLUDE_DIRS)
|
||||
set(SDL2_FOUND true)
|
||||
else()
|
||||
find_package(SDL2 QUIET)
|
||||
endif()
|
||||
|
||||
# If CMake cannot find SDL2 library, then it gets downloaded and compiled that way
|
||||
if (NOT ${SDL2_FOUND})
|
||||
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
SDL2
|
||||
@ -108,11 +121,20 @@ if (SDL2_ENABLED)
|
||||
FetchContent_Populate(SDL2)
|
||||
add_subdirectory(${sdl2_SOURCE_DIR} ${sdl2_BINARY_DIR})
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# Either way we are linking to SDL2
|
||||
set(LIBS ${LIBS} SDL2)
|
||||
endif()
|
||||
# Add Library and Include Dirs
|
||||
set(LIBS ${LIBS} ${SDL2_LIBRARIES})
|
||||
target_include_directories(blah PUBLIC ${SDL2_INCLUDE_DIRS})
|
||||
|
||||
endif()
|
||||
|
||||
# use the Win32 Platform Backend
|
||||
elseif (PLATFORM_WIN32)
|
||||
|
||||
add_compile_definitions(BLAH_PLATFORM_WIN32)
|
||||
|
||||
endif()
|
||||
|
||||
target_link_libraries(blah PUBLIC ${LIBS})
|
||||
|
Reference in New Issue
Block a user