cmake: Allow specifying rez files by absolute path

This allows generated rez files to be listed in add_application by their
full path in the build directory, e.g. ${CMAKE_CURRENT_BINARY_DIR}/foo.r

Closes #176
This commit is contained in:
Ryan Schmidt 2022-09-21 01:32:09 -05:00
parent 8fdb2f3a84
commit 3616f855a9

View File

@ -28,21 +28,21 @@ function(add_application name)
list(TRANSFORM rez_include_options PREPEND -I) list(TRANSFORM rez_include_options PREPEND -I)
foreach(f ${ARGS_FILES}) foreach(f ${ARGS_FILES})
get_filename_component(abspath "${f}" ABSOLUTE)
if(${f} MATCHES "\\.r$") if(${f} MATCHES "\\.r$")
get_filename_component(rsrc_file "${f}" NAME)
set(rsrc_file "${CMAKE_CURRENT_BINARY_DIR}/${rsrc_file}.rsrc.bin")
add_custom_command( add_custom_command(
OUTPUT ${f}.rsrc.bin OUTPUT ${rsrc_file}
COMMAND ${REZ} ${REZ_FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${f} ${rez_include_options} -o ${f}.rsrc.bin COMMAND ${REZ} ${REZ_FLAGS} ${abspath} ${rez_include_options} -o ${rsrc_file}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${f}) DEPENDS ${abspath})
list(APPEND rsrc_files "${CMAKE_CURRENT_BINARY_DIR}/${f}.rsrc.bin") list(APPEND rsrc_files "${rsrc_file}")
list(APPEND rez_files "${f}") list(APPEND rez_files "${abspath}")
elseif(${f} MATCHES "\\.rsrc$") elseif(${f} MATCHES "\\.rsrc$")
get_filename_component(abspath "${f}" ABSOLUTE)
list(APPEND rsrc_files "${abspath}") list(APPEND rsrc_files "${abspath}")
elseif(${f} MATCHES "\\.rsrc.bin$") elseif(${f} MATCHES "\\.rsrc.bin$")
get_filename_component(abspath "${f}" ABSOLUTE)
list(APPEND rsrc_files "${abspath}") list(APPEND rsrc_files "${abspath}")
else() else()
get_filename_component(abspath "${f}" ABSOLUTE)
list(APPEND files "${abspath}") list(APPEND files "${abspath}")
endif() endif()
endforeach() endforeach()