forked from vgmstream/vgmstream
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
274 lines (259 loc) · 9.44 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
cmake_minimum_required(VERSION 3.5)
project(vgmstream C)
enable_language(CXX)
get_directory_property(hasParent PARENT_DIRECTORY)
if(hasParent)
set(VGM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
endif()
set(VGM_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(VGM_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_MODULE_PATH ${VGM_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH})
include(vgmstream)
# Options
option(USE_MPEG "Use libmpg123 for support of MPEG (MP1/MP2/MP3)" ON)
option(USE_VORBIS "Use libvorbis for support of Vorbis" ON)
option(USE_FFMPEG "Use FFmpeg for support of many codecs" ON)
option(USE_MAIATRAC3PLUS "Use MAIATRAC3+ for support of ATRAC3+" OFF)
set(MAIATRAC3PLUS_PATH CACHE PATH "Path to MAIATRAC3+")
option(USE_G7221 "Use G7221 for support of ITU-T G.722.1 annex C" ON)
if(WIN32)
# May need to see if it is possible to get these to work on non-Windows systems too
option(USE_G719 "Use libg719_decode for support ITU-T G.719" ON)
option(USE_ATRAC9 "Use LibAtrac9 for support of ATRAC9" ON)
option(USE_CELT "Use libcelt for support of FSB CELT versions 0.6.1 and 0.11.0" ON)
endif()
# Build choices
option(BUILD_CLI "Build vgmstream CLI" ON)
if(WIN32)
option(BUILD_FB2K "Build foobar2000 component" ON)
set(FB2K_SDK_PATH CACHE PATH "Path to foobar2000 SDK")
set(WTL_INCLUDE_PATH CACHE PATH "Path to WTL include directory")
set(FB2K_COMPONENT_INSTALL_PREFIX CACHE PATH "Path to foobar2000 component installation directory")
option(BUILD_WINAMP "Build Winamp plugin" ON)
set(WINAMP_INSTALL_PREFIX CACHE PATH "Path to Winamp installation directory")
option(BUILD_XMPLAY "Build XMPlay plugin" ON)
set(XMPLAY_INSTALL_PREFIX CACHE PATH "Path to XMPlay installation directory")
else()
option(BUILD_AUDACIOUS "Build Audacious plugin" ON)
endif()
if(WIN32)
# Enable support for the resource compiler when using MinGW
if(MINGW)
enable_language(RC)
# Not 100% sure this is needed, but in the past, MinGW's command for compiling resources was incorrect
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
endif(MINGW)
# Update the version
set(CMAKE_EXECUTABLE_SUFFIX .exe)
if(MSVC)
file(TO_NATIVE_PATH "${VGM_BINARY_DIR}/version.h" VERSION_H_PATH)
add_custom_command(OUTPUT ${VGM_BINARY_DIR}/version.h
COMMAND "${VGM_SOURCE_DIR}/version.bat"
ARGS ${VERSION_H_PATH} VERSION
DEPENDS ${VGM_SOURCE_DIR}/version.bat)
add_custom_target(version_h DEPENDS ${VGM_BINARY_DIR}/version.h)
else()
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags
WORKING_DIRECTORY ${VGM_SOURCE_DIR}
OUTPUT_VARIABLE VGMSTREAM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif()
else()
# Update the version
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags
WORKING_DIRECTORY ${VGM_SOURCE_DIR}
OUTPUT_VARIABLE VGMSTREAM_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
# Find the relevant packages
if(USE_MPEG)
find_package(MPG123)
if(NOT MPG123_FOUND)
set(USE_MPEG OFF)
endif()
endif()
if(USE_VORBIS)
find_package(VorbisFile)
if(NOT VORBISFILE_FOUND)
set(USE_VORBIS OFF)
endif()
endif()
if(USE_FFMPEG)
find_package(FFmpeg)
if(NOT FFMPEG_LIBRARIES)
set(USE_FFMPEG OFF)
endif()
endif()
# If building the CLI, we need to include AO as well
if(BUILD_CLI)
find_package(AO)
if(NOT AO_FOUND)
message(FATAL_ERROR "Cannot build vgmstream123 without libao")
endif()
endif()
# Only build JSON dumping capabilities on Linux
pkg_check_modules(JANSSON jansson>=2.3)
if (JANSSON_FOUND)
set(USE_JANSSON ON)
set(JANSSON_PKG libjansson)
include_directories(${JANSSON_INCLUDE_DIRS})
link_directories(${JANSSON_LIBRARY_DIRS})
else (JANSSON_FOUND)
set(USE_JANSSON OFF)
endif (JANSSON_FOUND)
# If building Audacious, we need to make sure we can find its pkg-config module as well as GTK's
if(BUILD_AUDACIOUS)
include(FindPkgConfig)
pkg_search_module(AUDACIOUS REQUIRED audacious>=3.6)
pkg_get_variable(AUDACIOUS_PLUGIN_DIR audacious plugin_dir)
pkg_search_module(GTK REQUIRED gtk+-3.0 gtk+-2.0)
endif()
endif()
# Set compiler flags
if(CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES GNU)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-parentheses-equality -Wno-header-guard -Wno-unused-function -Wno-shift-negative-value -Wno-deprecated-register")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-parentheses-equality -Wno-header-guard -Wno-unused-function -Wno-shift-negative-value -Wno-deprecated-register")
elseif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 5.9)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-misleading-indentation")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-misleading-indentation")
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
endif()
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 2.99)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-format -Wno-sign-compare")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-format -Wno-sign-compare")
endif()
elseif(MSVC)
if(CMAKE_C_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
endif()
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4005 /wd4018 /wd4244 /wd4302 /wd4838")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4005 /wd4018 /wd4244 /wd4302 /wd4838")
endif()
# Add other projects and subdirectories as needed
if(USE_MAIATRAC3PLUS)
if(MAIATRAC3PLUS_PATH)
add_subdirectory(${MAIATRAC3PLUS_PATH}/MaiAT3PlusDecoder ${VGM_BINARY_DIR}/maitrac3plus)
else()
message(FATAL_ERROR "Path to MAIATRAC3+ must be set. (Use MAIATRAC3PLUS_PATH)")
endif()
endif()
add_subdirectory(src)
if(WIN32)
add_subdirectory(ext_libs)
if(BUILD_WINAMP)
if(NOT WINAMP_INSTALL_PREFIX)
set(WINAMP_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/winamp)
endif()
add_subdirectory(winamp)
endif()
if(BUILD_FB2K)
if(NOT FB2K_SDK_PATH)
message(FATAL_ERROR "The path to the foobar2000 SDK must be set. (Use FB2K_SDK_PATH)")
endif()
if(NOT WTL_INCLUDE_PATH)
message(FATAL_ERROR "The path to the WTL include directory must be set. (Use WTL_INCLUDE_PATH)")
endif()
if(NOT FB2K_COMPONENT_INSTALL_PREFIX)
set(FB2K_COMPONENT_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/fb2k)
endif()
include_external_msproject(fb2k_sdk ${FB2K_SDK_PATH}/foobar2000/SDK/foobar2000_SDK.vcxproj)
include_external_msproject(fb2k_sdk_helpers ${FB2K_SDK_PATH}/foobar2000/helpers/foobar2000_sdk_helpers.vcxproj)
include_external_msproject(fb2k_atl_helpers ${FB2K_SDK_PATH}/foobar2000/ATLHelpers/foobar2000_ATL_helpers.vcxproj)
include_external_msproject(fb2k_component_client ${FB2K_SDK_PATH}/foobar2000/foobar2000_component_client/foobar2000_component_client.vcxproj)
include_external_msproject(pfc ${FB2K_SDK_PATH}/pfc/pfc.vcxproj)
add_subdirectory(fb2k)
endif()
if(BUILD_XMPLAY)
if(NOT XMPLAY_INSTALL_PREFIX)
set(XMPLAY_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/xmplay)
endif()
add_subdirectory(xmplay)
endif()
else()
if(BUILD_AUDACIOUS)
add_subdirectory(audacious)
endif()
endif()
if(BUILD_CLI)
if(WIN32)
add_subdirectory(ext_libs/Getopt)
endif()
add_subdirectory(cli)
endif()
# Option Summary
message(STATUS " Option Summary")
message(STATUS "=================")
message(STATUS " MPEG: ${USE_MPEG}")
message(STATUS " Vorbis: ${USE_VORBIS}")
message(STATUS " FFmpeg: ${USE_FFMPEG}")
message(STATUS " MAIATRAC3+: ${USE_MAIATRAC3PLUS}")
message(STATUS " G.722.1: ${USE_G7221}")
if(WIN32)
message(STATUS " G.719: ${USE_G719}")
message(STATUS " ATRAC9: ${USE_ATRAC9}")
message(STATUS " FSB CELT: ${USE_CELT}")
endif()
message(STATUS "")
# Build Summary
message(STATUS " Building")
message(STATUS "=========================")
if(WIN32)
message(STATUS " CLI: ${BUILD_CLI}")
message(STATUS " JSON dumping: ${USE_JANSSON}")
message(STATUS "foobar2000 component: ${BUILD_FB2K}")
message(STATUS " Winamp plugin: ${BUILD_WINAMP}")
message(STATUS " XMPlay plugin: ${BUILD_XMPLAY}")
else()
message(STATUS "CLI/vgmstream123: ${BUILD_CLI}")
message(STATUS " JSON dumping: ${USE_JANSSON}")
message(STATUS "Audacious plugin: ${BUILD_AUDACIOUS}")
endif()
message(STATUS "")
# Install Summary
message(STATUS " Install Paths")
message(STATUS "=========================")
if(WIN32)
if(BUILD_CLI)
message(STATUS " CLI: ${CMAKE_INSTALL_PREFIX}/bin")
endif()
if(BUILD_FB2K)
message(STATUS "foobar2000 component: ${FB2K_COMPONENT_INSTALL_PREFIX}")
endif()
if(BUILD_WINAMP)
message(STATUS " Winamp plugin: ${WINAMP_INSTALL_PREFIX}")
endif()
if(BUILD_XMPLAY)
message(STATUS " XMPlay plugin: ${XMPLAY_INSTALL_PREFIX}")
endif()
else()
if(BUILD_CLI)
message(STATUS "CLI/vgmstream123: ${CMAKE_INSTALL_PREFIX}/bin")
endif()
if(BUILD_AUDACIOUS)
message(STATUS "Audacious plugin: ${AUDACIOUS_PLUGIN_DIR}/Input")
endif()
endif()
message(STATUS "")