|
| 1 | +set(triple "x86_64-scei-ps4") |
| 2 | + |
| 3 | +set(CMAKE_C_COMPILER "clang") |
| 4 | +set(CMAKE_CXX_COMPILER "clang++") |
| 5 | +set(CMAKE_C_COMPILER_AR "ar") |
| 6 | +set(CMAKE_LINKER "clang") |
| 7 | +set(CMAKE_ASM_COMPILER "clang") |
| 8 | +set(CMAKE_FIND_ROOT_PATH "$ENV{PS4SDK}") |
| 9 | +set(CMAKE_SYSROOT "$ENV{PS4SDK}/") |
| 10 | + |
| 11 | +# compiler has to be 'forced' to skip cxx compiler test |
| 12 | +# which fails due the crt0.s not being compatible with CXX |
| 13 | +set(CMAKE_CXX_COMPILER_FORCED on) |
| 14 | +set(CMAKE_C_COMPILER_TARGET "${triple}") |
| 15 | +set(CMAKE_CXX_COMPILER_TARGET "${triple}") |
| 16 | + |
| 17 | +# only search for libraries and includes in the PS4SDK directory |
| 18 | +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) |
| 19 | +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) |
| 20 | +set(CMAKE_SKIP_RPATH true) |
| 21 | + |
| 22 | +set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" CACHE STRING "") |
| 23 | +set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" CACHE STRING "") |
| 24 | +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -Wall -pedantic -m64 -mcmodel=large -nostdlib -nostdinc -ffreestanding -fPIE -fno-builtin -fno-stack-protector -D__PS4__" CACHE STRING "") |
| 25 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -m64 -mcmodel=large -nostdlib -nostdinc -ffreestanding -fPIE -fno-stack-protector -D__PS4__" CACHE STRING "") |
| 26 | +set(CMAKE_EXE_LINKER_FLAGS "-O3 -Wall -m64 -pie -nostartfiles -nostdlib $ENV{PS4SDK}/crt0.s " CACHE STRING "") |
| 27 | + |
| 28 | +link_directories("$ENV{PS4SDK}/lib") |
| 29 | + |
| 30 | +set(TOOLCHAIN_PS4SDK_LIBS) |
| 31 | +LIST(APPEND TOOLCHAIN_PS4SDK_LIBS Ps4_extension_kernel_execute_dynlib_prepare_dlclose Ps4_extension_kernel_call_standard) |
| 32 | +LIST(APPEND TOOLCHAIN_PS4SDK_LIBS Ps4_common_kernel Ps4_common_user Ps4_common_generic) |
| 33 | +LIST(APPEND TOOLCHAIN_PS4SDK_LIBS Ps4_common_generic) |
| 34 | +LIST(APPEND TOOLCHAIN_PS4SDK_LIBS Ps4LibCInternalAdaptive_stub Ps4LibKernelAdaptive_stub) |
| 35 | +LIST(APPEND TOOLCHAIN_PS4SDK_LIBS SceLibcInternal_stub kernel_stub) |
| 36 | +LIST(APPEND TOOLCHAIN_PS4SDK_LIBS ps4Kernel_stub) |
| 37 | +LIST(APPEND TOOLCHAIN_PS4SDK_LIBS Ps4_base_stub_resolve_minimal) |
| 38 | +LIST(APPEND TOOLCHAIN_PS4SDK_LIBS Ps4_base_kernel_dlsym_standard Ps4_base_kernel_seek_elf_address_standard) |
| 39 | +LIST(APPEND TOOLCHAIN_PS4SDK_LIBS Ps4_base_assembler_register_parameter_standard) |
| 40 | +LIST(APPEND TOOLCHAIN_PS4SDK_LIBS Ps4_base_assembler_system_call_rop_0x93a4FFFF8) |
| 41 | + |
| 42 | + |
| 43 | +# this is a work around to avoid duplicate library warning, |
| 44 | +# as the toolchain file can be proccessed multiple times |
| 45 | +# people over cmake IRC suggest I move this to a find module |
| 46 | +# instead of messing with policies as they might be removed in time AKA TODO |
| 47 | +cmake_policy(SET CMP0002 OLD) |
| 48 | + |
| 49 | +add_library(PS4LIBS INTERFACE) |
| 50 | +add_library(PS4::LIBS ALIAS PS4LIBS) |
| 51 | +target_link_libraries(PS4LIBS INTERFACE ${TOOLCHAIN_PS4SDK_LIBS}) |
| 52 | + |
| 53 | +add_library(PS4HEADERS INTERFACE) |
| 54 | +add_library(PS4::HEADERS ALIAS PS4HEADERS) |
| 55 | +target_include_directories(PS4HEADERS INTERFACE "$ENV{PS4SDK}/include/c++/v1/" "$ENV{PS4SDK}/include/" "$ENV{PS4SDK}/include/sce/" "$ENV{PS4SDK}/include/ps4/") |
| 56 | +include_directories("$ENV{PS4SDK}/include/c++/v1/" "$ENV{PS4SDK}/include/" "$ENV{PS4SDK}/include/sce/" "$ENV{PS4SDK}/include/ps4/") |
| 57 | + |
| 58 | +cmake_policy(SET CMP0002 NEW) |
0 commit comments