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 _GNU_SOURCE 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 ${OPENGLES3_INCLUDE_DIR} ${OPENGL_EGL_INCLUDE_DIR})
12
13if(${CMAKE_BUILD_TYPE} STREQUAL Debug OR ${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo)
14 find_library(NOUVEAU_LIBRARY drm_nouveaud REQUIRED)
15 list(APPEND OS_LIB nxd)
16else()
17 find_library(NOUVEAU_LIBRARY drm_nouveau REQUIRED)
18 list(APPEND OS_LIB nx)
19endif()
20set(CORE_VFS_SRC ${CORE_VFS_SRC} PARENT_SCOPE)
21set(OS_DEFINES ${OS_DEFINES} PARENT_SCOPE)
22set(OS_LIB ${OS_LIB} PARENT_SCOPE)
23
24if(BUILD_PERF)
25 add_custom_target(${BINARY_NAME}-perf.nro ALL
26 ${ELF2NRO} ../${BINARY_NAME}-perf ${BINARY_NAME}-perf.nro
27 DEPENDS ${BINARY_NAME}-perf)
28 install(FILES
29 ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}-perf.nro
30 DESTINATION . COMPONENT ${BINARY_NAME}-perf)
31endif()
32
33add_executable(${BINARY_NAME}.elf ${GUI_SRC} ${PLATFORM_SRC} main.c)
34set_target_properties(${BINARY_NAME}.elf PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}")
35target_link_libraries(${BINARY_NAME}.elf ${BINARY_NAME} ${M_LIBRARY} ${EGL_LIBRARY} ${OPENGLES3_LIBRARY} ${GLAPI_LIBRARY} ${NOUVEAU_LIBRARY} stdc++ ${OS_LIB})
36
37add_custom_command(OUTPUT control.nacp
38 COMMAND ${NACPTOOL} --create "${PROJECT_NAME}" "endrift" "${VERSION_STRING}" control.nacp)
39
40add_custom_command(OUTPUT romfs.bin
41 COMMAND ${CMAKE_COMMAND} -E make_directory romfs
42 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/res/font-new.png" romfs/
43 COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/fileassoc.cfg.in" romfs/
44 COMMAND ${BUILD_ROMFS} romfs romfs.bin
45 COMMAND ${CMAKE_COMMAND} -E remove_directory romfs
46 DEPENDS "${CMAKE_SOURCE_DIR}/res/font-new.png" "${CMAKE_CURRENT_SOURCE_DIR}/fileassoc.cfg.in")
47
48add_custom_target(${BINARY_NAME}.nro ALL
49 ${ELF2NRO} ${BINARY_NAME}.elf ${BINARY_NAME}.nro --romfs=romfs.bin --nacp=control.nacp --icon="${CMAKE_CURRENT_SOURCE_DIR}/icon.jpg"
50 DEPENDS ${BINARY_NAME}.elf control.nacp ${CMAKE_CURRENT_SOURCE_DIR}/icon.jpg romfs.bin)
51
52install(TARGETS ${BINARY_NAME}.elf DESTINATION . COMPONENT ${BINARY_NAME}-dbg)
53install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.nro DESTINATION . COMPONENT ${BINARY_NAME}-switch)