2022-01-04 20:31:39 -08:00
|
|
|
cmake_minimum_required(VERSION 3.14)
|
2020-08-26 00:38:01 -07:00
|
|
|
project(blah)
|
|
|
|
|
|
|
|
# C++ version
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
add_library(blah
|
2021-05-09 17:23:02 -07:00
|
|
|
src/app.cpp
|
|
|
|
src/filesystem.cpp
|
|
|
|
src/common.cpp
|
|
|
|
src/time.cpp
|
|
|
|
src/input.cpp
|
2022-02-12 12:19:53 -08:00
|
|
|
src/stream.cpp
|
|
|
|
src/graphics.cpp
|
2020-12-31 13:43:23 -08:00
|
|
|
src/containers/str.cpp
|
2022-02-12 12:19:53 -08:00
|
|
|
src/drawing/batch.cpp
|
|
|
|
src/drawing/spritefont.cpp
|
|
|
|
src/drawing/subtexture.cpp
|
2020-12-31 13:43:23 -08:00
|
|
|
src/images/aseprite.cpp
|
|
|
|
src/images/font.cpp
|
|
|
|
src/images/image.cpp
|
|
|
|
src/images/packer.cpp
|
2022-02-09 18:49:47 -08:00
|
|
|
src/internal/renderer_opengl.cpp
|
|
|
|
src/internal/renderer_d3d11.cpp
|
2021-05-25 21:30:46 -07:00
|
|
|
src/internal/platform_sdl2.cpp
|
|
|
|
src/internal/platform_win32.cpp
|
2020-12-26 14:44:48 -08:00
|
|
|
)
|
2020-08-26 00:38:01 -07:00
|
|
|
|
2021-02-11 13:14:36 -06:00
|
|
|
target_include_directories(blah
|
2020-08-26 00:38:01 -07:00
|
|
|
PUBLIC
|
2020-12-31 13:43:23 -08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
2020-08-26 00:38:01 -07:00
|
|
|
PRIVATE
|
2020-12-31 13:43:23 -08:00
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
|
2020-08-26 00:38:01 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
# Platform Variables
|
2022-02-11 15:20:07 -08:00
|
|
|
option(BLAH_PLATFORM_SDL2 "Use SDL2 Platform Backend" ON)
|
|
|
|
option(BLAH_PLATFORM_WIN32 "Use Win32 Platform Backend" OFF)
|
|
|
|
option(BLAH_RENDERER_OPENGL "Make OpenGL Renderer available" ON)
|
2022-02-09 18:49:47 -08:00
|
|
|
if (WIN32)
|
2022-02-11 15:20:07 -08:00
|
|
|
option(BLAH_RENDERER_D3D11 "Make D3D11 Renderer available" ON)
|
2022-02-09 18:49:47 -08:00
|
|
|
endif()
|
2022-02-11 15:20:07 -08:00
|
|
|
option(BLAH_NO_FUNCTIONAL "Don't use std::function" OFF)
|
|
|
|
option(BLAH_NO_SHARED_PTR "Don't use std::shared_ptr for Resources" OFF)
|
2020-12-28 18:31:06 -08:00
|
|
|
|
2022-02-15 10:35:44 -08:00
|
|
|
# tracks which libraries we need to link, depends on Options above
|
2020-12-28 18:31:06 -08:00
|
|
|
set(LIBS "")
|
2020-08-26 00:38:01 -07:00
|
|
|
|
2022-02-09 18:49:47 -08:00
|
|
|
# use the OpenGL Renderer Backend
|
|
|
|
if (BLAH_RENDERER_OPENGL)
|
|
|
|
add_compile_definitions(BLAH_RENDERER_OPENGL)
|
|
|
|
endif()
|
2021-03-23 15:45:19 -07:00
|
|
|
|
2022-02-09 18:49:47 -08:00
|
|
|
# use the D3D11 Renderer Backend
|
|
|
|
if (BLAH_RENDERER_D3D11)
|
|
|
|
add_compile_definitions(BLAH_RENDERER_D3D11)
|
2020-12-28 18:31:06 -08:00
|
|
|
set(LIBS ${LIBS} d3d11.lib dxguid.lib D3Dcompiler.lib)
|
|
|
|
endif()
|
|
|
|
|
2021-03-23 01:56:53 -07:00
|
|
|
# use the SDL2 Platform Backend
|
|
|
|
# Link and create SDL2 Definition
|
2022-01-09 13:50:16 -08:00
|
|
|
if (BLAH_PLATFORM_SDL2)
|
2021-03-23 01:56:53 -07:00
|
|
|
add_compile_definitions(BLAH_PLATFORM_SDL2)
|
|
|
|
|
2021-03-23 15:45:19 -07:00
|
|
|
# Emscripten can import SDL2 directly
|
2021-01-08 09:42:58 -06:00
|
|
|
if (EMSCRIPTEN)
|
2021-03-23 15:45:19 -07:00
|
|
|
|
2021-03-23 15:47:34 -07:00
|
|
|
set_target_properties(blah PROPERTIES COMPILE_FLAGS "-s USE_SDL=2")
|
2021-01-14 21:37:55 -06:00
|
|
|
|
2022-01-09 19:18:51 -08:00
|
|
|
# Pull SDL2 from its Github repo
|
2021-03-23 15:47:34 -07:00
|
|
|
else()
|
2022-05-28 09:29:30 -07:00
|
|
|
if (NOT DEFINED BLAH_SDL2_LIBS)
|
|
|
|
include(FetchContent)
|
|
|
|
set(FETCHCONTENT_QUIET FALSE)
|
|
|
|
|
|
|
|
FetchContent_Declare(
|
|
|
|
SDL2
|
|
|
|
GIT_REPOSITORY https://github.com/libsdl-org/SDL
|
|
|
|
GIT_TAG release-2.0.20 # grab latest stable release
|
|
|
|
GIT_PROGRESS TRUE
|
|
|
|
)
|
|
|
|
FetchContent_MakeAvailable(SDL2)
|
|
|
|
set(BLAH_SDL2_LIBS SDL2main SDL2-static)
|
|
|
|
set(BLAH_SDL2_INCLUDE ${sdl2_SOURCE_DIRS}/include)
|
|
|
|
endif()
|
2022-01-09 19:18:51 -08:00
|
|
|
|
|
|
|
# statically link SDL2 since we're building it ourselves
|
2022-05-28 09:29:30 -07:00
|
|
|
set(LIBS ${LIBS} ${BLAH_SDL2_LIBS})
|
|
|
|
target_include_directories(blah PRIVATE ${BLAH_SDL2_INCLUDE})
|
2021-03-23 15:47:34 -07:00
|
|
|
endif()
|
2021-03-23 01:56:53 -07:00
|
|
|
|
|
|
|
# use the Win32 Platform Backend
|
2022-01-09 13:50:16 -08:00
|
|
|
elseif (BLAH_PLATFORM_WIN32)
|
2021-03-23 15:45:19 -07:00
|
|
|
|
2021-03-23 01:56:53 -07:00
|
|
|
add_compile_definitions(BLAH_PLATFORM_WIN32)
|
2021-03-23 15:45:19 -07:00
|
|
|
|
2020-12-28 18:31:06 -08:00
|
|
|
endif()
|
|
|
|
|
2022-01-09 13:50:16 -08:00
|
|
|
target_link_libraries(blah PRIVATE ${LIBS})
|
2022-02-15 10:35:44 -08:00
|
|
|
|
|
|
|
# toggle options
|
2022-03-17 00:57:54 -07:00
|
|
|
if (BLAH_NO_FUNCTIONAL)
|
|
|
|
add_compile_definitions(BLAH_NO_FUNCTIONAL)
|
|
|
|
endif()
|
|
|
|
if (BLAH_NO_SHARED_PTR)
|
|
|
|
add_compile_definitions(BLAH_NO_SHARED_PTR)
|
|
|
|
endif()
|