cmake: provide a function to set up assets' language and dependencies

This commit is contained in:
Lephenixnoir 2021-01-27 20:32:34 +01:00
parent 4e1e3c86b4
commit 0902fdc904
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
2 changed files with 19 additions and 9 deletions

View file

@ -26,15 +26,7 @@ set(ASSETS_cg
# ...
)
set_source_files_properties(${ASSETS} PROPERTIES
OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/assets/fxconv-metadata.txt")
set_source_files_properties(${ASSETS_fx} PROPERTIES
OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/assets-fx/fxconv-metadata.txt")
set_source_files_properties(${ASSETS_cg} PROPERTIES
OBJECT_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/assets-cg/fxconv-metadata.txt")
set_source_files_properties(${ASSETS} ${ASSETS_fx} ${ASSETS_cg}
PROPERTIES LANGUAGE FXCONV)
fxconv_declare_assets(${ASSETS} ${ASSETS_fx} ${ASSETS_cg} WITH_METADATA)
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}})
target_link_libraries(myaddin Gint::Gint)

View file

@ -1,2 +1,20 @@
set(CMAKE_FXCONV_COMPILE_OBJECT
"fxconv <SOURCE> -o <OBJECT> --toolchain=sh-elf --${FXSDK_PLATFORM}")
function(fxconv_declare_assets)
cmake_parse_arguments(CONV "WITH_METADATA" "" "" ${ARGN})
foreach(ASSET IN LISTS CONV_UNPARSED_ARGUMENTS)
# Declare this source file as an FXCONV object
set_source_files_properties("${ASSET}" PROPERTIES LANGUAGE FXCONV)
# Set up a dependency to the local fxconv-metadata.txt
if(DEFINED CONV_WITH_METADATA)
get_filename_component(DIR "${ASSET}" DIRECTORY)
set(METADATA "${DIR}/fxconv-metadata.txt")
get_filename_component(METADATA "${METADATA}" ABSOLUTE
BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set_source_files_properties("${ASSET}" PROPERTIES OBJECT_DEPENDS "${METADATA}")
endif()
endforeach()
endfunction()