-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
215 lines (190 loc) · 6.43 KB
/
CMakeLists.txt
File metadata and controls
215 lines (190 loc) · 6.43 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
####
# USBSID-Player aims to be a command line SID file player that is also
# suited for embedding where both implementations target use
# with USBSID-Pico. USBSID-Pico is a RPi Pico/PicoW (RP2040) &
# Pico2/Pico2W (RP2350) based board for interfacing one or two
# MOS SID chips and/or hardware SID emulators over (WEB)USB with
# your computer, phone or ASID supporting player
#
# CMakeLists.txt
# This file is part of USBSID-Pico (https://github.com/LouDnl/USBSID-Player)
# File author: LouD
#
# Copyright (c) 2025 ~ 2026 LouD
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
####
### Cmake minimum version
cmake_minimum_required(VERSION 3.17)
### Cmake compiler standard versions
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
### Project magic sprinkles
set(PROJECT_NAME usbsid)
set(EXECUTABLE ${PROJECT_NAME} CACHE STRING "EXECUTABLE")
# enable or disable desktop build
set(DESKTOP 1 CACHE STRING "DESKTOP")
# enable or disable embedded build
set(EMBEDDED 0 CACHE STRING "EMBEDDED")
# enable or disable the (re)build of psiddrv.h
set(BUILDPSIDDRV 0 CACHE STRING "BUILDPSIDDRV")
# enable or disable radare2 debugging support
set(RADARE2 1 CACHE STRING "RADARE2")
if(${DESKTOP} EQUAL 1 AND ${EMBEDDED} EQUAL 1)
message(FATAL_ERROR "DESKTOP and EMBEDDED are mutually exclusive! Exiting...")
endif()
if(${DESKTOP} EQUAL 0 AND ${EMBEDDED} EQUAL 0)
message(FATAL_ERROR "Please set either DESKTOP or EMBEDDED to 1! Exiting...")
endif()
### Compiler flags and options
set(COMPILE_OPTS PRIVATE
-g3
-Og
# -Wall
# -Wunused
# -Werror
-fno-omit-frame-pointer
-Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
-Wno-unused-function # extra check to verify no unused lingering code is present
-Wno-maybe-uninitialized
-save-temps
-fverbose-asm
)
if (DESKTOP)
endif (DESKTOP)
set(COMPILE_OPTS ${COMPILE_OPTS}
-DDESKTOP=${DESKTOP}
)
if (EMBEDDED)
set(COMPILE_OPTS ${COMPILE_OPTS}
-DEMBEDDED=${EMBEDDED}
)
add_compile_definitions(ONBOARD_SIDPLAYER=1)
endif (EMBEDDED)
# Run the project command
project(${PROJECT_NAME} C CXX ASM)
if (DESKTOP)
find_package(PkgConfig REQUIRED)
pkg_check_modules(libusb REQUIRED IMPORTED_TARGET libusb-1.0)
set(TARGET_LL PkgConfig::libusb)
### Linux ONLY (Exclude macOS/Darwin)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
pkg_check_modules(udev REQUIRED IMPORTED_TARGET libudev)
list(APPEND TARGET_LL PkgConfig::udev)
endif ()
### macOS ONLY
if (APPLE)
# libusb on macOS often requires these native frameworks
find_library(IOKIT_FRAMEWORK IOKit)
find_library(COREFOUNDATION_FRAMEWORK CoreFoundation)
list(APPEND TARGET_LL ${IOKIT_FRAMEWORK} ${COREFOUNDATION_FRAMEWORK})
endif ()
if (WIN32)
# PkgConfig::libusb is already in TARGET_LL
endif ()
endif (DESKTOP)
### Source files to compile
set(SOURCEFILES
${CMAKE_CURRENT_LIST_DIR}/src/usplayer.cpp
${CMAKE_CURRENT_LIST_DIR}/src/vsidpsid.cpp
${CMAKE_CURRENT_LIST_DIR}/src/microsid.cpp
${CMAKE_CURRENT_LIST_DIR}/src/prgrunner.cpp
${CMAKE_CURRENT_LIST_DIR}/src/emulation.cpp
${CMAKE_CURRENT_LIST_DIR}/src/c64/mos6510_cpu.cpp
${CMAKE_CURRENT_LIST_DIR}/src/c64/mos6526_cia.cpp
${CMAKE_CURRENT_LIST_DIR}/src/c64/mos6560_6561_vic.cpp
${CMAKE_CURRENT_LIST_DIR}/src/c64/mos6581_8580_sid.cpp
${CMAKE_CURRENT_LIST_DIR}/src/c64/mos906114_pla.cpp
${CMAKE_CURRENT_LIST_DIR}/src/c64/mmu.cpp
${CMAKE_CURRENT_LIST_DIR}/src/util/timer.cpp
${CMAKE_CURRENT_LIST_DIR}/src/util/wrappers.cpp
${CMAKE_CURRENT_LIST_DIR}/src/psid/sidfile.cpp
${CMAKE_CURRENT_LIST_DIR}/src/psiddrv/psid.cpp
${CMAKE_CURRENT_LIST_DIR}/src/psiddrv/reloc65.c
#${WIN32_SRC}
)
### Header folders to include
set(TARGET_INCLUDE_DIRS PRIVATE
.
src
${CMAKE_CURRENT_LIST_DIR}/src
${CMAKE_CURRENT_LIST_DIR}/src/c64
${CMAKE_CURRENT_LIST_DIR}/src/util
${CMAKE_CURRENT_LIST_DIR}/src/roms
${CMAKE_CURRENT_LIST_DIR}/src/psid
${CMAKE_CURRENT_LIST_DIR}/src/psiddrv
)
if (DESKTOP)
set(TARGET_INCLUDE_DIRS ${TARGET_INCLUDE_DIRS}
# ${WIN32_INC}
/usr/local/lib
/usr/local/include
/usr/lib
/usr/include
)
endif (DESKTOP)
## Workaround for github actions failing
## Needs download and compilation of XA for this part to work
if (BUILDPSIDDRV)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_custom_command(
# OUTPUT psiddrv.h psidextdrv.h
OUTPUT psiddrv.h
COMMAND $(MAKE) all
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/psiddrv/
)
add_custom_target(
RSIDDriver ALL
# DEPENDS psiddrv.h psidextdrv.h
DEPENDS psiddrv.h
)
endif ()
endif (BUILDPSIDDRV)
if (DESKTOP)
set(SOURCEFILES
${SOURCEFILES}
${CMAKE_CURRENT_LIST_DIR}/lib/driver/src/USBSID.cpp
# ${CMAKE_CURRENT_LIST_DIR}/src/midi/RtMidi.cpp
# ${CMAKE_CURRENT_LIST_DIR}/src/midi/asid.cpp
)
set(TARGET_INCLUDE_DIRS
${TARGET_INCLUDE_DIRS}
${CMAKE_CURRENT_LIST_DIR}/lib/driver/src
# ${CMAKE_CURRENT_LIST_DIR}/lib/midi
)
endif (DESKTOP)
### Compile time
add_executable(${EXECUTABLE} ${SOURCEFILES})
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_definitions(${EXECUTABLE} PRIVATE UNIX_COMPILE)
# target_compile_definitions(${PROJECT_NAME} PRIVATE __LINUX_ALSA__)
# target_compile_definitions(${PROJECT_NAME} PRIVATE __RTMIDI_DEBUG__)
endif ()
# if (WIN32)
# target_compile_definitions(${PROJECT_NAME} PRIVATE WINDOWS_COMPILE)
# target_compile_definitions(${PROJECT_NAME} PRIVATE TERMIWIN_DONOTREDEFINE=1)
# endif (WIN32)
target_include_directories(${EXECUTABLE} ${TARGET_INCLUDE_DIRS})
target_link_libraries(${EXECUTABLE} ${TARGET_LL})
target_sources(${EXECUTABLE} PUBLIC ${SOURCEFILES})
target_compile_options(${EXECUTABLE} ${COMPILE_OPTS})
### Copy build output to main directory
add_custom_command(TARGET
${EXECUTABLE}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${EXECUTABLE}> ${CMAKE_CURRENT_LIST_DIR})
### Remove build output from build directory
add_custom_command(TARGET
${EXECUTABLE}
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E rm $<TARGET_FILE:${EXECUTABLE}>)