-
Notifications
You must be signed in to change notification settings - Fork 21
/
CMakeLists.txt
215 lines (193 loc) · 6.52 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.28)
# project / version
set(REDUMPER_PROJECT_NAME "redumper" CACHE STRING "Project name")
string(TIMESTAMP REDUMPER_VERSION_MAJOR "%Y")
string(TIMESTAMP REDUMPER_VERSION_MINOR "%m")
string(TIMESTAMP REDUMPER_VERSION_PATCH "%d")
set(REDUMPER_VERSION_BUILD "LOCAL" CACHE STRING "Version patch")
project(${REDUMPER_PROJECT_NAME} VERSION "${REDUMPER_VERSION_MAJOR}.${REDUMPER_VERSION_MINOR}.${REDUMPER_VERSION_PATCH}")
set(REDUMPER_CLANG_LINK_OPTIONS "-static" CACHE STRING "Extra LLVM/Clang linker options")
# build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the build type" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
endif()
set(CMAKE_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE} CACHE INTERNAL "Active configuration" FORCE)
# packaging
set(CPACK_GENERATOR "ZIP")
# add build number to a package file name if it was provided
if(NOT REDUMPER_VERSION_BUILD STREQUAL "LOCAL")
set(system_name__ ${CMAKE_SYSTEM_NAME})
if(system_name__ STREQUAL "Windows")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(system_name__ "win64")
else()
set(system_name__ "win32")
endif()
endif()
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}_build${REDUMPER_VERSION_BUILD}-${system_name__}")
endif()
include(CPack)
# platform
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(REDUMPER_TARGET_LINUX 1)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(REDUMPER_TARGET_WINDOWS 1)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(REDUMPER_TARGET_MACOSX 1)
else()
message(FATAL_ERROR "Unknown target platform")
endif()
# C/C++
set(CMAKE_CXX_STANDARD 20)
add_definitions(-DREDUMPER_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
-DREDUMPER_VERSION_MINOR=${PROJECT_VERSION_MINOR}
-DREDUMPER_VERSION_PATCH=${PROJECT_VERSION_PATCH}
-DREDUMPER_VERSION_BUILD=${REDUMPER_VERSION_BUILD})
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-stdlib=libc++>)
add_link_options(-stdlib=libc++ ${REDUMPER_CLANG_LINK_OPTIONS})
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-Wall -Wextra -Werror)
# remove after https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99426 is fixed
add_compile_options(--param=ggc-min-expand=10000)
endif()
if(MSVC)
# disable modules inlining
# wait until Microsoft actually fixes this and remove the option, more information:
# https://developercommunity.visualstudio.com/t/VS-1750-Compiler-is-Broken/10288409
# https://developercommunity.visualstudio.com/t/Modules-ICE-when-using-cout-inside-of-/10299789
# https://developercommunity.visualstudio.com/t/C-Modules:-Internal-Compiler-Error-on-/10377473
add_compile_options(/dxifcInlineFunctions-)
# build MT configuration by default
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# multithreaded build
add_compile_options(/MP)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DNOMINMAX -D_NTSCSI_USER_MODE_)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# flatten source lists
file(GLOB_RECURSE files LIST_DIRECTORIES false RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *)
foreach(i IN LISTS files)
get_filename_component(source_path "${i}" PATH)
string(REPLACE "/" "\\" source_path "${source_path}")
source_group("${source_path}" FILES ${i})
endforeach()
endif()
# generated source file
set(DRIVEOFFSETS_FN "${CMAKE_CURRENT_BINARY_DIR}/driveoffsets.inc")
add_executable(generate_offsets generate_offsets.cc)
add_custom_command(
OUTPUT ${DRIVEOFFSETS_FN}
COMMAND generate_offsets "${CMAKE_CURRENT_SOURCE_DIR}/driveoffsets.txt"
DEPENDS generate_offsets "driveoffsets.txt"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_executable(redumper)
target_sources(redumper
PUBLIC
"dvd/css/css_tables.cc"
"main.cc"
"driveoffsets.txt"
"systems/system.hh"
"utils/throw_line.hh"
"redumper.manifest"
${DRIVEOFFSETS_FN}
PRIVATE FILE_SET cxx_modules TYPE CXX_MODULES FILES
"analyzers/analyzer.ixx"
"analyzers/silence.ixx"
"analyzers/sync.ixx"
"cd/cd.ixx"
"cd/cd_dump.ixx"
"cd/cd_dump_new.ixx"
"cd/cdrom.ixx"
"cd/ecc.ixx"
"cd/edc.ixx"
"cd/fix_msf.ixx"
"cd/offset_manager.ixx"
"cd/protection.ixx"
"cd/scrambler.ixx"
"cd/split.ixx"
"cd/subcode.ixx"
"cd/toc.ixx"
"crc/crc.ixx"
"crc/crc16_gsm.ixx"
"crc/crc32.ixx"
"dvd/dvd_dump.ixx"
"dvd/dvd_key.ixx"
"dvd/css/css.ixx"
"filesystem/iso9660/iso9660.ixx"
"filesystem/iso9660/iso9660_browser.ixx"
"filesystem/iso9660/iso9660_defs.ixx"
"filesystem/iso9660/iso9660_entry.ixx"
"filesystem/iso9660/iso9660_map.ixx"
"hash/block_hasher.ixx"
"hash/md5.ixx"
"hash/sha1.ixx"
"readers/disc_read_form1_reader.ixx"
"readers/image_bin_form1_reader.ixx"
"readers/image_iso_form1_reader.ixx"
"readers/image_raw_reader.ixx"
"readers/image_simple_reader.ixx"
"readers/sector_reader.ixx"
"scsi/cmd.ixx"
"scsi/mmc.ixx"
"scsi/sptd.ixx"
"systems/securom.ixx"
"systems/s_cdrom.ixx"
"systems/s_iso.ixx"
"systems/dc.ixx"
"systems/mcd.ixx"
"systems/psx.ixx"
"systems/ps2.ixx"
"systems/ps3.ixx"
"systems/ps4.ixx"
"systems/ps5.ixx"
"systems/sat.ixx"
"systems/systems.ixx"
"utils/animation.ixx"
"utils/endian.ixx"
"utils/file_io.ixx"
"utils/hex_bin.ixx"
"utils/logger.ixx"
"utils/misc.ixx"
"utils/signal.ixx"
"utils/strings.ixx"
"utils/xbox.ixx"
"debug.ixx"
"dump.ixx"
"drive.ixx"
"hash.ixx"
"info.ixx"
"options.ixx"
"redumper.ixx"
"rings.ixx"
"rom_entry.ixx"
"skeleton.ixx"
"version.ixx"
)
target_include_directories(redumper
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
"utils"
)
set(libs
"lzma"
)
if(REDUMPER_TARGET_MACOSX)
find_library(CORE_FOUNDATION CoreFoundation REQUIRED)
find_library(IO_KIT IOKit REQUIRED)
set(libs ${libs}
${CORE_FOUNDATION}
${IO_KIT}
)
endif()
target_link_libraries(redumper ${libs})
install(TARGETS redumper DESTINATION "bin")
# Windows 7 requires administrative access in order to access the disc drive
if(MSVC AND ${CMAKE_SYSTEM_VERSION} EQUAL 6.1)
set_target_properties(redumper PROPERTIES LINK_FLAGS "/MANIFESTUAC:\"level='requireAdministrator' uiAccess='false'\"")
endif()
enable_testing()
add_subdirectory("lzma")
add_subdirectory("tests")