src/platform/3ds/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{DEVKITARM})
8 set(DEVKITARM $ENV{DEVKITARM})
9else()
10 set(DEVKITARM ${DEVKITPRO}/devkitARM)
11endif()
12
13if(DEFINED ENV{CTRULIB})
14 set(CTRULIB $ENV{CTRULIB})
15else()
16 set(CTRULIB ${DEVKITPRO}/libctru)
17endif()
18
19set(extension)
20if (CMAKE_HOST_WIN32)
21 set(extension .exe)
22endif()
23
24set(CMAKE_PROGRAM_PATH ${DEVKITARM}/bin)
25set(cross_prefix arm-none-eabi-)
26set(arch_flags "-march=armv6k -mtune=mpcore -mfloat-abi=hard -ffunction-sections")
27set(inc_flags "-I${CTRULIB}/include ${arch_flags} -mword-relocations")
28set(link_flags "-L${CTRULIB}/lib -lctru -specs=3dsx.specs ${arch_flags} -Wl,--gc-sections")
29
30set(CMAKE_SYSTEM_NAME Generic CACHE INTERNAL "system name")
31set(CMAKE_SYSTEM_PROCESSOR arm CACHE INTERNAL "processor")
32set(CMAKE_LIBRARY_ARCHITECTURE arm-none-eabi 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")
43
44set(CMAKE_EXE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "exe link flags")
45set(CMAKE_MODULE_LINKER_FLAGS ${link_flags} CACHE INTERNAL "module link flags")
46set(CMAKE_SHARED_LINKER_FLAGS ${link_flags} CACHE INTERNAL "shared link flags")
47
48set(CMAKE_FIND_ROOT_PATH ${DEVKITARM}/arm-none-eabi ${DEVKITPRO}/portlibs/3ds)
49set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER CACHE INTERNAL "")
50set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY CACHE INTERNAL "")
51set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY CACHE INTERNAL "")
52set(PKG_CONFIG_EXECUTABLE "/dev/null" CACHE INTERNAL "" FORCE)
53
54set(3DS ON)
55add_definitions(-D_3DS -DARM11)