Fixed debug builds
This commit is contained in:
parent
990e4871ad
commit
dfccf4d01b
3 changed files with 25 additions and 13 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,3 +4,4 @@ CMakeFiles/
|
|||
Makefile
|
||||
cmake_install.cmake
|
||||
compile_commands.json
|
||||
webgpu
|
||||
|
|
|
|||
|
|
@ -9,24 +9,13 @@ project(webgpu
|
|||
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 explicitly
|
||||
# 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()
|
||||
|
||||
# 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
|
||||
find_path(WGPU_INCLUDE webgpu)
|
||||
find_library(WGPU_LIBRARY libwgpu_native.so)
|
||||
|
|
@ -45,6 +34,17 @@ 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
|
||||
${WGPU_INCLUDE}
|
||||
${SDL3_INCLUDE_DIRS}
|
||||
|
|
|
|||
13
src/main.c
13
src/main.c
|
|
@ -8,6 +8,17 @@ int main() {
|
|||
|
||||
// We create the instance using this descriptor
|
||||
WGPUInstance instance = wgpuCreateInstance(&desc);
|
||||
printf("Hello World!\n");
|
||||
//
|
||||
// We can check whether there is actually an instance created
|
||||
if (!instance) {
|
||||
printf("Could not initialize WebGPU!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Display the object (WGPUInstance is a simple pointer, it may be
|
||||
// copied around without worrying about its size).
|
||||
printf("WGPU instance: %p\n", instance);
|
||||
|
||||
wgpuInstanceRelease(instance);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue