# libpsn00b interface targets # (C) 2021 spicyjpeg - MPL licensed # This script creates several "virtual" targets (psn00bsdk_*) that set include # directories and compiler flags when a target is linked against them. These # all end up in the autogenerated libpsn00b setup script after installation, # so this file is only included when building libpsn00b. # The following targets are currently defined: # - psn00bsdk_common # - psn00bsdk_object_lib (same as psn00bsdk_common) # - psn00bsdk_static_exe # - psn00bsdk_dynamic_exe # - psn00bsdk_static_lib # - psn00bsdk_shared_lib # - psn00bsdk_module_lib (same as psn00bsdk_shared_lib) include(GNUInstallDirs) set(PSN00BSDK_VIRTUAL_TARGETS "") macro(_add_interface_target name) add_library(${name} INTERFACE) list(APPEND PSN00BSDK_VIRTUAL_TARGETS ${name}) target_compile_options( ${name} INTERFACE ${_aflags} $<$:${_cflags}> $<$:${_cxxflags}> ) target_link_options (${name} INTERFACE ${_ldflags}) target_link_libraries(${name} INTERFACE ${ARGN}) endmacro() macro(_add_alias_target name) #add_library(${name} ALIAS ${ARGN}) add_library(${name} INTERFACE) list(APPEND PSN00BSDK_VIRTUAL_TARGETS ${name}) target_link_libraries(${name} INTERFACE ${ARGN}) endmacro() # Options common to all target types: # - Define PLAYSTATION=1 and set include directories # - Optimize for MIPS R3000 # - Inject zero checks into division operations (will throw breaks) # - All standard libraries (including libgcc) disabled # - Put all symbols into separate sections when building # - C++ features that require runtime support disabled # - Unused section stripping enabled set(_aflags -msoft-float -march=r3000 -mtune=r3000 -mabi=32) set(_cflags -mdivide-breaks -O2 -ffreestanding -fno-builtin -nostdlib -fdata-sections -ffunction-sections -fsigned-char -fno-strict-overflow -fdiagnostics-color=always) set(_cxxflags -fno-exceptions -fno-rtti -fno-unwind-tables -fno-threadsafe-statics -fno-use-cxa-atexit) set(_ldflags -nostdlib -Wl,-gc-sections) _add_interface_target(psn00bsdk_common) _add_alias_target (psn00bsdk_object_lib psn00bsdk_common) target_compile_definitions( psn00bsdk_common INTERFACE PLAYSTATION=1 $<$:DEBUG=1> ) # Options for executables without support for dynamic linking: # - Position-independent code disabled # - GP-relative addressing enabled only for local symbols # - ABI-compatible calls disabled (incompatible with GP-relative addr) set(_aflags -G8) set(_cflags -mno-abicalls -mgpopt -mno-extern-sdata) set(_cxxflags) set(_ldflags -G8 -static) _add_interface_target(psn00bsdk_static_exe psn00bsdk_common ${PSN00BSDK_LIBRARIES}) # Options for executables with support for dynamic linking: # - Position-independent code disabled # - GP-relative addressing disabled # - ABI-compatible calls disabled (must be performed manually) set(_aflags -G0) set(_cflags -mno-abicalls -mno-gpopt) set(_cxxflags) set(_ldflags -G0 -static) _add_interface_target(psn00bsdk_dynamic_exe psn00bsdk_common ${PSN00BSDK_LIBRARIES}) # Options for static libraries: # - GP-relative addressing disabled # - ABI-compatible calls disabled # - Local stripping enabled set(_aflags -G0 -Wa,--strip-local-absolute) set(_cflags -mno-abicalls -mno-gpopt) set(_cxxflags) set(_ldflags) _add_interface_target(psn00bsdk_static_lib psn00bsdk_common) # Options for dynamically-loaded libraries: # - Position-independent code enabled # - GP-relative addressing disabled (incompatible with ABI calls) # - ABI-compatible calls enabled set(_aflags -G0) set(_cflags -mabicalls -mshared -mno-gpopt -fPIC) set(_cxxflags) set(_ldflags -G0 -shared) _add_interface_target(psn00bsdk_shared_lib psn00bsdk_common) _add_alias_target (psn00bsdk_module_lib psn00bsdk_shared_lib)