1 # Macro which contains all bits and pieces to create a single grf file based
2 # on NFO and PNG files.
4 # create_grf_command(NFO_SOURCE_FILES nfo_file1 ... PNG_SOURCE_FILES png_file1 ...)
6 function(create_grf_command)
7 cmake_parse_arguments(GRF "" "" "NFO_SOURCE_FILES;PNG_SOURCE_FILES" ${ARGN})
9 get_filename_component(GRF_SOURCE_FOLDER_NAME "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
10 get_filename_component(GRF_BINARY_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../${GRF_SOURCE_FOLDER_NAME}.grf ABSOLUTE)
12 # Copy over all the PNG files to the correct folder
13 foreach(GRF_PNG_SOURCE_FILE IN LISTS GRF_PNG_SOURCE_FILES)
14 get_filename_component(GRF_PNG_SOURCE_FILE_NAME "${GRF_PNG_SOURCE_FILE}" NAME)
15 set(GRF_PNG_BINARY_FILE "${CMAKE_CURRENT_BINARY_DIR}/sprites/${GRF_PNG_SOURCE_FILE_NAME}")
17 add_custom_command(OUTPUT ${GRF_PNG_BINARY_FILE}
18 COMMAND ${CMAKE_COMMAND} -E copy
19 ${GRF_PNG_SOURCE_FILE}
20 ${GRF_PNG_BINARY_FILE}
21 MAIN_DEPENDENCY ${GRF_PNG_SOURCE_FILE}
22 COMMENT "Copying ${GRF_PNG_SOURCE_FILE_NAME} sprite file"
25 list(APPEND GRF_PNG_BINARY_FILES ${GRF_PNG_BINARY_FILE})
28 add_custom_command(OUTPUT ${GRF_BINARY_FILE} ${GRF_BINARY_FILE}.hash
29 COMMAND ${CMAKE_COMMAND}
30 -DGRF_SOURCE_FOLDER=${CMAKE_CURRENT_SOURCE_DIR}
31 -DGRF_BINARY_FILE=${GRF_BINARY_FILE}
32 -DNFORENUM_EXECUTABLE=${NFORENUM_EXECUTABLE}
33 -DGRFCODEC_EXECUTABLE=${GRFCODEC_EXECUTABLE}
34 -DGRFID_EXECUTABLE=${GRFID_EXECUTABLE}
35 -P ${CMAKE_SOURCE_DIR}/cmake/scripts/CreateGRF.cmake
36 MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/cmake/scripts/CreateGRF.cmake
37 DEPENDS ${GRF_PNG_BINARY_FILES}
38 ${GRF_NFO_SOURCE_FILES}
39 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
40 COMMENT "Generating ${GRF_SOURCE_FOLDER_NAME}.grf"
43 # For conviance, if you want to only test building the GRF
44 add_custom_target(${GRF_SOURCE_FOLDER_NAME}.grf