Simple hello world
This commit is contained in:
parent
4443acb493
commit
b281bc04ce
2 changed files with 51 additions and 5 deletions
|
|
@ -1,9 +1,27 @@
|
||||||
cmake_minimum_required(VERSION 3.31)
|
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
|
||||||
project(ProjectName)
|
project(webgpu
|
||||||
include(FeatureSummary)
|
VERSION 0
|
||||||
|
DESCRIPTION "Simple Engine Experiment in C"
|
||||||
|
HOMEPAGE_URL "https://git.warwick-new.co.uk/"
|
||||||
|
LANGUAGES C
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CMAKE_C_STANDARD 17)
|
||||||
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
# 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()
|
||||||
|
|
||||||
# Use environment set by nix-shell to find wgpu include and library
|
# Use environment set by nix-shell to find wgpu include and library
|
||||||
find_path(WGPU_INCLUDE wgpu)
|
find_path(WGPU_INCLUDE webgpu)
|
||||||
find_library(WGPU_LIBRARY libwgpu_native.so)
|
find_library(WGPU_LIBRARY libwgpu_native.so)
|
||||||
message(STATUS "wgpu lib: ${WGPU_LIBRARY}")
|
message(STATUS "wgpu lib: ${WGPU_LIBRARY}")
|
||||||
message(STATUS "wgpu include dir: ${WGPU_INCLUDE}")
|
message(STATUS "wgpu include dir: ${WGPU_INCLUDE}")
|
||||||
|
|
@ -11,5 +29,26 @@ message(STATUS "wgpu include dir: ${WGPU_INCLUDE}")
|
||||||
find_package(SDL3 REQUIRED)
|
find_package(SDL3 REQUIRED)
|
||||||
find_package(SDL3_image REQUIRED)
|
find_package(SDL3_image REQUIRED)
|
||||||
find_package(cglm REQUIRED)
|
find_package(cglm REQUIRED)
|
||||||
|
include(FeatureSummary)
|
||||||
feature_summary(WHAT PACKAGES_FOUND)
|
feature_summary(WHAT PACKAGES_FOUND)
|
||||||
|
|
||||||
|
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})
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME} PRIVATE
|
||||||
|
${WGPU_INCLUDE}
|
||||||
|
${SDL3_INCLUDE_DIRS}
|
||||||
|
${SDL3_image_INCLUDE_DIRS}
|
||||||
|
${GLFW_INCLUDE_DIRS}
|
||||||
|
${CGLM_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
${WGPU_LIBRARY}
|
||||||
|
${SDL3_LIBRARIES}
|
||||||
|
${SDL3_image_LIBRARIES}
|
||||||
|
${CGLM_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
|
||||||
7
src/main.c
Normal file
7
src/main.c
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <webgpu/webgpu.h>
|
||||||
|
|
||||||
|
int main () {
|
||||||
|
printf("Hello World!\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue