all repos — mgba @ 9de8f084ba55460b02d300c1dd8b8e6c56f691d5

mGBA Game Boy Advance Emulator

src/platform/switch/CMakeToolchain.txt (view raw)

 1if(DEFINED ENV{DEVKITPRO})
 2	set(DEVKITPRO $ENV{DEVKITPRO})
 3else()
 4	message(FATAL_ERROR "Could not find DEVKITPRO in environment")
 5endif()
 6
 7if(DEFINED ENV{DEVKITA64})
 8	set(DEVKITA64 $ENV{DEVKITA64})
 9else()
10	set(DEVKITA64 ${DEVKITPRO}/devkitA64)
11endif()
12
13if(DEFINED ENV{LIBNX})
14	set(LIBNX $ENV{LIBNX})
15else()
16	set(LIBNX ${DEVKITPRO}/libnx)
17endif()
18
19set(extension)
20if (CMAKE_HOST_WIN32)
21	set(extension .exe)
22endif()
23
24set(CMAKE_PROGRAM_PATH ${DEVKITA64}/bin)
25set(cross_prefix aarch64-none-elf-)
26set(arch_flags "-mtune=cortex-a57 -ffunction-sections -march=armv8-a -mtp=soft -fPIC -ftls-model=local-exec")
27set(inc_flags "-I${LIBNX}/include ${arch_flags}")
28set(link_flags "-L${LIBNX}/lib -lnx -specs=${LIBNX}/switch.specs ${arch_flags}")
29
30set(CMAKE_SYSTEM_NAME Generic CACHE INTERNAL "system name")
31set(CMAKE_SYSTEM_PROCESSOR aarch64 CACHE INTERNAL "processor")
32set(CMAKE_LIBRARY_ARCHITECTURE aarch64-none-elf CACHE INTERNAL "abi")
33
34find_program(CMAKE_AR ${cross_prefix}gcc-ar${extension})
35find_program(CMAKE_RANLIB ${cross_prefix}gcc-ranlib${extension})
36find_program(CMAKE_C_COMPILER ${cross_prefix}gcc${extension})
37find_program(CMAKE_CXX_COMPILER ${cross_prefix}g++${extension})
38find_program(CMAKE_ASM_COMPILER ${cross_prefix}gcc${extension})
39find_program(CMAKE_LINKER ${cross_prefix}ld${extension})
40set(CMAKE_C_FLAGS ${inc_flags} CACHE INTERNAL "c compiler flags")
41set(CMAKE_ASM_FLAGS ${inc_flags} CACHE INTERNAL "assembler flags")
42set(CMAKE_CXX_FLAGS ${inc_flags} CACHE INTERNAL "cxx compiler flags")
43SET(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> <FLAGS> -o <OBJECT>   -c <SOURCE>")
44
45set(CMAKE_EXE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "exe link flags")
46set(CMAKE_MODULE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "module link flags")
47set(CMAKE_SHARED_LINKER_FLAGS ${link_flags} CACHE INTERNAL "shared link flags")
48
49set(CMAKE_FIND_ROOT_PATH ${DEVKITARM}/aarch64-none-elf ${DEVKITPRO}/portlibs/switch)
50set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE INTERNAL "")
51set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CACHE INTERNAL "")
52set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY CACHE INTERNAL "")
53set(PKG_CONFIG_EXECUTABLE "/dev/null" CACHE INTERNAL "" FORCE)
54
55set(SWITCH ON)
56add_definitions(-D__SWITCH__)