summaryrefslogtreecommitdiff
path: root/libpcsxcore/CMakeLists.txt
blob: 0be1e4acfc1a460f9be7c51f8e4d600de1e9c8cd (plain) (blame)
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
message(STATUS "* Configuring Core")

set(DYNAREC "auto" CACHE STRING "Build dynarec for arch.")
set_property(CACHE DYNAREC PROPERTY STRINGS auto x86_64 x86 ppc no)

option(ENABLE_CCDDA "Enables compressed CDDA support." OFF)
option(USE_LIBARCHIVE "Enables compressed data-tracks support." OFF)

include_directories(../dynstr/dynstr/include)

if (ENABLE_CCDDA)
  find_package(FFMPEG REQUIRED)
  include_directories(${FFMPEG_INCLUDE_DIRS})
  add_definitions(-DENABLE_CCDDA)
endif()

if (USE_LIBARCHIVE)
  find_package(LibArchive REQUIRED)
  include_directories(${LibArchive_INCLUDE_DIRS})
  add_definitions(-DHAVE_LIBARCHIVE)
endif()

# Architecture detection and arch specific settings
message(STATUS "Building PCSXr on arch " ${CMAKE_SYSTEM_PROCESSOR})
include(TargetArch)
target_architecture(PCSXR_TARGET_ARCH)
message(STATUS "Targeting arch " ${PCSXR_TARGET_ARCH})
if (${PCSXR_TARGET_ARCH} MATCHES "ppc")
    set(_ARCH_PPC 1)
elseif(${PCSXR_TARGET_ARCH} MATCHES "i386")
    set(_ARCH_32 1)
elseif(${PCSXR_TARGET_ARCH} MATCHES "x86_64")
    set(_ARCH_64 1)
else()
    message(STATUS "Unsupported arch. Will not build dynarec")
    add_definitions(-DNOPSXREC)
endif()
set(CMAKE_POSITION_INDEPENDENT_CODE OFF) #for x86

if (${DYNAREC} STREQUAL "auto")
    if (_ARCH_PPC)
#if anyone ever fixes ppc dynarec
#        set(DYNAREC_PPC 1)
#        message(STATUS "Autodetected PPC dynarec.")
    message(STATUS "Autodetected PPC dynarec is broken, sorry.")
    add_definitions(-DNOPSXREC)
    elseif(_ARCH_64)
        set(DYNAREC_64 1)
        message(STATUS "Autodetected x86_64 dynarec.")
    elseif(_ARCH_32)
        set(DYNAREC_32 1)
        message(STATUS "Autodetected x86 dynarec.")
    endif()
elseif (${DYNAREC} STREQUAL "ppc")
#if anyone ever fixes ppc dynarec
#    set(DYNAREC_PPC 1)
#    message(STATUS "User selected PPC dynarec")
    message(STATUS "User selected PPC dynarec is broken, sorry.")
    add_definitions(-DNOPSXREC)
elseif (${DYNAREC} STREQUAL "x86_64")
    set(DYNAREC_64 1)
    message(STATUS "User selected x86_64 dynarec.")
elseif (${DYNAREC} STREQUAL "x86")
    set(DYNAREC_32 1)
    message(STATUS "User selected x86 dynarec.")
elseif (${DYNAREC} STREQUAL "no")
    message(STATUS "User selected to not build dynarec.")
    add_definitions(-DNOPSXREC)
endif()


set(SRCS  psxbios.c
          cdrom.c
          psxcounters.c
          psxdma.c
          disr3000a.c
          gpu.c
          spu.c
          sio.c
          psxhw.c
          mdec.c
          psxmem.c
          misc.c
          plugins.c
          decode_xa.c
          r3000a.c
          psxinterpreter.c
          gte.c
          psxhle.c
          debug.c
          psxcommon.c
          cdriso.c
          cheat.c
          socket.c
          ppf.c
          pgxp_cpu.c
          pgxp_debug.c
          pgxp_gte.c
          pgxp_mem.c
          pgxp_value.c
)

set(LIBS "-lm")

if(DYNAREC_64)
    file(GLOB_RECURSE DYNAREC_SRC  ix86_64/*.c)
elseif(DYNAREC_32)
    file(GLOB_RECURSE DYNAREC_SRC  ix86/*.c)
elseif(DYNAREC_PPC)
    enable_language(ASM-ATT)
    SET(CMAKE_ASM-ATT_SOURCE_FILE_EXTENSIONS nasm;nas;asm;s)
    file(GLOB_RECURSE DYNAREC_SRC  ppc/*.c)
    set(DYNAREC_SRC ${DYNAREC_SRC} ppc/pasm.s)
endif()

set(SRCS ${SRCS} ${DYNAREC_SRC})

add_library(pcsxcore STATIC ${SRCS})
target_link_libraries(pcsxcore dynstr gdbstub ${FFMPEG_LIBRARIES} ${LibArchive_LIBRARIES} ${LIBS})