cmake: fix ps2toolchain

This commit is contained in:
Anonymous Maarten 2021-07-09 19:35:32 +02:00
parent fe07db1b21
commit ff4b2c2b48
1 changed files with 32 additions and 21 deletions

View File

@ -3,11 +3,9 @@ cmake_minimum_required(VERSION 3.7)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}") list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
set(CMAKE_SYSTEM_NAME "PlayStation2") set(CMAKE_SYSTEM_NAME "PlayStation2")
set(CMAKE_SYSTEM_PROCESSOR "mipsel") set(CMAKE_SYSTEM_PROCESSOR "mips64r5900el")
set(CMAKE_SYSTEM_VERSION 1) set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON) set(CMAKE_NO_SYSTEM_FROM_IMPORTED ON)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
@ -18,37 +16,47 @@ endif()
if(NOT DEFINED ENV{PS2SDK}) if(NOT DEFINED ENV{PS2SDK})
message(FATAL_ERROR "Need environment variable PS2SDK set") message(FATAL_ERROR "Need environment variable PS2SDK set")
endif() endif()
if(NOT DEFINED ENV{GSKIT})
message(FATAL_ERROR "Need environment variable PS2SDK set")
endif()
set(PS2DEV "$ENV{PS2DEV}") set(PS2DEV "$ENV{PS2DEV}")
set(PS2SDK "$ENV{PS2SDK}") set(PS2SDK "$ENV{PS2SDK}")
set(GSKIT "$ENV{GSKIT}")
if(NOT IS_DIRECTORY "${PS2DEV}") if(NOT IS_DIRECTORY "${PS2DEV}")
message(FATAL_ERROR "PS2DEV must contain a folder path (${PS2DEV})") message(FATAL_ERROR "PS2DEV must be a folder path (${PS2DEV})")
endif() endif()
if(NOT IS_DIRECTORY "${PS2SDK}") if(NOT IS_DIRECTORY "${PS2SDK}")
message(FATAL_ERROR "PS2SDK must contain a folder path (${PS2SDK})") message(FATAL_ERROR "PS2SDK must be a folder path (${PS2SDK})")
endif()
if(NOT IS_DIRECTORY "${GSKIT}")
message(FATAL_ERROR "GSKIT must be a folder path (${GSKIT})")
endif() endif()
set(CMAKE_DSM_SOURCE_FILE_EXTENSIONS "dsm") set(CMAKE_DSM_SOURCE_FILE_EXTENSIONS "dsm")
set(CMAKE_C_COMPILER "${PS2DEV}/ee/bin/ee-gcc") set(CMAKE_C_COMPILER "${PS2DEV}/ee/bin/mips64r5900el-ps2-elf-gcc" CACHE FILEPATH "C compiler")
set(CMAKE_CXX_COMPILER "${PS2DEV}/ee/bin/ee-g++") set(CMAKE_CXX_COMPILER "${PS2DEV}/ee/bin/mips64r5900el-ps2-elf-g++" CACHE FILEPATH "CXX compiler")
set(CMAKE_ASM_COMPILER "${PS2DEV}/ee/bin/ee-g++") set(CMAKE_ASM_COMPILER "${PS2DEV}/ee/bin/mips64r5900el-ps2-elf-g++" CACHE FILEPATH "ASM assembler")
set(CMAKE_DSM_COMPILER "${PS2DEV}/dvp/bin/dvp-as") set(CMAKE_DSM_COMPILER "${PS2DEV}/dvp/bin/dvp-as" CACHE FILEPATH "DSM assembler")
set(CMAKE_AR "${PS2DEV}/ee/bin/ee-ar" CACHE FILEPATH "archiver") set(CMAKE_AR "${PS2DEV}/ee/bin/mips64r5900el-ps2-elf-ar" CACHE FILEPATH "archiver")
set(CMAKE_LINKER "${PS2DEV}/ee/bin/ee-ld") set(CMAKE_LINKER "${PS2DEV}/ee/bin/mips64r5900el-ps2-elf-ld" CACHE FILEPATH "Linker")
set(CMAKE_RANLIB "${PS2DEV}/ee/bin/ee-ranlib" CACHE FILEPATH "ranlib") set(CMAKE_RANLIB "${PS2DEV}/ee/bin/mips64r5900el-ps2-elf-ranlib" CACHE FILEPATH "ranlib")
set(CMAKE_STRIP "${PS2DEV}/ee/bin/ee-strip" CACHE FILEPATH "strip") set(CMAKE_STRIP "${PS2DEV}/ee/bin/mips64r5900el-ps2-elf-strip" CACHE FILEPATH "strip")
set(CMAKE_ASM_FLAGS_INIT "-G0 -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\"") set(CMAKE_ASM_FLAGS_INIT "-G0 -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\" -D_EE")
set(CMAKE_C_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\"") set(CMAKE_C_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\" -D_EE")
set(CMAKE_CXX_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\"") set(CMAKE_CXX_FLAGS_INIT "-G0 -fno-common -I\"${PS2SDK}/ee/include\" -I\"${PS2SDK}/common/include\" -D_EE")
set(CMAKE_EXE_LINKER_FLAGS_INIT "-G0 -L\"${PS2SDK}/ee/lib\" -Wl,-r -Wl,-d") set(CMAKE_EXE_LINKER_FLAGS_INIT "-G0 -L\"${PS2SDK}/ee/lib\" -Wl,-r -Wl,-d")
set(CMAKE_FIND_ROOT_PATH "${PS2DEV}/ee" "${PS2SDK}/ee") set(CMAKE_FIND_ROOT_PATH "${PS2DEV}/ee" "${PS2SDK}/ee" "${GSKIT}")
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_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(PS2 1) set(PS2 1)
set(EE 1) set(EE 1)
@ -58,7 +66,10 @@ set(CMAKE_EXECUTABLE_SUFFIX ".elf")
function(add_erl_executable TARGET) function(add_erl_executable TARGET)
cmake_parse_arguments("AEE" "" "OUTPUT_VAR" "" ${ARGN}) cmake_parse_arguments("AEE" "" "OUTPUT_VAR" "" ${ARGN})
get_target_property(output_dir ${TARGET} RUNTIME_OUTPUT_DIRECTORY) get_target_property(output_dir "${TARGET}" RUNTIME_OUTPUT_DIRECTORY)
if(NOT output_dir)
set(output_dir ${CMAKE_CURRENT_BINARY_DIR})
endif()
get_target_property(output_name ${TARGET} OUTPUT_NAME) get_target_property(output_name ${TARGET} OUTPUT_NAME)
if(NOT output_name) if(NOT output_name)