huge redesign

This commit is contained in:
herbglitch 2024-01-12 19:48:06 -07:00
parent 46e26e41e5
commit 85d0bad350
4 changed files with 66 additions and 81 deletions

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.25)
set(ARCHEUS_STD_VERSION 0.0.0)
project(archeus_std LANGUAGES C VERSION ${ARCHEUS_STD_VERSION} DESCRIPTION "libarcheus_std standard archeus c library")
@ -9,52 +9,32 @@ function(print var)
message("${var} = ${${var}}")
endfunction()
option(ARCHEUS_STD_DEBUG "Build in debug mode" ON)
#TODO: Might want to remove this
if(NOT CMAKE_BUILD_TYPE)
message("[Archeus C STD] Build Type not set, defaulting to Debug")
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Default to Debug" FORCE)
endif()
# ~ OPTIONS ~ #
option(ARCHEUS_STD_DEFAULT_CONFIG "Build with default config keys" ON)
option(ARCHEUS_STD_SDL "Build with SDL" OFF)
option(ARCHEUS_STD_GLFW "Build with GLFW window" OFF)
option(ARCHEUS_STD_GLEW "Build with GLEW" OFF)
option(ARCHEUS_STD_OPENGL "Build with OpenGL" OFF)
set(ARCHEUS_STD_WINDOW_BACKEND "NONE" CACHE STRING "Window Backend to build with")
set_property(CACHE ARCHEUS_STD_WINDOW_BACKEND PROPERTY STRINGS NONE SDL2 GLFW)
set(ARCHEUS_STD_INPUT_BACKEND "NONE" CACHE STRING "Input Backend to build with, most likely should match Window API")
set_property(CACHE ARCHEUS_STD_INPUT_BACKEND PROPERTY STRINGS NONE SDL2 GLFW)
set(ARCHEUS_STD_GRAPHICS_BACKEND "NONE" CACHE STRING "Graphics Backend to build with")
set_property(CACHE ARCHEUS_STD_GRAPHICS_BACKEND PROPERTY STRINGS NONE SDL2 OPENGL)
# ~ INIT VARIABLES ~ #
set(ARCHEUS_STD_FLAGS "")
set(ARCHEUS_STD_LIBRARIES "")
if(ARCHEUS_STD_DEBUG)
string(APPEND ARCHEUS_STD_FLAGS "-Wall -Werror -g -ggdb -DARC_DEBUG ")
endif()
if(ARCHEUS_STD_DEFAULT_CONFIG)
string(APPEND ARCHEUS_STD_FLAGS "-DARC_DEFAULT_CONFIG ")
endif()
if(ARCHEUS_STD_SDL)
if(NOT PNG AND WIN32 AND NOT MSVC)
set(PNG_LIBRARY "C:/Program Files(x86)/libpng")
set(PNG_PNG_INCLUDE_DIR "C:/Program Files(x86)/libpng/include")
endif()
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)
string(APPEND ARCHEUS_STD_FLAGS "-DARC_SDL ")
endif()
if(ARCHEUS_STD_GLFW)
string(APPEND ARCHEUS_STD_FLAGS "-DARC_GLFW ")
endif()
if(ARCHEUS_STD_GLEW)
string(APPEND ARCHEUS_STD_FLAGS "-DARC_GLEW ")
endif()
if(ARCHEUS_STD_OPENGL)
string(APPEND ARCHEUS_STD_FLAGS "-DARC_OPENGL")
endif()
set(CMAKE_C_FLAGS ${ARCHEUS_STD_FLAGS})
# ~ ARCHEUS_SOURCES ~ #
set(ARCHEUS_STD_SOURCES
src/std/config.c
src/std/errno.c
src/std/handler.c
src/std/hashtable.c
src/std/io.c
@ -74,21 +54,37 @@ set(ARCHEUS_STD_SOURCES
src/engine/state.c
)
set(ARCHEUS_STD_SDL_SOURCES
src/input/sdl/keyboard.c
src/input/sdl/mouse.c
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
string(APPEND ARCHEUS_STD_FLAGS "-Wall -Werror -g -ggdb -DARC_DEBUG ")
endif()
src/graphics/sdl/circle.c
src/graphics/sdl/config.c
src/graphics/sdl/line.c
src/graphics/sdl/obround.c
src/graphics/sdl/rectangle.c
src/graphics/sdl/renderer.c
src/graphics/sdl/sprite.c
src/graphics/sdl/spritesheet.c
src/graphics/sdl/text.c
src/graphics/sdl/window.c
)
# TODO: replace this with a better system
if(ARCHEUS_STD_DEFAULT_CONFIG)
string(APPEND ARCHEUS_STD_FLAGS "-DARC_DEFAULT_CONFIG ")
endif()
# ~ NONE ~ #
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/archeus_none.cmake)
none_check_and_init_needed(ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ${ARCHEUS_STD_WINDOW_BACKEND} ${ARCHEUS_STD_INPUT_BACKEND} ${ARCHEUS_STD_GRAPHICS_BACKEND})
# ~ SDL2 ~ #
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/archeus_sdl2.cmake)
sdl2_check_and_init_needed(ARCHEUS_STD_FLAGS ARCHEUS_STD_SOURCES ${ARCHEUS_STD_WINDOW_BACKEND} ${ARCHEUS_STD_INPUT_BACKEND} ${ARCHEUS_STD_GRAPHICS_BACKEND})
# ~ OPENGL ~ #
if(ARCHEUS_STD_GRAPHICS_BACKEND STREQUAL OPENGL)
string(APPEND ARCHEUS_STD_FLAGS "-DARC_OPENGL ")
endif()
if(ARCHEUS_STD_GLFW)
string(APPEND ARCHEUS_STD_FLAGS "-DARC_GLFW ")
endif()
if(ARCHEUS_STD_GLEW)
string(APPEND ARCHEUS_STD_FLAGS "-DARC_GLEW ")
endif()
set(CMAKE_C_FLAGS ${ARCHEUS_STD_FLAGS})
set(ARCHEUS_STD_OPENGL_SOURCES
src/graphics/opengl/config.c
@ -105,10 +101,6 @@ set(ARCHEUS_STD_GLFW_SOURCES
src/input/glfw/mouse.c
)
if(ARCHEUS_STD_SDL)
list(APPEND ARCHEUS_STD_SOURCES ${ARCHEUS_STD_SDL_SOURCES})
endif()
if(ARCHEUS_STD_OPENGL)
list(APPEND ARCHEUS_STD_SOURCES ${ARCHEUS_STD_OPENGL_SOURCES})
endif()
@ -123,21 +115,13 @@ else()
add_library(archeus_std SHARED ${ARCHEUS_STD_SOURCES})
endif()
if(ARCHEUS_STD_SDL)
target_include_directories(archeus_std
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE ${SDL2_INCLUDE_DIRS}
PRIVATE ${SDL2IMAGE_INCLUDE_DIRS}
)
target_include_directories(archeus_std
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_link_libraries(archeus_std PUBLIC ${SDL2_LIBRARIES} SDL2_image::SDL2_image SDL2_ttf::SDL2_ttf)
endif()
if(ARCHEUS_STD_OPENGL)
target_include_directories(archeus_std PRIVATE
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
endif()
target_link_libraries(archeus_std
PUBLIC m
)
install(TARGETS archeus_std EXPORT archeus_std_Exports
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}