eo/CMakeLists.txt

53 lines
1.9 KiB
CMake

cmake_minimum_required(VERSION 3.30.0)
project(eo
VERSION 0.1
DESCRIPTION "Report to Houston"
HOMEPAGE_URL "http://git.0xdeadbeer.xyz/0xdeadbeer/eo"
LANGUAGES CXX)
add_subdirectory("thirdparty/bgfx.cmake")
add_subdirectory("thirdparty/glfw.cmake")
add_subdirectory("thirdparty/imgui.cmake")
add_subdirectory("thirdparty/assimp.cmake")
add_subdirectory("thirdparty/glm.cmake")
add_executable(eo src/eo.cpp)
target_link_libraries(eo bx)
target_link_libraries(eo bgfx)
target_link_libraries(eo bimg)
target_link_libraries(eo glfw)
target_link_libraries(eo imgui)
target_link_libraries(eo assimp)
target_link_libraries(eo glm)
# build shaders into /build/shaders/
file(GLOB SHADER_SOURCE_FILES "${PROJECT_SOURCE_DIR}/shaders/*.sc")
set(SHADER_PLATFORM "linux")
set(SHADER_PROFILE "440")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/shaders")
foreach(SHADER_SOURCE ${SHADER_SOURCE_FILES})
cmake_path(ABSOLUTE_PATH SHADER_SOURCE NORMALIZE)
cmake_path(GET SHADER_SOURCE FILENAME SHADER_NAME)
cmake_path(GET SHADER_SOURCE STEM SHADER_STEM)
set(VERTEX_SHADER_TYPE -1)
set(FRAGMENT_SHADER_TYPE -1)
set(SHADER_TYPE)
string(FIND "${SHADER_NAME}" "vs" VERTEX_SHADER_TYPE)
string(FIND "${SHADER_NAME}" "fs" FRAGMENT_SHADER_TYPE)
if(${VERTEX_SHADER_TYPE} GREATER -1)
set(SHADER_TYPE "vertex")
elseif(${FRAGMENT_SHADER_TYPE} GREATER -1)
set(SHADER_TYPE "fragment")
else()
continue()
endif()
set(SHADER_COMMAND_ARGUMENTS "-f ${SHADER_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/shaders/${SHADER_LANGUAGE}/${SHADER_STEM}.bin --type ${SHADER_TYPE} --platform ${SHADER_PLATFORM} --profile ${SHADER_PROFILE}")
set(SHADER_COMMAND "${PROJECT_SOURCE_DIR}/tools/shaderc ${SHADER_COMMAND_ARGUMENTS}")
add_custom_target(${SHADER_NAME} ALL
COMMAND /bin/bash -c "${SHADER_COMMAND}"
)
endforeach()