mirror of
https://github.com/perfect-dark-pc-port/perfect_dark.git
synced 2026-10-23 15:52:41 +02:00
28 lines
936 B
CMake
28 lines
936 B
CMake
# execute a header generator (execcmd) for every json file in jsonpath, collect headers in headerlist
|
|
# note that this reads ROMID
|
|
macro(generate_asset_headers jsonpath execcmd extraarg headerlist)
|
|
set(TMP_JSON "")
|
|
|
|
if (${jsonpath} MATCHES "\.json")
|
|
# is a json file
|
|
list(APPEND TMP_JSON "${CMAKE_SOURCE_DIR}/${ASSET_DIR}/${jsonpath}")
|
|
else()
|
|
# is a directory
|
|
file(GLOB TMP_JSON "${CMAKE_SOURCE_DIR}/${ASSET_DIR}/${jsonpath}*.json")
|
|
endif()
|
|
|
|
foreach(JSON ${TMP_JSON})
|
|
unset(HEADERNAME)
|
|
string(REPLACE ".json" ".h" HEADERNAME ${JSON})
|
|
string(REPLACE "${CMAKE_SOURCE_DIR}/${ASSET_DIR}" "${CMAKE_BINARY_DIR}/${GENERATED_DIR}" HEADERNAME ${HEADERNAME})
|
|
add_custom_command(
|
|
OUTPUT ${HEADERNAME}
|
|
DEPENDS ${JSON}
|
|
COMMAND ${execcmd} ${JSON} ${extraarg} --headers-only --romid=${ROMID}
|
|
)
|
|
list(APPEND ${headerlist} "${HEADERNAME}")
|
|
endforeach()
|
|
|
|
unset(TMP_JSON)
|
|
endmacro()
|