2022-01-05 12:31:39 +08:00
|
|
|
cmake_minimum_required(VERSION 3.14)
|
2020-08-26 15:38:01 +08:00
|
|
|
project(blah)
|
|
|
|
|
|
|
|
# C++ version
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
add_library(blah
|
2021-05-10 08:23:02 +08:00
|
|
|
src/app.cpp
|
|
|
|
src/filesystem.cpp
|
|
|
|
src/common.cpp
|
|
|
|
src/time.cpp
|
|
|
|
src/input.cpp
|
2020-08-26 15:38:01 +08:00
|
|
|
|
2021-03-23 07:53:27 +08:00
|
|
|
src/graphics/batch.cpp
|
2021-01-01 05:43:23 +08:00
|
|
|
src/graphics/blend.cpp
|
|
|
|
src/graphics/material.cpp
|
|
|
|
src/graphics/mesh.cpp
|
|
|
|
src/graphics/renderpass.cpp
|
|
|
|
src/graphics/shader.cpp
|
2021-03-23 07:53:27 +08:00
|
|
|
src/graphics/spritefont.cpp
|
|
|
|
src/graphics/subtexture.cpp
|
2021-05-10 08:23:02 +08:00
|
|
|
src/graphics/target.cpp
|
2021-01-01 05:43:23 +08:00
|
|
|
src/graphics/texture.cpp
|
|
|
|
|
|
|
|
src/containers/str.cpp
|
2021-02-12 03:14:36 +08:00
|
|
|
|
2021-01-01 05:43:23 +08:00
|
|
|
src/images/aseprite.cpp
|
|
|
|
src/images/font.cpp
|
|
|
|
src/images/image.cpp
|
|
|
|
src/images/packer.cpp
|
|
|
|
|
2021-05-10 08:23:02 +08:00
|
|
|
src/numerics/calc.cpp
|
|
|
|
src/numerics/color.cpp
|
2021-02-12 03:14:36 +08:00
|
|
|
|
|
|
|
src/streams/bufferstream.cpp
|
2021-01-01 05:43:23 +08:00
|
|
|
src/streams/filestream.cpp
|
|
|
|
src/streams/memorystream.cpp
|
|
|
|
src/streams/stream.cpp
|
|
|
|
|
2022-02-10 10:49:47 +08:00
|
|
|
src/internal/renderer_opengl.cpp
|
|
|
|
src/internal/renderer_d3d11.cpp
|
2021-05-26 12:30:46 +08:00
|
|
|
src/internal/platform_sdl2.cpp
|
|
|
|
src/internal/platform_win32.cpp
|
2020-12-27 06:44:48 +08:00
|
|
|
)
|
2020-08-26 15:38:01 +08:00
|
|
|
|
2021-02-12 03:14:36 +08:00
|
|
|
target_include_directories(blah
|
2020-08-26 15:38:01 +08:00
|
|
|
PUBLIC
|
2021-01-01 05:43:23 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
2020-08-26 15:38:01 +08:00
|
|
|
PRIVATE
|
2021-01-01 05:43:23 +08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
2020-08-26 15:38:01 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# Platform Variables
|
2022-01-10 05:50:16 +08:00
|
|
|
set(BLAH_PLATFORM_SDL2 true CACHE BOOL "Use SDL2 Platform Backend")
|
|
|
|
set(BLAH_PLATFORM_WIN32 false CACHE BOOL "Use Win32 Platform Backend")
|
2022-02-10 10:49:47 +08:00
|
|
|
set(BLAH_RENDERER_OPENGL true CACHE BOOL "Make OpenGL Renderer available")
|
|
|
|
if (WIN32)
|
|
|
|
set(BLAH_RENDERER_D3D11 true CACHE BOOL "Make D3D11 Renderer available")
|
|
|
|
else()
|
|
|
|
set(BLAH_RENDERER_D3D11 false CACHE BOOL "Make D3D11 Renderer available")
|
|
|
|
endif()
|
2020-12-29 10:31:06 +08:00
|
|
|
|
|
|
|
set(LIBS "")
|
2020-08-26 15:38:01 +08:00
|
|
|
|
2022-02-10 10:49:47 +08:00
|
|
|
# use the OpenGL Renderer Backend
|
|
|
|
if (BLAH_RENDERER_OPENGL)
|
|
|
|
add_compile_definitions(BLAH_RENDERER_OPENGL)
|
|
|
|
endif()
|
2021-03-24 06:45:19 +08:00
|
|
|
|
2022-02-10 10:49:47 +08:00
|
|
|
# use the D3D11 Renderer Backend
|
|
|
|
if (BLAH_RENDERER_D3D11)
|
|
|
|
add_compile_definitions(BLAH_RENDERER_D3D11)
|
2020-12-29 10:31:06 +08:00
|
|
|
set(LIBS ${LIBS} d3d11.lib dxguid.lib D3Dcompiler.lib)
|
|
|
|
endif()
|
|
|
|
|
2021-03-23 16:56:53 +08:00
|
|
|
# use the SDL2 Platform Backend
|
|
|
|
# Link and create SDL2 Definition
|
2022-01-10 05:50:16 +08:00
|
|
|
if (BLAH_PLATFORM_SDL2)
|
2021-03-23 16:56:53 +08:00
|
|
|
add_compile_definitions(BLAH_PLATFORM_SDL2)
|
|
|
|
|
2021-03-24 06:45:19 +08:00
|
|
|
# Emscripten can import SDL2 directly
|
2021-01-08 23:42:58 +08:00
|
|
|
if (EMSCRIPTEN)
|
2021-03-24 06:45:19 +08:00
|
|
|
|
2021-03-24 06:47:34 +08:00
|
|
|
set_target_properties(blah PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
|
2021-01-15 11:37:55 +08:00
|
|
|
|
2022-01-10 11:18:51 +08:00
|
|
|
# Pull SDL2 from its Github repo
|
2021-03-24 06:47:34 +08:00
|
|
|
else()
|
2022-01-10 11:18:51 +08:00
|
|
|
include(FetchContent)
|
|
|
|
set(FETCHCONTENT_QUIET FALSE)
|
|
|
|
|
|
|
|
FetchContent_Declare(
|
|
|
|
SDL2
|
|
|
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
2022-02-10 10:49:47 +08:00
|
|
|
GIT_TAG release-2.0.20 # grab latest stable release
|
2022-01-10 11:18:51 +08:00
|
|
|
GIT_PROGRESS TRUE
|
|
|
|
)
|
|
|
|
FetchContent_MakeAvailable(SDL2)
|
|
|
|
|
|
|
|
# statically link SDL2 since we're building it ourselves
|
|
|
|
set(LIBS ${LIBS} SDL2main SDL2-static)
|
|
|
|
target_include_directories(blah PRIVATE ${sdl2_SOURCE_DIRS}/include)
|
2021-03-24 06:47:34 +08:00
|
|
|
endif()
|
2021-03-23 16:56:53 +08:00
|
|
|
|
|
|
|
# use the Win32 Platform Backend
|
2022-01-10 05:50:16 +08:00
|
|
|
elseif (BLAH_PLATFORM_WIN32)
|
2021-03-24 06:45:19 +08:00
|
|
|
|
2021-03-23 16:56:53 +08:00
|
|
|
add_compile_definitions(BLAH_PLATFORM_WIN32)
|
2021-03-24 06:45:19 +08:00
|
|
|
|
2020-12-29 10:31:06 +08:00
|
|
|
endif()
|
|
|
|
|
2022-01-10 05:50:16 +08:00
|
|
|
target_link_libraries(blah PRIVATE ${LIBS})
|