63 lines
1.7 KiB
CMake
63 lines
1.7 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)
|
|
|
|
# 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}
|
|
)
|