2018-03-10 21:02:38 +00:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
#set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
|
|
|
|
|
|
set(CMAKE_SYSTEM_NAME "Generic")
|
|
|
|
|
|
|
|
set(DEVKITPRO $ENV{DEVKITPRO})
|
|
|
|
set(CMAKE_SYSTEM_PROCESSOR "armv8-a")
|
|
|
|
set(CMAKE_C_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc")
|
|
|
|
set(CMAKE_CXX_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-g++")
|
|
|
|
set(CMAKE_ASM_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-as")
|
|
|
|
set(CMAKE_AR "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ar" CACHE STRING "")
|
|
|
|
set(CMAKE_RANLIB "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ranlib" CACHE STRING "")
|
2018-10-02 06:26:49 +00:00
|
|
|
set(CMAKE_C_FLAGS "-g -O2 -march=armv8-a -mtune=cortex-a57 -mtp=soft -ftls-model=local-exec -fPIC -I${DEVKITPRO}/libnx/include -I${DEVKITPRO}/portlibs/switch/include" CACHE STRING "C flags")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions" CACHE STRING "C++ flags")
|
2018-03-10 21:02:38 +00:00
|
|
|
set(CMAKE_FIND_ROOT_PATH ${DEVKITPRO} ${DEVKITPRO}/devkitA64 ${DEVKITPRO}/libnx ${DEVKITPRO}/portlibs/switch)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
|
|
|
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
|
|
|
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available")
|
|
|
|
|
|
|
|
project(SDL2)
|
|
|
|
|
|
|
|
set(SRC_DIRS
|
|
|
|
src
|
|
|
|
src/atomic
|
|
|
|
src/audio
|
2018-03-14 13:16:52 +00:00
|
|
|
src/audio/switch
|
2018-03-10 21:02:38 +00:00
|
|
|
src/cpuinfo
|
|
|
|
src/events
|
|
|
|
src/file
|
|
|
|
src/filesystem/dummy
|
|
|
|
src/haptic
|
|
|
|
src/haptic/dummy
|
|
|
|
src/joystick
|
2018-03-12 20:22:15 +00:00
|
|
|
src/joystick/switch
|
2018-03-10 21:02:38 +00:00
|
|
|
src/joystick/dummy
|
|
|
|
src/libm
|
|
|
|
src/power
|
|
|
|
src/render
|
|
|
|
src/render/software
|
2018-10-02 06:26:49 +00:00
|
|
|
src/render/opengl
|
|
|
|
src/render/opengles
|
|
|
|
src/render/opengles2
|
2018-03-10 21:02:38 +00:00
|
|
|
src/stdlib
|
|
|
|
src/thread
|
|
|
|
src/thread/switch
|
|
|
|
src/timer
|
|
|
|
src/timer/switch
|
|
|
|
src/video
|
|
|
|
src/video/yuv2rgb
|
|
|
|
src/video/switch
|
|
|
|
)
|
|
|
|
|
|
|
|
set(SRC_FILES )
|
|
|
|
foreach (DIR ${SRC_DIRS})
|
|
|
|
file(GLOB FILES ${DIR}/*.c*)
|
|
|
|
list(APPEND SRC_FILES ${FILES})
|
|
|
|
endforeach (DIR)
|
|
|
|
|
|
|
|
# SDL2 library
|
|
|
|
add_library(${PROJECT_NAME} STATIC ${SRC_FILES})
|
|
|
|
target_include_directories(${PROJECT_NAME} PUBLIC ${SRC_DIRS} include)
|
2018-10-02 06:26:49 +00:00
|
|
|
target_compile_options(${PROJECT_NAME} PUBLIC -O3 -D__SWITCH__ -DSDL_VIDEO_STATIC_ANGLE)
|
2018-03-10 21:02:38 +00:00
|
|
|
|
|
|
|
# SDL2 test
|
|
|
|
add_executable(${PROJECT_NAME}.elf test/testswitch.c)
|
|
|
|
target_include_directories(${PROJECT_NAME}.elf PRIVATE include)
|
2018-03-12 20:22:15 +00:00
|
|
|
target_compile_options(${PROJECT_NAME}.elf PRIVATE -O3 -D__SWITCH__)
|
2018-03-10 21:02:38 +00:00
|
|
|
target_link_libraries(${PROJECT_NAME}.elf
|
|
|
|
${PROJECT_NAME}
|
2018-10-02 06:26:49 +00:00
|
|
|
${DEVKITPRO}/portlibs/switch/lib/libEGL.a
|
|
|
|
${DEVKITPRO}/portlibs/switch/lib/libglapi.a
|
|
|
|
${DEVKITPRO}/portlibs/switch/lib/libdrm_nouveau.a
|
2018-03-10 21:02:38 +00:00
|
|
|
${DEVKITPRO}/libnx/lib/libnx.a
|
2018-10-02 06:26:49 +00:00
|
|
|
stdc++
|
2018-03-10 21:02:38 +00:00
|
|
|
m
|
|
|
|
)
|
|
|
|
set_target_properties(${PROJECT_NAME}.elf PROPERTIES LINK_FLAGS "-specs=${DEVKITPRO}/libnx/switch.specs")
|
|
|
|
add_custom_target(${PROJECT_NAME}.nro
|
|
|
|
DEPENDS ${PROJECT_NAME}.elf
|
|
|
|
COMMAND elf2nro ${PROJECT_NAME}.elf ${PROJECT_NAME}.nro)
|