54 lines
1.4 KiB
CMake
54 lines
1.4 KiB
CMake
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)
|
|
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
|
|
find_path(WGPU_INCLUDE webgpu)
|
|
find_library(WGPU_LIBRARY libwgpu_native.so)
|
|
message(STATUS "wgpu lib: ${WGPU_LIBRARY}")
|
|
message(STATUS "wgpu include dir: ${WGPU_INCLUDE}")
|
|
|
|
find_package(SDL3 REQUIRED)
|
|
find_package(SDL3_image REQUIRED)
|
|
find_package(cglm REQUIRED)
|
|
include(FeatureSummary)
|
|
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}
|
|
)
|