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