This commit is contained in:
2025-08-05 15:59:12 -05:00
parent 577bef8fb7
commit d68fae0db7
30 changed files with 1389 additions and 42 deletions

View File

@@ -0,0 +1,99 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
if(NOT TARGET pspsdk)
message(STATUS "Looking for PSPSDK...")
set(PSPSDK_FOUND FALSE CACHE INTERNAL "PSPSDK found")
set(PSPSDK_DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/_pspsdk")
set(PSPSDK_SEARCH_ROOTS
"${PSPSDK_ROOT}"
"$ENV{PSPDEV}"
"$ENV{HOME}/pspdev"
"/usr/local/pspdev"
"/opt/pspdev"
"/usr/pspdev"
"${PSPSDK_DOWNLOAD_DIR}/pspdev"
)
foreach(root IN LISTS PSPSDK_SEARCH_ROOTS)
list(APPEND PSPSDK_BIN_HINTS "${root}/bin")
list(APPEND PSPSDK_INCLUDE_HINTS "${root}/include")
list(APPEND PSPSDK_LIB_HINTS "${root}/lib")
endforeach()
# Find PSP GCC
find_program(PSPSDK_PSP_GCC NAMES psp-gcc HINTS ${PSPSDK_BIN_HINTS})
# If we did not find it, download it.
if(NOT PSPSDK_PSP_GCC)
message(STATUS "psp-gcc not found in system paths. Downloading PSPSDK tarball...")
file(DOWNLOAD
"https://github.com/pspdev/pspdev/releases/latest/download/pspdev-ubuntu-latest-x86_64.tar.gz"
"${CMAKE_BINARY_DIR}/pspsdk.tar.gz"
EXPECTED_HASH SHA256=afe338e92f6eeec21c56a64eeb65201e6b95ecbae938ae38688bbf0f17b69ead
SHOW_PROGRESS
)
# Make output dir
file(MAKE_DIRECTORY "${PSPSDK_DOWNLOAD_DIR}")
# Extract the tarball
execute_process(
COMMAND
${CMAKE_COMMAND} -E tar xzf "${CMAKE_BINARY_DIR}/pspsdk.tar.gz"
WORKING_DIRECTORY
"${PSPSDK_DOWNLOAD_DIR}"
RESULT_VARIABLE
tar_result
)
if(NOT tar_result EQUAL 0)
message(FATAL_ERROR "Failed to extract PSPSDK tarball")
endif()
# Retry discovery with extracted fallback
find_program(PSPSDK_PSP_GCC NAMES psp-gcc HINTS ${PSPSDK_BIN_HINTS})
endif()
if(PSPSDK_PSP_GCC)
get_filename_component(PSPSDK_BIN_ROOT "${PSPSDK_PSP_GCC}" DIRECTORY)
get_filename_component(PSPSDK_ROOT "${PSPSDK_BIN_ROOT}" DIRECTORY)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(ENV{PSPDEV} "${PSPSDK_ROOT}")
set(CMAKE_TOOLCHAIN_FILE "${PSPSDK_ROOT}/psp/share/pspdev.cmake")
set(BUILD_PRX ON CACHE BOOL "Build PRX modules")
include("${PSPSDK_ROOT}/psp/share/pspdev.cmake")
set(CMAKE_C_COMPILER ${PSPSDK_BIN_ROOT}/psp-gcc)
set(CMAKE_CXX_COMPILER ${PSPSDK_BIN_ROOT}/psp-g++)
if(NOT DEFINED PSP)
message(FATAL_ERROR "PSP environment variable is not set correctly.")
endif()
add_library(pspsdk INTERFACE IMPORTED)
set_target_properties(pspsdk PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${PSPSDK_INCLUDE_DIR}"
INTERFACE_LINK_DIRECTORIES "${PSPSDK_LIB_DIR}"
)
target_include_directories(pspsdk
INTERFACE
${PSPDEV}/psp/include
${PSPDEV}/psp/sdk/include
)
target_link_directories(pspsdk
INTERFACE
${PSPDEV}/lib
${PSPDEV}/psp/lib
${PSPDEV}/psp/sdk/lib
)
target_link_libraries(pspsdk INTERFACE
pspdebug
pspdisplay
pspge
pspctrl
)
endif()
endif()

View File

@@ -0,0 +1,20 @@
# Copyright (c) 2025 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
include(FetchContent)
FetchContent_Declare(
raylib
URL https://github.com/raysan5/raylib/archive/refs/tags/5.5.tar.gz
URL_HASH MD5=61638c4c2c097fbca1d6a71e4da36c16
)
FetchContent_GetProperties(raylib)
FetchContent_MakeAvailable(raylib)
# Define expected target if not already defined
if(NOT TARGET raylib)
set(raylib_FOUND FALSE CACHE INTERNAL "Whether raylib was found")
else()
set(raylib_FOUND TRUE CACHE INTERNAL "Whether raylib was found")
endif()