I think I got all the dependancies into cmake (unlinked)

This commit is contained in:
Warwick 2025-06-18 10:32:52 +01:00
parent 473416a78e
commit faf6b5838a
7 changed files with 87 additions and 5 deletions

13
.gitignore vendored
View file

@ -1,8 +1,11 @@
compile_commands.json
webgpu
## Meson
subprojects/
!subprojects/*.wrap
!subprojects/wgpu-native
.cache/
# CMake
CMakeCache.txt
CMakeFiles/
CPackConfig.cmake
CPackSourceConfig.cmake
Makefile
_deps/
cmake_install.cmake

12
.gitmodules vendored
View file

@ -0,0 +1,12 @@
[submodule "extern/extern/SDL3"]
path = extern/SDL3
url = git@github.com:libsdl-org/SDL.git
[submodule "extern/SDL3_image"]
path = extern/SDL3_image
url = https://github.com/libsdl-org/SDL_image
[submodule "extern/cglm"]
path = extern/cglm
url = git@github.com:recp/cglm.git
[submodule "external/glew"]
path = external/glew
url = https://github.com/nigels-com/glew.git

63
CMakeLists.txt Normal file
View file

@ -0,0 +1,63 @@
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
project(webgpu
VERSION 0
DESCRIPTION "Simple Engine Experiment in C"
HOMEPAGE_URL "https://git.warwick-new.co.uk/"
LANGUAGES C
)
set(CMAKE_C_STANDARD 17)
# Since nix include dirs isn't appearing in compile_commands.json we're gonna
# force cmake to link it's includes more explicitly
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE INTERNAL "")
if(CMAKE_EXPORT_COMPILE_COMMANDS)
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES
${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES})
endif()
add_subdirectory(extern/SDL3)
add_subdirectory(extern/SDL3_image)
add_subdirectory(extern/cglm)
add_definitions(-DGLEW_STATIC)
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL)
include(FetchContent)
cmake_policy(SET CMP0135 NEW) #DOWNLOAD_EXTRACT_TIMESTAMP
FetchContent_Declare(
glew
URL https://github.com/nigels-com/glew/releases/download/glew-2.2.0/glew-2.2.0.tgz
SOURCE_SUBDIR build/cmake
)
file(GLOB_RECURSE SOURCE_FILES
${CMAKE_SOURCE_DIR}/src/*.c)
file(GLOB_RECURSE HEADER_FILES
${CMAKE_SOURCE_DIR}/src/*.h)
add_executable(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES})
# Error on memory address issues in debug mode
if(CMAKE_BUILD_TYPE MATCHES "Debug")
set(
CMAKE_C_FLAGS
"${CMAKE_C_FLAGS} -Werror -fsanitize=undefined -fsanitize=address"
)
target_link_options(${PROJECT_NAME}
BEFORE PUBLIC -fsanitize=undefined PUBLIC -fsanitize=address
)
endif()
target_include_directories(${PROJECT_NAME} PRIVATE
${SDL3_INCLUDE_DIRS}
${SDL3_image_INCLUDE_DIRS}
${GLFW_INCLUDE_DIRS}
${CGLM_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
${SDL3_LIBRARIES}
${SDL3_image_LIBRARIES}
${CGLM_LIBRARIES}
)

1
extern/SDL3 vendored Submodule

@ -0,0 +1 @@
Subproject commit c9a6709bd21750f1ad9597be21abace78c6378c9

1
extern/SDL3_image vendored Submodule

@ -0,0 +1 @@
Subproject commit 11154afb7855293159588b245b446a4ef09e574f

1
extern/cglm vendored Submodule

@ -0,0 +1 @@
Subproject commit 144d1e7c29b3b0c6dede7917a0476cc95248559c

1
external/glew vendored Submodule

@ -0,0 +1 @@
Subproject commit 3da315c23aa80b5727e51f21bbe33823bf4c0511