mirror of https://github.com/AxioDL/metaforce.git
66 lines
2.7 KiB
CMake
66 lines
2.7 KiB
CMake
include_guard(GLOBAL)
|
|
|
|
file(RELATIVE_PATH REL_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_LIST_DIR})
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/${REL_PATH})
|
|
|
|
unset(HECL_APPLICATION_REPS_TARGETS_LIST CACHE)
|
|
unset(HECL_APPLICATION_REPS_INCLUDES_LIST CACHE)
|
|
unset(HECL_APPLICATION_PIPELINE_REPS_UNIVERSAL CACHE)
|
|
unset(HECL_APPLICATION_PIPELINE_REPS CACHE)
|
|
unset(HECL_APPLICATION_STAGE_REPS CACHE)
|
|
|
|
# add_pipeline_rep(my::fully::qualified::class my_class_header.hpp [UNIVERSAL])
|
|
function(add_pipeline_rep name header)
|
|
if(IS_ABSOLUTE ${header})
|
|
set(theHeader ${header})
|
|
else()
|
|
set(theHeader ${CMAKE_CURRENT_SOURCE_DIR}/${header})
|
|
endif()
|
|
if (NOT ${theHeader} IN_LIST HECL_APPLICATION_REPS_INCLUDES_LIST)
|
|
set(HECL_APPLICATION_REPS_INCLUDES_LIST "${HECL_APPLICATION_REPS_INCLUDES_LIST};${theHeader}" CACHE INTERNAL "")
|
|
endif()
|
|
if ("${ARGV2}" STREQUAL "UNIVERSAL")
|
|
set(HECL_APPLICATION_PIPELINE_REPS_UNIVERSAL "${HECL_APPLICATION_PIPELINE_REPS_UNIVERSAL};${name}" CACHE INTERNAL "")
|
|
else()
|
|
set(HECL_APPLICATION_PIPELINE_REPS "${HECL_APPLICATION_PIPELINE_REPS};${name}" CACHE INTERNAL "")
|
|
endif()
|
|
endfunction()
|
|
|
|
# add_stage_rep(my::fully::qualified::class my_class_header.hpp)
|
|
function(add_stage_rep name header)
|
|
if(IS_ABSOLUTE ${header})
|
|
set(theHeader ${header})
|
|
else()
|
|
set(theHeader ${CMAKE_CURRENT_SOURCE_DIR}/${header})
|
|
endif()
|
|
if (NOT ${theHeader} IN_LIST HECL_APPLICATION_REPS_INCLUDES_LIST)
|
|
set(HECL_APPLICATION_REPS_INCLUDES_LIST "${HECL_APPLICATION_REPS_INCLUDES_LIST};${theHeader}" CACHE INTERNAL "")
|
|
endif()
|
|
set(HECL_APPLICATION_STAGE_REPS "${HECL_APPLICATION_STAGE_REPS};${name}" CACHE INTERNAL "")
|
|
endfunction()
|
|
|
|
function(add_shader_target target)
|
|
if (NOT ${target} IN_LIST HECL_APPLICATION_REPS_TARGETS_LIST)
|
|
set(HECL_APPLICATION_REPS_TARGETS_LIST "${HECL_APPLICATION_REPS_TARGETS_LIST};${target}" CACHE INTERNAL "")
|
|
endif()
|
|
endfunction()
|
|
|
|
function(add_shader file)
|
|
get_filename_component(name ${file} NAME)
|
|
get_filename_component(dir ${file} DIRECTORY)
|
|
shaderc(${CMAKE_CURRENT_BINARY_DIR}/${dir}/shader_${name} ${file}.shader)
|
|
add_stage_rep(shader_${name} ${CMAKE_CURRENT_BINARY_DIR}/${dir}/shader_${name}.hpp)
|
|
add_pipeline_rep(shader_${name} ${CMAKE_CURRENT_BINARY_DIR}/${dir}/shader_${name}.hpp UNIVERSAL)
|
|
add_library(shader_${name} ${CMAKE_CURRENT_BINARY_DIR}/${dir}/shader_${name}.hpp ${CMAKE_CURRENT_BINARY_DIR}/${dir}/shader_${name}.cpp)
|
|
target_link_libraries(shader_${name} PUBLIC boo hecl-light)
|
|
add_shader_target(shader_${name})
|
|
endfunction()
|
|
|
|
function(add_special_shader name)
|
|
add_stage_rep(${name} ${name}.hpp)
|
|
add_pipeline_rep(${name} ${name}.hpp UNIVERSAL)
|
|
add_library(${name} ${name}.hpp ${ARGN})
|
|
target_link_libraries(${name} PUBLIC boo hecl-light)
|
|
add_shader_target(${name})
|
|
endfunction()
|