all repos — mgba @ 8862dc49aa03691b5cbd614dde1a99420d555cbd

mGBA Game Boy Advance Emulator

src/platform/psp2/CMakeLists.txt (view raw)

 1find_program(FIXUP vita-elf-create)
 2find_program(MAKE_FSELF vita-make-fself)
 3find_program(MAKE_SFO vita-mksfoex)
 4find_program(OBJCOPY ${cross_prefix}objcopy)
 5find_file(NIDDB db.json PATHS ${VITASDK} ${VITASDK}/bin ${VITASDK}/share)
 6find_program(STRIP ${cross_prefix}strip)
 7
 8set(OS_DEFINES IOAPI_NO_64)
 9set(OS_DEFINES ${OS_DEFINES} PARENT_SCOPE)
10
11file(GLOB OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/psp2-*.c)
12set(OS_SRC ${OS_SRC} PARENT_SCOPE)
13source_group("PS Vita-specific code" FILES ${OS_SRC})
14
15list(APPEND CORE_VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/sce-vfs.c)
16set(CORE_VFS_SRC ${CORE_VFS_SRC} PARENT_SCOPE)
17
18set(OS_LIB -lvita2d -lSceCtrl_stub -lScePgf_stub -lSceGxm_stub -lSceDisplay_stub -lSceAudio_stub -lSceCommonDialog_stub -lSceMotion_stub -lScePower_stub -lSceSysmodule_stub -lSceTouch_stub -l${M_LIBRARY})
19set(OBJCOPY_CMD ${OBJCOPY} -I binary -O elf32-littlearm -B arm)
20
21list(APPEND GUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/gui-font.c)
22
23set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/icons.o
24                            ${CMAKE_CURRENT_BINARY_DIR}/font.o
25                            ${CMAKE_CURRENT_BINARY_DIR}/backdrop.o
26                            PROPERTIES GENERATED ON)
27add_executable(${BINARY_NAME}.elf ${PLATFORM_SRC} ${GUI_SRC} main.c
28               ${CMAKE_CURRENT_BINARY_DIR}/icons.o
29               ${CMAKE_CURRENT_BINARY_DIR}/font.o
30               ${CMAKE_CURRENT_BINARY_DIR}/backdrop.o)
31set_target_properties(${BINARY_NAME}.elf PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
32target_link_libraries(${BINARY_NAME}.elf ${BINARY_NAME} ${OS_LIB})
33
34add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/font.o
35                   COMMAND ${OBJCOPY_CMD} font2x.png ${CMAKE_CURRENT_BINARY_DIR}/font.o
36                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/res)
37
38add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/icons.o
39                   COMMAND ${OBJCOPY_CMD} icons2x.png ${CMAKE_CURRENT_BINARY_DIR}/icons.o
40                   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/res)
41
42add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/backdrop.o
43                   COMMAND ${OBJCOPY_CMD} backdrop.png ${CMAKE_CURRENT_BINARY_DIR}/backdrop.o
44                   WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
45
46add_custom_target(${BINARY_NAME}.velf ALL
47                  ${STRIP} --strip-unneeded -go ${BINARY_NAME}-stripped.elf ${BINARY_NAME}.elf
48                  COMMAND ${FIXUP} ${BINARY_NAME}-stripped.elf ${BINARY_NAME}.velf ${NIDDB}
49                  DEPENDS ${BINARY_NAME}.elf)
50
51add_custom_target(sce_sys ${CMAKE_COMMAND} -E make_directory sce_sys)
52
53add_custom_target(param.sfo
54                  ${MAKE_SFO} ${PROJECT_NAME} -s TITLE_ID=MGBA00001 sce_sys/param.sfo
55                  DEPENDS sce_sys)
56
57add_custom_target(eboot.bin
58                  ${MAKE_FSELF} ${BINARY_NAME}.velf eboot.bin
59                  DEPENDS ${BINARY_NAME}.velf)
60
61add_custom_target(livearea
62                  ${CMAKE_COMMAND} -E make_directory sce_sys/livearea/contents
63                  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/icon0.png sce_sys
64                  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/template.xml sce_sys/livearea/contents
65                  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/bg.png sce_sys/livearea/contents
66                  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/startup.png sce_sys/livearea/contents
67                  DEPENDS sce_sys)
68
69add_custom_target(${BINARY_NAME}.vpk ALL
70                  zip -r ${BINARY_NAME}.vpk sce_sys eboot.bin
71                  DEPENDS livearea eboot.bin param.sfo)
72
73install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.vpk DESTINATION . COMPONENT ${BINARY_NAME}-psp2)