all repos — mgba @ fd7d05baeecfa62873785a4b4cda77cb7808d36a

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 citro3d ctru)
 17file(GLOB OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/3ds-*.c ${CMAKE_CURRENT_SOURCE_DIR}/ctru-heap.c ${CMAKE_CURRENT_SOURCE_DIR}/socket.c)
 18set(OS_SRC ${OS_SRC} PARENT_SCOPE)
 19set(OS_LIB ${OS_LIB} PARENT_SCOPE)
 20source_group("3DS-specific code" FILES ${OS_SRC})
 21
 22if(USE_VFS_3DS)
 23	list(APPEND OS_DEFINES USE_VFS_3DS)
 24else()
 25	list(APPEND OS_DEFINES USE_VFS_FILE)
 26	list(APPEND CORE_VFS_SRC ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-file.c ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-dirent.c)
 27endif()
 28set(CORE_VFS_SRC ${CORE_VFS_SRC} PARENT_SCOPE)
 29set(OS_DEFINES ${OS_DEFINES} PARENT_SCOPE)
 30
 31list(APPEND GUI_SRC
 32	${CMAKE_CURRENT_BINARY_DIR}/icons.c
 33	${CMAKE_CURRENT_BINARY_DIR}/uishader_g.c
 34	${CMAKE_CURRENT_BINARY_DIR}/uishader_g.h
 35	${CMAKE_CURRENT_BINARY_DIR}/uishader_g.shbin.h
 36	${CMAKE_CURRENT_BINARY_DIR}/uishader_v.c
 37	${CMAKE_CURRENT_BINARY_DIR}/uishader_v.h
 38	${CMAKE_CURRENT_BINARY_DIR}/uishader_v.shbin.h
 39
 40	${CMAKE_CURRENT_SOURCE_DIR}/gui-font.c
 41	${CMAKE_CURRENT_SOURCE_DIR}/ctr-gpu.c
 42	${CMAKE_CURRENT_SOURCE_DIR}/ctr-gpu.h)
 43
 44set_source_files_properties(
 45	${CMAKE_CURRENT_BINARY_DIR}/icons.c
 46	${CMAKE_CURRENT_BINARY_DIR}/uishader_g.c
 47	${CMAKE_CURRENT_BINARY_DIR}/uishader_g.h
 48	${CMAKE_CURRENT_BINARY_DIR}/uishader_g.shbin.h
 49	${CMAKE_CURRENT_BINARY_DIR}/uishader_v.c
 50	${CMAKE_CURRENT_BINARY_DIR}/uishader_v.h
 51	${CMAKE_CURRENT_BINARY_DIR}/uishader_v.shbin.h
 52	PROPERTIES GENERATED ON)
 53
 54add_executable(${BINARY_NAME}.elf ${GUI_SRC} main.c)
 55set_target_properties(${BINARY_NAME}.elf PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
 56target_link_libraries(${BINARY_NAME}.elf ${BINARY_NAME} ${M_LIBRARY} ${OS_LIB})
 57
 58add_custom_command(OUTPUT ${BINARY_NAME}.smdh
 59                   COMMAND ${BANNERTOOL} makesmdh -s "${PROJECT_NAME}" -l "${SUMMARY}" -p "endrift" -i ${CMAKE_SOURCE_DIR}/res/mgba-48.png -o ${BINARY_NAME}.smdh
 60                   DEPENDS ${CMAKE_SOURCE_DIR}/res/mgba-48.png)
 61
 62add_custom_command(OUTPUT ${BINARY_NAME}.bnr
 63                   COMMAND ${BANNERTOOL} makebanner -i ${CMAKE_CURRENT_SOURCE_DIR}/logo.png -a ${CMAKE_CURRENT_SOURCE_DIR}/bios.wav -o ${BINARY_NAME}.bnr
 64                   DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/logo.png ${CMAKE_CURRENT_SOURCE_DIR}/bios.wav)
 65
 66add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/icons.c
 67                   COMMAND ${RAW2C} ${CMAKE_SOURCE_DIR}/src/platform/3ds/icons.raw
 68                   DEPENDS ${CMAKE_SOURCE_DIR}/src/platform/3ds/icons.raw)
 69
 70add_custom_command(
 71	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/uishader_g.shbin ${CMAKE_CURRENT_BINARY_DIR}/uishader_g.shbin.h
 72	MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/uishader.g.pica
 73	COMMAND ${PICASSO}
 74		-o ${CMAKE_CURRENT_BINARY_DIR}/uishader_g.shbin
 75		-h ${CMAKE_CURRENT_BINARY_DIR}/uishader_g.shbin.h
 76		${CMAKE_CURRENT_SOURCE_DIR}/uishader.g.pica
 77	COMMENT "picasso uishader.g.pica")
 78
 79add_custom_command(
 80	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/uishader_g.c ${CMAKE_CURRENT_BINARY_DIR}/uishader_g.h
 81	MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/uishader_g.shbin
 82	COMMAND ${RAW2C} ${CMAKE_CURRENT_BINARY_DIR}/uishader_g.shbin
 83	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 84	COMMENT "raw2c uishader.g.shbin")
 85
 86add_custom_command(
 87	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/uishader_v.shbin ${CMAKE_CURRENT_BINARY_DIR}/uishader_v.shbin.h
 88	MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/uishader.v.pica
 89	COMMAND ${PICASSO}
 90		-o ${CMAKE_CURRENT_BINARY_DIR}/uishader_v.shbin
 91		-h ${CMAKE_CURRENT_BINARY_DIR}/uishader_v.shbin.h
 92		${CMAKE_CURRENT_SOURCE_DIR}/uishader.v.pica
 93	COMMENT "picasso uishader.v.pica")
 94
 95add_custom_command(
 96	OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/uishader_v.c ${CMAKE_CURRENT_BINARY_DIR}/uishader_v.h
 97	MAIN_DEPENDENCY ${CMAKE_CURRENT_BINARY_DIR}/uishader_v.shbin
 98	COMMAND ${RAW2C} ${CMAKE_CURRENT_BINARY_DIR}/uishader_v.shbin
 99	WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
100	COMMENT "raw2c uishader.v.shbin")
101
102add_custom_target(${BINARY_NAME}.3dsx ALL
103                  ${3DSXTOOL} ${BINARY_NAME}.elf ${BINARY_NAME}.3dsx --smdh=${BINARY_NAME}.smdh
104                  DEPENDS ${BINARY_NAME}.elf ${BINARY_NAME}.smdh)
105
106add_custom_target(${BINARY_NAME}.cia ALL
107                  ${STRIP} -o ${BINARY_NAME}-stripped.elf ${BINARY_NAME}.elf
108                  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
109                  DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/cia.rsf ${BINARY_NAME}.elf ${BINARY_NAME}.smdh ${BINARY_NAME}.bnr)
110
111add_custom_target(run ${3DSLINK} ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.3dsx
112                  DEPENDS ${BINARY_NAME}.3dsx)
113
114add_custom_target(install-cia stat -f '0 00000001 %016Xz' '${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.cia' | xxd -r | cat -- - '${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.cia' | nc $ENV{N3DS_IP} 5000
115                  DEPENDS ${BINARY_NAME}.cia)
116
117if(BUILD_PERF)
118	add_custom_target(${BINARY_NAME}-perf.3dsx ALL
119	                  ${3DSXTOOL} ../${BINARY_NAME}-perf ${BINARY_NAME}-perf.3dsx --smdh=${BINARY_NAME}.smdh
120	                  DEPENDS ${BINARY_NAME}-perf ${BINARY_NAME}.smdh)
121	install(FILES
122		    ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}-perf.3dsx
123		    DESTINATION . COMPONENT ${BINARY_NAME}-3ds)
124endif()
125
126configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cia.rsf.in ${CMAKE_CURRENT_BINARY_DIR}/cia.rsf)
127install(FILES
128	    ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.3dsx
129	    ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.smdh
130	    ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.cia
131	    DESTINATION . COMPONENT ${BINARY_NAME}-3ds)