1 # Macro which contains all bits and pieces to create a single grf file based
2 # on NFO and PNG files.
6 function(create_grf_command)
7 set(EXTRA_PNG_SOURCE_FILES ${ARGV})
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)
11 file(GLOB_RECURSE GRF_PNG_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.png)
12 file(GLOB_RECURSE GRF_NFO_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nfo)
13 set(GRF_PNG_SOURCE_FILES ${GRF_PNG_SOURCE_FILES} ${EXTRA_PNG_SOURCE_FILES})
15 # Copy over all the PNG files to the correct folder
16 foreach(GRF_PNG_SOURCE_FILE IN LISTS GRF_PNG_SOURCE_FILES)
17 get_filename_component(GRF_PNG_SOURCE_FILE_NAME "${GRF_PNG_SOURCE_FILE}" NAME)
18 set(GRF_PNG_BINARY_FILE "${CMAKE_CURRENT_BINARY_DIR}/sprites/${GRF_PNG_SOURCE_FILE_NAME}")
20 add_custom_command(OUTPUT ${GRF_PNG_BINARY_FILE}
21 COMMAND ${CMAKE_COMMAND} -E copy
22 ${GRF_PNG_SOURCE_FILE}
23 ${GRF_PNG_BINARY_FILE}
24 MAIN_DEPENDENCY ${GRF_PNG_SOURCE_FILE}
25 COMMENT "Copying ${GRF_PNG_SOURCE_FILE_NAME} sprite file"
28 list(APPEND GRF_PNG_BINARY_FILES ${GRF_PNG_BINARY_FILE})
31 add_custom_command(OUTPUT ${GRF_BINARY_FILE}
32 COMMAND ${CMAKE_COMMAND}
33 -DGRF_SOURCE_FOLDER=${CMAKE_CURRENT_SOURCE_DIR}
34 -DGRF_BINARY_FILE=${GRF_BINARY_FILE}
35 -DNFORENUM_EXECUTABLE=${NFORENUM_EXECUTABLE}
36 -DGRFCODEC_EXECUTABLE=${GRFCODEC_EXECUTABLE}
37 -P ${CMAKE_SOURCE_DIR}/cmake/scripts/CreateGRF.cmake
38 MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/cmake/scripts/CreateGRF.cmake
39 DEPENDS ${GRF_PNG_BINARY_FILES}
40 ${GRF_NFO_SOURCE_FILES}
41 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
42 COMMENT "Generating ${GRF_SOURCE_FOLDER_NAME}.grf"
45 # For conviance, if you want to only test building the GRF
46 add_custom_target(${GRF_SOURCE_FOLDER_NAME}.grf