src/platform/switch/CMakeLists.txt (view raw)
1find_program(ELF2NRO elf2nro)
2find_program(NACPTOOL nacptool)
3find_program(BUILD_ROMFS build_romfs)
4find_library(GLAPI_LIBRARY glapi REQUIRED)
5find_library(EGL_LIBRARY EGL REQUIRED)
6
7set(OS_DEFINES USE_VFS_FILE IOAPI_NO_64)
8list(APPEND CORE_VFS_SRC ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-file.c ${CMAKE_SOURCE_DIR}/src/util/vfs/vfs-dirent.c)
9list(APPEND GUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/gui-font.c)
10
11include_directories(AFTER ${OPENGLES2_INCLUDE_DIR} ${OPENGL_EGL_INCLUDE_DIR})
12
13file(GLOB OS_SRC ${CMAKE_SOURCE_DIR}/src/platform/wii/wii-*.c)
14if(${CMAKE_BUILD_TYPE} STREQUAL Debug OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo)
15 find_library(NOUVEAU_LIBRARY drm_nouveaud REQUIRED)
16 list(APPEND OS_LIB nxd)
17else()
18 find_library(NOUVEAU_LIBRARY drm_nouveau REQUIRED)
19 list(APPEND OS_LIB nx)
20endif()
21set(CORE_VFS_SRC ${CORE_VFS_SRC} PARENT_SCOPE)
22set(OS_DEFINES ${OS_DEFINES} PARENT_SCOPE)
23set(OS_SRC ${OS_SRC} PARENT_SCOPE)
24set(OS_LIB ${OS_LIB} PARENT_SCOPE)
25
26if(BUILD_PERF)
27 add_custom_target(${BINARY_NAME}-perf.nro ALL
28 ${ELF2NRO} ../${BINARY_NAME}-perf ${BINARY_NAME}-perf.nro
29 DEPENDS ${BINARY_NAME}-perf)
30 install(FILES
31 ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}-perf.nro
32 DESTINATION . COMPONENT ${BINARY_NAME}-perf)
33endif()
34
35add_executable(${BINARY_NAME}.elf ${GUI_SRC} ${PLATFORM_SRC} main.c)
36set_target_properties(${BINARY_NAME}.elf PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
37target_link_libraries(${BINARY_NAME}.elf ${BINARY_NAME} ${M_LIBRARY} ${EGL_LIBRARY} ${OPENGLES2_LIBRARY} ${GLAPI_LIBRARY} ${NOUVEAU_LIBRARY} stdc++ ${OS_LIB})
38
39add_custom_command(OUTPUT control.nacp
40 COMMAND ${NACPTOOL} --create "${PROJECT_NAME}" "endrift" "${LIB_VERSION_STRING}" control.nacp)
41
42add_custom_command(OUTPUT romfs.bin
43 COMMAND ${CMAKE_COMMAND} -E make_directory romfs
44 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/res/font-new.png" romfs/
45 COMMAND ${BUILD_ROMFS} romfs romfs.bin
46 COMMAND ${CMAKE_COMMAND} -E remove_directory romfs
47 DEPENDS "${CMAKE_SOURCE_DIR}/res/font-new.png")
48
49add_custom_target(${BINARY_NAME}.nro ALL
50 ${ELF2NRO} ${BINARY_NAME}.elf ${BINARY_NAME}.nro --romfs=romfs.bin --nacp=control.nacp --icon="${CMAKE_CURRENT_SOURCE_DIR}/icon.jpg"
51 DEPENDS ${BINARY_NAME}.elf control.nacp ${CMAKE_CURRENT_SOURCE_DIR}/icon.jpg romfs.bin)