This repository has been archived by the owner on Jul 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
210 lines (181 loc) · 7.39 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
cmake_minimum_required (VERSION 3.5)
set (project VRCE)
project (
${project}
DESCRIPTION "Exports vrchat avatars"
LANGUAGES CXX
)
# --- Configure default build ---
set (default_build_type "Release")
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message (STATUS "Setting build type to '${default_build_type}' as none was specified.")
set (CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
set_property (CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif ()
# --------------------------------
# --- Simplify build checking ---
math (EXPR VPTR_BITS "${CMAKE_SIZEOF_VOID_P}*8") # Convert 4/8 -> 32/64
if (UNIX AND NOT APPLE)
set (BUILD_OS "linux")
set (BUILD_OSL "linux")
elseif (WIN32)
set (BUILD_OS "win")
set (BUILD_OSL "windows")
endif ()
string (TOLOWER ${CMAKE_CXX_COMPILER_ID} BUILD_COMPILER)
# Translate some stuff
if (${BUILD_COMPILER} STREQUAL "gnu")
set (BUILD_COMPILER "gcc")
elseif (${BUILD_COMPILER} STREQUAL "intel")
set (BUILD_COMPILER "icc")
endif ()
# --------------------------------
# --- Set global C++ CMake settings ---
set (CMAKE_CXX_STANDARD 20)
set (CMAKE_CXX_EXTENSIONS OFF)
set (THREADS_PREFER_PTHREAD_FLAG ON)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
set (CMAKE_POLICY_DEFAULT_CMP0069 NEW)
set (CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
if (VERBOSE)
set (CMAKE_VERBOSE_MAKEFILE ON)
endif ()
# -------------------------------
# --- Set compiler flags ---
# Debugging, and warnings
add_definitions (-DBUILDER_STATIC_DEFINE)
if (NOT ${CMAKE_BUILD_TYPE} MATCHES "Release")
add_definitions (-DDEBUG)
set (BUILD_TYPE "dbg")
if (MSVC)
# Remove all previously declared flags before adding new ones
string (REGEX REPLACE "[/-]W[0-4] ?" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# Verboseeeee
string (APPEND CMAKE_CXX_FLAGS " -Wall")
else ()
# Verboseeeee
string (APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -pedantic -Wformat=2 -Wsign-conversion -Wundef -Wredundant-decls -Wwrite-strings -Wpointer-arith -Wcast-qual -Wmissing-include-dirs -Wcast-align -Wctor-dtor-privacy -Wdisabled-optimization -Winvalid-pch -Woverloaded-virtual -Wconversion -Wswitch-enum -Wno-ctor-dtor-privacy -Wno-format-nonliteral -Wnoexcept -Wno-dangling-else -Wno-unused-local-typedefs -Wdouble-promotion -Wtrampolines -Wzero-as-null-pointer-constant -Wuseless-cast -Wvector-operation-performance -Wsized-deallocation -Wshadow -Wshift-overflow=2 -Wnull-dereference -Wduplicated-cond")
endif ()
else ()
set (BUILD_TYPE "rel")
endif ()
# Optimization and compiler specific fixes
if (MSVC)
# Remove all previously declared flags before adding new ones
string (REGEX REPLACE "[/-][ML][DT]d? ?" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string (REGEX REPLACE "[/-]O[12bdgistxy] ?" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string (REGEX REPLACE "[/-]DEBUG:[a-zA-Z]+ ?" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# Enable max warnings (But dont spam the console)
string (APPEND CMAKE_CXX_FLAGS " -DNOMINMAX -wo9025 -wo5054")
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
string (APPEND CMAKE_CXX_FLAGS " -MT -DEBUG:NONE -O2")
else ()
string (APPEND CMAKE_CXX_FLAGS " -MTd -DEBUG:FULL -Od")
endif ()
else ()
# 64-bit, and threading
string (APPEND CMAKE_CXX_FLAGS " -m64")
if (${CMAKE_BUILD_TYPE} MATCHES "Release")
string (APPEND CMAKE_CXX_FLAGS " -fstack-protector -O3 -g0")
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
string (APPEND CMAKE_CXX_FLAGS " -s")
endif ()
else ()
string (APPEND CMAKE_CXX_FLAGS " -O0 -g3")
endif ()
endif ()
# --------------------------
find_package (Threads REQUIRED)
find_package (fmt CONFIG REQUIRED)
find_package (lz4 CONFIG REQUIRED)
find_package (liblzma CONFIG REQUIRED)
message ("Configuring ${project}...")
# --- Build ---
set (${project}_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/stream.cpp
${CMAKE_CURRENT_SOURCE_DIR}/binaryreader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/endianreader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/binaryreader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/hash128.cpp
${CMAKE_CURRENT_SOURCE_DIR}/version.cpp
${CMAKE_CURRENT_SOURCE_DIR}/fileidentifier.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bundlescene.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bundleheader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/filescheme.cpp
${CMAKE_CURRENT_SOURCE_DIR}/fileschemelist.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bundlefilescheme.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bundlerawwebheader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bundlefilestreamheader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bundlemetadata.cpp
${CMAKE_CURRENT_SOURCE_DIR}/blocksinfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/storageblock.cpp
${CMAKE_CURRENT_SOURCE_DIR}/directoryinfo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/filenameutils.cpp
${CMAKE_CURRENT_SOURCE_DIR}/bundlefileblockreader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/sevenziphelper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/filereadsource.cpp
${CMAKE_CURRENT_SOURCE_DIR}/memoryreadsource.cpp
)
set (${project}_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/stream.h
${CMAKE_CURRENT_SOURCE_DIR}/binaryreader.h
${CMAKE_CURRENT_SOURCE_DIR}/vecstreambuf.h
${CMAKE_CURRENT_SOURCE_DIR}/ibundlereadable.h
${CMAKE_CURRENT_SOURCE_DIR}/endianreader.h
${CMAKE_CURRENT_SOURCE_DIR}/binaryreader.h
${CMAKE_CURRENT_SOURCE_DIR}/bundlereader.h
${CMAKE_CURRENT_SOURCE_DIR}/hash128.h
${CMAKE_CURRENT_SOURCE_DIR}/readerhelpers.h
${CMAKE_CURRENT_SOURCE_DIR}/bundleflags.h
${CMAKE_CURRENT_SOURCE_DIR}/endiantype.h
${CMAKE_CURRENT_SOURCE_DIR}/endianswap.h
${CMAKE_CURRENT_SOURCE_DIR}/version.h
${CMAKE_CURRENT_SOURCE_DIR}/versiontype.h
${CMAKE_CURRENT_SOURCE_DIR}/fileentrytype.h
${CMAKE_CURRENT_SOURCE_DIR}/fileidentifier.h
${CMAKE_CURRENT_SOURCE_DIR}/bundletype.h
${CMAKE_CURRENT_SOURCE_DIR}/compressiontype.h
${CMAKE_CURRENT_SOURCE_DIR}/bundlescene.h
${CMAKE_CURRENT_SOURCE_DIR}/bundleheader.h
${CMAKE_CURRENT_SOURCE_DIR}/filescheme.h
${CMAKE_CURRENT_SOURCE_DIR}/fileschemelist.h
${CMAKE_CURRENT_SOURCE_DIR}/bundleversion.h
${CMAKE_CURRENT_SOURCE_DIR}/bundlefilescheme.h
${CMAKE_CURRENT_SOURCE_DIR}/bundlerawwebheader.h
${CMAKE_CURRENT_SOURCE_DIR}/bundlefilestreamheader.h
${CMAKE_CURRENT_SOURCE_DIR}/bundlemetadata.h
${CMAKE_CURRENT_SOURCE_DIR}/blocksinfo.h
${CMAKE_CURRENT_SOURCE_DIR}/storageblock.h
${CMAKE_CURRENT_SOURCE_DIR}/directoryinfo.h
${CMAKE_CURRENT_SOURCE_DIR}/node.h
${CMAKE_CURRENT_SOURCE_DIR}/filenameutils.h
${CMAKE_CURRENT_SOURCE_DIR}/bundlefileblockreader.h
${CMAKE_CURRENT_SOURCE_DIR}/storageblockflags.h
${CMAKE_CURRENT_SOURCE_DIR}/sevenziphelper.h
${CMAKE_CURRENT_SOURCE_DIR}/ireadsource.h
${CMAKE_CURRENT_SOURCE_DIR}/filereadsource.h
${CMAKE_CURRENT_SOURCE_DIR}/memoryreadsource.h
)
add_executable (${project}
main.cpp
${${project}_HEADERS}
${${project}_SOURCES}
)
target_include_directories (${project} PRIVATE
${FMT_INCLUDE_DIRS}
${LZ4_INCLUDE_DIRS}
${LIBLZMA_INCLUDE_DIRS}
)
target_link_libraries (${project} PRIVATE
Threads::Threads
${CMAKE_DL_LIBS}
fmt::fmt
lz4::lz4
liblzma::liblzma
)
if (WIN32)
target_link_libraries(${project} PRIVATE ws2_32 winmm Rpcrt4 Iphlpapi)
endif ()