|
| 1 | +cmake_minimum_required(VERSION 3.13) |
| 2 | + |
| 3 | +# Set the toolchain file before project() |
| 4 | +if(NOT CMAKE_TOOLCHAIN_FILE) |
| 5 | + if(DEFINED ENV{PS2DEV}) |
| 6 | + set(CMAKE_TOOLCHAIN_FILE "$ENV{PS2DEV}/share/ps2dev.cmake" CACHE FILEPATH "Toolchain file") |
| 7 | + else() |
| 8 | + message(FATAL_ERROR "PS2DEV environment variable is not set. Please set it to your PS2DEV installation path.") |
| 9 | + endif() |
| 10 | +endif() |
| 11 | + |
| 12 | +project(ps2stuff VERSION 1.0.0 LANGUAGES CXX C) |
| 13 | + |
| 14 | +# Options |
| 15 | +option(BUILD_TESTS "Build test projects" OFF) |
| 16 | +option(DEBUG "Enable debug build" OFF) |
| 17 | + |
| 18 | +# Check if PS2SDK is set (should be done by toolchain file) |
| 19 | +if(NOT DEFINED PS2SDK) |
| 20 | + message(FATAL_ERROR "PS2SDK is not defined. Make sure the toolchain file is loaded correctly.") |
| 21 | +endif() |
| 22 | + |
| 23 | +# Set output library name |
| 24 | +set(EE_LIB "libps2stuff.a") |
| 25 | + |
| 26 | +# Include directories |
| 27 | +include_directories( |
| 28 | + ${CMAKE_SOURCE_DIR}/include |
| 29 | + ${PS2SDK}/ports/include |
| 30 | +) |
| 31 | + |
| 32 | +# Link directories |
| 33 | +link_directories( |
| 34 | + ${PS2SDK}/ports/lib |
| 35 | +) |
| 36 | + |
| 37 | +# Compiler flags |
| 38 | +if(DEBUG) |
| 39 | + add_compile_definitions(_DEBUG) |
| 40 | +endif() |
| 41 | + |
| 42 | +# Warning flags (matching Makefile) |
| 43 | +set(WARNING_FLAGS |
| 44 | + -Wno-strict-aliasing |
| 45 | + -Wno-conversion-null |
| 46 | +) |
| 47 | + |
| 48 | +# VU0 code is broken so disable for now |
| 49 | +add_compile_definitions( |
| 50 | + NO_VU0_VECTORS |
| 51 | + NO_ASM |
| 52 | +) |
| 53 | + |
| 54 | +add_compile_options(${WARNING_FLAGS}) |
| 55 | + |
| 56 | +# ============================================================================ |
| 57 | +# Source files |
| 58 | +# ============================================================================ |
| 59 | +set(PS2STUFF_SOURCES |
| 60 | + src/core.cpp |
| 61 | + src/cpu_matrix.cpp |
| 62 | + src/displayenv.cpp |
| 63 | + src/drawenv.cpp |
| 64 | + src/eetimer.cpp |
| 65 | + src/gs.cpp |
| 66 | + src/gsmem.cpp |
| 67 | + src/imagepackets.cpp |
| 68 | + src/math.cpp |
| 69 | + src/matrix.cpp |
| 70 | + src/packet.cpp |
| 71 | + src/perfmon.cpp |
| 72 | + src/ps2stuff.cpp |
| 73 | + src/sprite.cpp |
| 74 | + src/texture.cpp |
| 75 | + src/timer.cpp |
| 76 | + src/utils.cpp |
| 77 | +) |
| 78 | + |
| 79 | +# ============================================================================ |
| 80 | +# Build the library |
| 81 | +# ============================================================================ |
| 82 | +add_library(ps2stuff STATIC ${PS2STUFF_SOURCES}) |
| 83 | + |
| 84 | +set_target_properties(ps2stuff PROPERTIES |
| 85 | + OUTPUT_NAME "ps2stuff" |
| 86 | + ARCHIVE_OUTPUT_NAME "ps2stuff" |
| 87 | +) |
| 88 | + |
| 89 | +target_include_directories(ps2stuff PUBLIC |
| 90 | + $<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/include> |
| 91 | + $<INSTALL_INTERFACE:include> |
| 92 | +) |
| 93 | + |
| 94 | +# ============================================================================ |
| 95 | +# Install targets |
| 96 | +# ============================================================================ |
| 97 | +install( |
| 98 | + FILES ${CMAKE_CURRENT_BINARY_DIR}/${EE_LIB} |
| 99 | + DESTINATION "${PS2SDK}/ports/lib" |
| 100 | +) |
| 101 | + |
| 102 | +install( |
| 103 | + DIRECTORY ${CMAKE_SOURCE_DIR}/include/ps2s |
| 104 | + DESTINATION "${PS2SDK}/ports/include" |
| 105 | + FILES_MATCHING PATTERN "*.h" |
| 106 | +) |
| 107 | + |
| 108 | +# ============================================================================ |
| 109 | +# Include tests if enabled |
| 110 | +# ============================================================================ |
| 111 | +if(BUILD_TESTS) |
| 112 | + add_subdirectory(tests) |
| 113 | +endif() |
| 114 | + |
| 115 | +# ============================================================================ |
| 116 | +# Print configuration summary |
| 117 | +# ============================================================================ |
| 118 | +message(STATUS "") |
| 119 | +message(STATUS "ps2stuff configuration:") |
| 120 | +message(STATUS " Version: ${PROJECT_VERSION}") |
| 121 | +message(STATUS " Debug build: ${DEBUG}") |
| 122 | +message(STATUS " Build tests: ${BUILD_TESTS}") |
| 123 | +message(STATUS " Output library: ${EE_LIB}") |
| 124 | +message(STATUS " Install prefix: ${PS2SDK}/ports") |
| 125 | +message(STATUS " VU0 vectors: DISABLED") |
| 126 | +message(STATUS " ASM optimizations: DISABLED") |
| 127 | +message(STATUS "") |
0 commit comments