all repos — mgba @ 9919fffcb7e6bb23b5a8a77799051cded983c2af

mGBA Game Boy Advance Emulator

src/platform/3ds/CMakeLists.txt (view raw)

  1set(USE_VFS_3DS ON CACNE BOOL "Use 3DS-specific file support")
  2mark_as_advanced(USE_VFS_3DS)
  3
  4find_program(3DSLINK 3dslink)
  5find_program(3DSXTOOL 3dsxtool)
  6find_program(BANNERTOOL bannertool)
  7find_program(MAKEROM makerom)
  8find_program(PICASSO picasso)
  9find_program(RAW2C raw2c)
 10find_program(STRIP ${cross_prefix}strip)
 11
 12set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format" PARENT_SCOPE)
 13set(OS_DEFINES COLOR_16_BIT COLOR_5_6_5 IOAPI_NO_64)
 14
 15include_directories(${CMAKE_CURRENT_BINARY_DIR})
 16list(APPEND OS_LIB ctru)
 17file(GLOB OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/3ds-*.c)
 18set(OS_SRC ${OS_SRC} PARENT_SCOPE)
 19source_group("3DS-specific code" FILES ${OS_SRC})
 20
 21if(USE_VFS_3DS)
 22	list(APPEND OS_DEFINES USE_VFS_3DS)
 23else()
 24	list(APPEND OS_DEFINES USE_VFS_FILE)
 25	list(APPEND CORE_VFS_SRC ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-file.c ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-dirent.c)
 26endif()
 27set(CORE_VFS_SRC ${CORE_VFS_SRC} PARENT_SCOPE)
 28set(OS_DEFINES ${OS_DEFINES} PARENT_SCOPE)
 29
 30list(APPEND GUI_SRC
 31	${CMAKE_CURRENT_BINARY_DIR}/icons.c
 32	${CMAKE_CURRENT_BINARY_DIR}/font.c
 33	${CMAKE_CURRENT_BINARY_DIR}/uishader.c
 34	${CMAKE_CURRENT_BINARY_DIR}/uishader.h
 35	${CMAKE_CURRENT_BINARY_DIR}/uishader.shbin.h
 36
 37	${CMAKE_CURRENT_SOURCE_DIR}/gui-font.c
 38	${CMAKE_CURRENT_SOURCE_DIR}/ctr-gpu.c
 39	${CMAKE_CURRENT_SOURCE_DIR}/ctr-gpu.h)
 40
 41set_source_files_properties(
 42	${CMAKE_CURRENT_BINARY_DIR}/icons.c
 43	${CMAKE_CURRENT_BINARY_DIR}/font.c
 44	${CMAKE_CURRENT_BINARY_DIR}/uishader.c
 45	${CMAKE_CURRENT_BINARY_DIR}/uishader.h
 46	${CMAKE_CURRENT_BINARY_DIR}/uishader.shbin.h
 47	PROPERTIES GENERATED ON)
 48add_executable(${BINARY_NAME}.elf ${GUI_SRC} main.c ctru-heap.c)
 49set_target_properties(${BINARY_NAME}.elf PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
 50target_link_libraries(${BINARY_NAME}.elf ${BINARY_NAME} ${M_LIBRARY} ${OS_LIB})
 51
 52add_custom_command(OUTPUT ${BINARY_NAME}.smdh
 53                   COMMAND ${BANNERTOOL} makesmdh -s "${PROJECT_NAME}" -l "${SUMMARY}" -p "endrift" -i ${CMAKE_SOURCE_DIR}/res/mgba-48.png -o ${BINARY_NAME}.smdh
 54                   DEPENDS ${CMAKE_SOURCE_DIR}/res/mgba-48.png)
 55
 56add_custom_command(OUTPUT ${BINARY_NAME}.bnr
 57                   COMMAND ${BANNERTOOL} makebanner -i ${CMAKE_CURRENT_SOURCE_DIR}/logo.png -a ${CMAKE_CURRENT_SOURCE_DIR}/bios.wav -o ${BINARY_NAME}.bnr
 58                   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/logo.png ${CMAKE_CURRENT_SOURCE_DIR}/bios.wav)
 59
 60add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/font.c
 61                   COMMAND ${RAW2C} ${CMAKE_SOURCE_DIR}/src/platform/3ds/font.raw
 62                   DEPENDS ${CMAKE_SOURCE_DIR}/src/platform/3ds/font.raw)
 63
 64add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/icons.c
 65                   COMMAND ${RAW2C} ${CMAKE_SOURCE_DIR}/src/platform/3ds/icons.raw
 66                   DEPENDS ${CMAKE_SOURCE_DIR}/src/platform/3ds/icons.raw)
 67
 68add_custom_command(
 69	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/uishader.shbin ${CMAKE_CURRENT_BINARY_DIR}/uishader.shbin.h
 70	MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/uishader.vsh
 71	COMMAND ${PICASSO}
 72		-o ${CMAKE_CURRENT_BINARY_DIR}/uishader.shbin
 73		-h ${CMAKE_CURRENT_BINARY_DIR}/uishader.shbin.h
 74		${CMAKE_CURRENT_SOURCE_DIR}/uishader.vsh
 75	COMMENT "picasso uishader.vsh")
 76
 77add_custom_command(
 78	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/uishader.c ${CMAKE_CURRENT_BINARY_DIR}/uishader.h
 79	MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/uishader.shbin
 80	COMMAND ${RAW2C} ${CMAKE_CURRENT_BINARY_DIR}/uishader.shbin
 81	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 82	COMMENT "raw2c uishader.shbin")
 83
 84add_custom_target(${BINARY_NAME}.3dsx ALL
 85                  ${3DSXTOOL} ${BINARY_NAME}.elf ${BINARY_NAME}.3dsx --smdh=${BINARY_NAME}.smdh
 86                  DEPENDS ${BINARY_NAME}.elf ${BINARY_NAME}.smdh)
 87
 88add_custom_target(${BINARY_NAME}.cia ALL
 89                  ${STRIP} -o ${BINARY_NAME}-stripped.elf ${BINARY_NAME}.elf
 90                  COMMAND ${MAKEROM} -f cia -o ${BINARY_NAME}.cia -rsf cia.rsf -target t -exefslogo -elf ${BINARY_NAME}-stripped.elf -icon ${BINARY_NAME}.smdh -banner ${BINARY_NAME}.bnr
 91                  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/cia.rsf ${BINARY_NAME}.elf ${BINARY_NAME}.smdh ${BINARY_NAME}.bnr)
 92
 93add_custom_target(run ${3DSLINK} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.3dsx
 94                  DEPENDS ${BINARY_NAME}.3dsx)
 95
 96configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cia.rsf.in ${CMAKE_CURRENT_BINARY_DIR}/cia.rsf)
 97install(FILES
 98	    ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.3dsx
 99	    ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.smdh
100	    ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.cia
101	    DESTINATION . COMPONENT ${BINARY_NAME}-3ds)