Switches to target generation instead of raw output file list.

This commit is contained in:
Erik Abair 2023-07-22 21:05:50 -07:00
parent cabe10fbc2
commit 5e8e998f6c
2 changed files with 34 additions and 6 deletions

View File

@ -124,7 +124,7 @@ endmacro()
# Vertex shaders.
generate_nv2a_vshinc_files(
generated_vertex_shaders
generated_nv2a_vertex_shaders
SOURCES
src/shaders/fog_infinite_fogc_test.vsh
src/shaders/fog_vec4_w.vsh
@ -240,6 +240,7 @@ target_link_libraries(
PUBLIC
generated_fp20_pixel_shaders
generated_vp20_vertex_shaders
generated_nv2a_vertex_shaders
PRIVATE
fpng
printf
@ -373,7 +374,6 @@ add_executable(
src/tests/z_min_max_control_tests.h
src/tests/zero_stride_tests.cpp
src/tests/zero_stride_tests.h
${generated_vertex_shaders}
)
# Pull debug info out of the binary into a host-side linked binary.

View File

@ -22,11 +22,15 @@ function(generate_nv2a_vshinc_files)
set(target "${ARGV0}")
set("${target}")
foreach (src ${NV2A_VSH_SOURCES})
set(output "${CMAKE_CURRENT_BINARY_DIR}/${src}inc")
set(generated_sources)
set(generated_source_dirs)
foreach (src ${NV2A_VSH_SOURCES})
get_filename_component(abs_src "${src}" REALPATH)
get_filename_component(src_dirname "${src}" DIRECTORY)
get_filename_component(src_basename "${src}" NAME_WE)
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${src_dirname}")
set(output "${CMAKE_CURRENT_BINARY_DIR}/${src_dirname}/${src_basename}.vshinc")
add_custom_command(
OUTPUT "${output}"
@ -34,6 +38,30 @@ function(generate_nv2a_vshinc_files)
DEPENDS "${abs_src}"
)
set("${target}" "${${target}};${output}" CACHE INTERNAL "")
list(APPEND generated_sources "${output}")
list(APPEND generated_source_dirs "${CMAKE_CURRENT_BINARY_DIR}/${src_dirname}")
endforeach ()
add_custom_target(
"${target}_gen"
DEPENDS
${generated_sources}
)
list(REMOVE_DUPLICATES generated_source_dirs)
add_library(
"${target}"
INTERFACE
EXCLUDE_FROM_ALL
${generated_sources}
)
target_include_directories(
"${target}"
INTERFACE
${generated_source_dirs}
)
add_dependencies(
"${target}"
"${target}_gen"
)
endfunction()