all repos — mgba @ 465dc2b40048e70380ed26a7451d208f4e643d6c

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