SOF/renderer/CMakeLists.txt
FroggyGreen 207de345f7 Window events, math, and asdf
Window resize events are now sent from the renderer to lisp.
On the lisp side, some math code has been written, but not yet
integrated into the project.
2024-05-13 19:05:28 -05:00

47 lines
1.8 KiB
CMake

cmake_minimum_required(VERSION 3.25)
project(SofRenderer C)
option(DEBUG_BUILD "Build the library in debug mode." OFF)
if (DEBUG_BUILD)
add_compile_definitions(RENDERER_DEBUG)
endif()
find_package(Vulkan REQUIRED)
# compile shaders
file(GLOB_RECURSE SHADER_FILES "${PROJECT_SOURCE_DIR}/shaders/*.frag" "${PROJECT_SOURCE_DIR}/shaders/*.vert")
foreach(SHADER_FILE ${SHADER_FILES})
cmake_path(GET SHADER_FILE FILENAME SHADER_FILE_NAME)
message(STATUS "Configuring \"${SHADER_FILE_NAME}\" to compile with "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}" ...")
set(SHADER_SPIRV "${PROJECT_SOURCE_DIR}/shaders/${SHADER_FILE_NAME}.spv")
add_custom_command(
OUTPUT "${SHADER_SPIRV}"
COMMAND "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}" -V "${PROJECT_SOURCE_DIR}/shaders/${SHADER_FILE_NAME}" -o "${SHADER_SPIRV}"
DEPENDS "${PROJECT_SOURCE_DIR}/shaders/${SHADER_FILE_NAME}")
list(APPEND SHADER_SPIRV_BINARIES ${SHADER_SPIRV})
endforeach()
add_custom_target(shaders ALL DEPENDS ${SHADER_SPIRV_BINARIES})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
add_library(sofrenderer SHARED
"src/logger.c"
"src/renderer.c"
"src/containers/darray.c"
"src/containers/dblist.c"
"src/containers/hashtable.c"
"src/containers/ringqueue.c")
target_include_directories(sofrenderer PRIVATE "${PROJECT_SOURCE_DIR}/src")
set_target_properties(sofrenderer PROPERTIES
C_STANDARD 99
LIBRARY_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/lib")
# GLFW
add_subdirectory(../external/glfw build)
target_include_directories(sofrenderer PRIVATE "${PROJECT_SOURCE_DIR}/../external/glfw/include")
target_link_directories(sofrenderer PRIVATE "${PROJECT_SOURCE_DIR}/../external/glfw")
target_link_libraries(sofrenderer PRIVATE glfw)
# Vulkan
target_include_directories(sofrenderer PRIVATE ${Vulkan_INCLUDE_DIRS})
target_link_libraries(sofrenderer PRIVATE ${Vulkan_LIBRARIES})