2025-01-09 20:22:49 +01:00
|
|
|
cmake_minimum_required(VERSION 3.18)
|
|
|
|
|
2025-02-22 00:23:48 +01:00
|
|
|
### Helper Function to Build Librarys without have always
|
|
|
|
### These includes and definition defines
|
|
|
|
function(add_pd_lib TARGET_NAME)
|
|
|
|
set(opts "")
|
|
|
|
set(one_val_args "")
|
|
|
|
set(multi_val_args SRC_FILES DEPENDS)
|
|
|
|
cmake_parse_arguments(ARG "${opts}" "${one_val_args}" "${multi_val_args}" ${ARGN})
|
|
|
|
|
|
|
|
add_library(${TARGET_NAME} STATIC ${ARG_SRC_FILES})
|
|
|
|
target_include_directories(${TARGET_NAME} PUBLIC
|
|
|
|
include
|
|
|
|
${DEVKITPRO}/portlibs/3ds/include)
|
|
|
|
target_compile_definitions(${TARGET_NAME} PUBLIC
|
|
|
|
-D_GNU_SOURCE=1
|
|
|
|
-DPALLADIUM_VERSION="${PROJECT_VERSION}"
|
|
|
|
-DPALLADIUM_GIT_COMMIT="${GIT_SHORT_HASH}"
|
2025-03-02 21:11:58 +01:00
|
|
|
-DPALLADIUM_GIT_BRANCH="${GIT_BRANCH}"
|
2025-02-22 00:23:48 +01:00
|
|
|
-DBUILD_CTR=1)
|
|
|
|
### For the libs that depend on another
|
|
|
|
if(ARG_DEPENDS)
|
|
|
|
target_link_libraries(${TARGET_NAME} PUBLIC ${ARG_DEPENDS})
|
|
|
|
endif()
|
|
|
|
install(TARGETS ${TARGET_NAME})
|
|
|
|
endfunction()
|
|
|
|
|
2025-01-09 20:22:49 +01:00
|
|
|
# Setup Toolchain if not specified
|
|
|
|
# Could propably avoided by using arm-none-eabi-cmake
|
|
|
|
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
|
|
|
|
if(DEFINED ENV{DEVKITPRO})
|
|
|
|
set(CMAKE_TOOLCHAIN_FILE "$ENV{DEVKITPRO}/cmake/3DS.cmake" CACHE PATH "toolchain file")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Please define DEVKITPRO to point to your SDK path!")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2025-03-02 21:11:58 +01:00
|
|
|
## Get Current Git Commit Value
|
2025-02-02 20:32:07 +01:00
|
|
|
execute_process(
|
|
|
|
COMMAND git rev-parse --short HEAD
|
2025-02-28 19:49:24 +01:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
2025-02-02 20:32:07 +01:00
|
|
|
OUTPUT_VARIABLE GIT_SHORT_HASH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
|
2025-03-02 21:11:58 +01:00
|
|
|
## Get Current Git Branch
|
|
|
|
execute_process(
|
|
|
|
COMMAND git rev-parse --abbrev-ref HEAD
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE GIT_BRANCH
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
|
|
)
|
|
|
|
|
2025-01-09 20:22:49 +01:00
|
|
|
# Set Project
|
2025-03-12 21:09:45 +01:00
|
|
|
project(palladium LANGUAGES C CXX VERSION 0.3.0)
|
2025-02-22 00:23:48 +01:00
|
|
|
|
|
|
|
option(PD_BUILD_TESTS "Sets if TestApp and TestBench get build" OFF)
|
2025-01-09 20:22:49 +01:00
|
|
|
|
|
|
|
# Enable Compile Command Export
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
|
|
|
# Force C++ 20
|
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
|
|
|
|
|
|
|
|
# Set Special C and CXX flags
|
2025-02-09 21:40:31 +01:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-psabi -O2")
|
2025-01-09 20:22:49 +01:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS} -fno-rtti -fno-exceptions")
|
|
|
|
|
2025-02-28 21:14:20 +01:00
|
|
|
## Core Source Code
|
2025-02-22 00:23:48 +01:00
|
|
|
set(CORE_SRC
|
|
|
|
source/core/common.cpp
|
2025-02-28 21:14:20 +01:00
|
|
|
source/core/bit_util.cpp
|
|
|
|
source/core/color.cpp
|
2025-02-22 00:23:48 +01:00
|
|
|
source/core/io.cpp
|
|
|
|
source/core/strings.cpp
|
|
|
|
source/core/sys.cpp
|
2025-02-28 19:49:24 +01:00
|
|
|
source/core/timer.cpp
|
2025-02-22 00:23:48 +01:00
|
|
|
source/core/timetrace.cpp)
|
2025-01-09 20:22:49 +01:00
|
|
|
|
2025-02-28 21:14:20 +01:00
|
|
|
## Image Source Code
|
|
|
|
set(IMAGE_SRC
|
2025-03-05 20:18:00 +01:00
|
|
|
source/image/image.cpp
|
2025-02-28 21:14:20 +01:00
|
|
|
source/image/img_blur.cpp
|
|
|
|
source/image/img_convert.cpp)
|
2025-01-09 20:22:49 +01:00
|
|
|
|
2025-02-28 21:14:20 +01:00
|
|
|
## External Source Code
|
2025-02-22 00:23:48 +01:00
|
|
|
set(EXTERNAL_SRC
|
|
|
|
source/external/stb.cpp)
|
|
|
|
|
2025-02-28 21:14:20 +01:00
|
|
|
## Drivers Source Code
|
2025-02-22 00:23:48 +01:00
|
|
|
set(DRVS_SRC
|
|
|
|
source/drivers/hid.cpp)
|
|
|
|
|
2025-02-28 21:14:20 +01:00
|
|
|
## Lib3ds Source Code
|
2025-02-22 00:23:48 +01:00
|
|
|
set(L3DS_SRC
|
|
|
|
source/lib3ds/gamepad_icons.cpp
|
|
|
|
source/lib3ds/result_decoder.cpp
|
2025-02-28 19:49:24 +01:00
|
|
|
source/lib3ds/drv_hid.cpp
|
|
|
|
source/lib3ds/hwinfo.cpp
|
|
|
|
source/lib3ds/os.cpp)
|
2025-02-22 00:23:48 +01:00
|
|
|
|
2025-02-28 21:14:20 +01:00
|
|
|
## Lithium Source Code
|
2025-02-22 00:23:48 +01:00
|
|
|
set(LI_SRC
|
|
|
|
source/lithium/li7_shader.cpp
|
|
|
|
source/lithium/spritesheet.cpp
|
|
|
|
source/lithium/texture.cpp
|
|
|
|
source/lithium/font.cpp
|
|
|
|
source/lithium/objects.cpp
|
|
|
|
source/lithium/renderer.cpp)
|
|
|
|
|
2025-02-28 21:14:20 +01:00
|
|
|
## Sounbd Source Code
|
2025-02-28 19:49:24 +01:00
|
|
|
set(SOUND_SRC
|
|
|
|
source/sound/mp3.cpp)
|
|
|
|
|
2025-02-28 21:14:20 +01:00
|
|
|
## Overlay source Code
|
2025-02-22 00:23:48 +01:00
|
|
|
set(OVL_SRC
|
|
|
|
source/overlays/keyboard.cpp
|
|
|
|
source/overlays/message_mgr.cpp
|
|
|
|
source/overlays/overlay_mgr.cpp
|
|
|
|
source/overlays/performance.cpp
|
|
|
|
source/overlays/settings.cpp)
|
|
|
|
|
2025-02-28 21:14:20 +01:00
|
|
|
## App Source Code
|
2025-02-22 00:23:48 +01:00
|
|
|
set(APP_SRC
|
|
|
|
source/app/app.cpp
|
|
|
|
source/app/lang.cpp
|
|
|
|
source/app/error.cpp)
|
|
|
|
|
2025-02-28 21:14:20 +01:00
|
|
|
## UI7 Source Code
|
2025-02-22 00:23:48 +01:00
|
|
|
set(UI7_SRC
|
|
|
|
source/ui7/drawlist.cpp
|
2025-03-08 13:52:11 +01:00
|
|
|
source/ui7/io.cpp
|
2025-02-22 00:23:48 +01:00
|
|
|
source/ui7/menu.cpp
|
|
|
|
source/ui7/theme.cpp
|
|
|
|
source/ui7/ui7.cpp
|
|
|
|
source/ui7/container/container.cpp
|
|
|
|
source/ui7/container/button.cpp
|
|
|
|
source/ui7/container/checkbox.cpp
|
2025-03-09 20:00:47 +01:00
|
|
|
source/ui7/container/coloredit.cpp
|
2025-02-22 00:23:48 +01:00
|
|
|
source/ui7/container/image.cpp
|
|
|
|
source/ui7/container/label.cpp)
|
|
|
|
|
2025-02-28 21:14:20 +01:00
|
|
|
#### Creating the Libraries (if activated) ####
|
|
|
|
add_pd_lib(pd-core SRC_FILES ${CORE_SRC})
|
|
|
|
add_pd_lib(pd-image SRC_FILES ${IMAGE_SRC} DEPENDS pd-core)
|
|
|
|
add_pd_lib(pd-external SRC_FILES ${EXTERNAL_SRC})
|
|
|
|
add_pd_lib(pd-drivers SRC_FILES ${DRVS_SRC} DEPENDS pd-core)
|
|
|
|
add_pd_lib(pd-lib3ds SRC_FILES ${L3DS_SRC} DEPENDS pd-drivers)
|
|
|
|
add_pd_lib(pd-lithium SRC_FILES ${LI_SRC} DEPENDS pd-core pd-image pd-external citro3d)
|
|
|
|
add_pd_lib(pd-sound SRC_FILES ${SOUND_SRC} DEPENDS pd-core mpg123)
|
|
|
|
add_pd_lib(pd-overlays SRC_FILES ${OVL_SRC} DEPENDS pd-lithium)
|
|
|
|
add_pd_lib(pd-app SRC_FILES ${APP_SRC} DEPENDS pd-overlays pd-drivers pd-lib3ds)
|
2025-02-22 00:23:48 +01:00
|
|
|
add_pd_lib(pd-ui7 SRC_FILES ${UI7_SRC} DEPENDS pd-drivers pd-lithium)
|
|
|
|
|
|
|
|
add_library(palladium INTERFACE)
|
|
|
|
target_link_libraries(palladium INTERFACE
|
2025-02-28 21:14:20 +01:00
|
|
|
pd-core pd-image pd-external pd-drivers pd-lib3ds
|
2025-02-28 19:49:24 +01:00
|
|
|
pd-lithium pd-overlays pd-app pd-ui7
|
2025-01-09 20:22:49 +01:00
|
|
|
)
|
2025-02-22 00:23:48 +01:00
|
|
|
|
|
|
|
add_dependencies(palladium
|
2025-02-28 21:14:20 +01:00
|
|
|
pd-core pd-image pd-external pd-drivers
|
2025-02-28 19:49:24 +01:00
|
|
|
pd-lib3ds pd-lithium pd-overlays pd-app pd-ui7
|
|
|
|
)
|
|
|
|
|
|
|
|
add_library(palladium-lite INTERFACE)
|
|
|
|
target_link_libraries(palladium-lite INTERFACE
|
2025-02-28 21:14:20 +01:00
|
|
|
pd-core pd-image pd-external pd-drivers pd-lib3ds
|
2025-02-28 19:49:24 +01:00
|
|
|
pd-lithium
|
|
|
|
)
|
|
|
|
|
|
|
|
add_dependencies(palladium-lite
|
2025-02-28 21:14:20 +01:00
|
|
|
pd-core pd-image pd-external pd-drivers
|
2025-02-28 19:49:24 +01:00
|
|
|
pd-lib3ds pd-lithium
|
2025-01-09 20:22:49 +01:00
|
|
|
)
|
|
|
|
|
2025-02-22 00:23:48 +01:00
|
|
|
if(PD_BUILD_TESTS)
|
2025-01-30 15:06:27 +01:00
|
|
|
add_executable(test test/app/main.cpp)
|
|
|
|
target_include_directories(test PUBLIC include test/app)
|
2025-01-09 20:22:49 +01:00
|
|
|
target_link_directories(test PUBLIC ${CMAKE_BINARY_DIR})
|
|
|
|
target_link_libraries(test PUBLIC palladium citro3d ctru m)
|
2025-01-30 15:06:27 +01:00
|
|
|
|
|
|
|
add_executable(testbench test/bench/main.cpp)
|
|
|
|
target_include_directories(testbench PUBLIC include test/bench)
|
|
|
|
target_link_directories(testbench PUBLIC ${CMAKE_BINARY_DIR})
|
|
|
|
target_link_libraries(testbench PUBLIC palladium citro3d ctru m)
|
2025-01-09 20:22:49 +01:00
|
|
|
# Generate 3DSX
|
|
|
|
ctr_generate_smdh(
|
|
|
|
${CMAKE_BINARY_DIR}/test.smdh
|
|
|
|
NAME "${APP_NAME}"
|
|
|
|
DESCRIPTION "Palladium test app"
|
|
|
|
AUTHOR "tobid7"
|
|
|
|
ICON "test/romfs/icon.png"
|
|
|
|
)
|
|
|
|
ctr_create_3dsx(
|
|
|
|
test
|
|
|
|
OUTPUT "${CMAKE_BINARY_DIR}/test.3dsx"
|
|
|
|
SMDH "${CMAKE_BINARY_DIR}/test.smdh"
|
|
|
|
ROMFS "${CMAKE_SOURCE_DIR}/test/romfs"
|
|
|
|
)
|
2025-01-30 15:06:27 +01:00
|
|
|
ctr_create_3dsx(
|
|
|
|
testbench
|
|
|
|
OUTPUT "${CMAKE_BINARY_DIR}/testbench.3dsx"
|
|
|
|
SMDH "${CMAKE_BINARY_DIR}/test.smdh"
|
|
|
|
ROMFS "${CMAKE_SOURCE_DIR}/test/romfs"
|
|
|
|
)
|
2025-02-22 00:23:48 +01:00
|
|
|
endif()
|
|
|
|
|
2025-01-09 20:22:49 +01:00
|
|
|
install(DIRECTORY include DESTINATION ".")
|