install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${TARGET_NAME}.bin
          DESTINATION ${SEGASMP_DESTINATION}/${TARGET_PATH}/CD
          RENAME 0.bin )

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/IP.BIN
              DESTINATION ${SEGASMP_DESTINATION}/${TARGET_PATH}/CD )
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.cue DESTINATION ${SEGASMP_DESTINATION}/${TARGET_PATH} )


list(TRANSFORM CD_FILES PREPEND "${CMAKE_INSTALL_PREFIX}/${SEGASMP_DESTINATION}/${TARGET_PATH}/CD/" )
list(TRANSFORM CD_FILES APPEND "\\n" )

set (filename ${CMAKE_INSTALL_PREFIX}/${SEGASMP_DESTINATION}/${TARGET_PATH}/CD/FILES.txt)
install(CODE "file(WRITE ${filename} ${CD_FILES})")

set(MAKE_CMD $ENV{SATURN_CD}/create_cd.sh
    "${TARGET_NAME}" "\"SBL\"" "\"SBL\"" IP.BIN
    "${TARGET_NAME}.iso" "${CMAKE_INSTALL_PREFIX}/${SEGASMP_DESTINATION}/${TARGET_PATH}/")

install(CODE "execute_process(COMMAND
                                ${MAKE_CMD}
                                WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/${SEGASMP_DESTINATION}/${TARGET_PATH}/CD)")
