@@ -64,8 +64,14 @@ if(INSTALL_MINGW_DEPENDENCIES)
64
64
include (cmake/install_shared_libs.cmake )
65
65
endif ()
66
66
67
+ set (target FAudio-shared )
68
+
69
+ if (NOT BUILD_SHARED_LIBS )
70
+ set (target FAudio-static )
71
+ endif ()
72
+
67
73
# Source lists
68
- add_library (FAudio
74
+ add_library (${target}
69
75
# Public Headers
70
76
include /F3DAudio.h
71
77
include /FACT3D.h
@@ -106,14 +112,14 @@ add_library(FAudio
106
112
)
107
113
108
114
if (PLATFORM_WIN32 )
109
- target_link_libraries (FAudio PRIVATE dxguid uuid winmm ole32 advapi32 user32 mfplat mfreadwrite mfuuid propsys )
110
- target_compile_definitions (FAudio PUBLIC FAUDIO_WIN32_PLATFORM )
111
- target_compile_definitions (FAudio PRIVATE HAVE_WMADEC=1 )
115
+ target_link_libraries (${target} PRIVATE dxguid uuid winmm ole32 advapi32 user32 mfplat mfreadwrite mfuuid propsys )
116
+ target_compile_definitions (${target} PUBLIC FAUDIO_WIN32_PLATFORM )
117
+ target_compile_definitions (${target} PRIVATE HAVE_WMADEC=1 )
112
118
set (PLATFORM_CFLAGS "-DFAUDIO_WIN32_PLATFORM" )
113
119
set (XNASONG OFF )
114
120
else ()
115
121
if (BUILD_SDL3 )
116
- target_compile_definitions (FAudio PUBLIC FAUDIO_SDL3_PLATFORM )
122
+ target_compile_definitions (${target} PUBLIC FAUDIO_SDL3_PLATFORM )
117
123
set (PLATFORM_CFLAGS "-DFAUDIO_SDL3_PLATFORM" )
118
124
else ()
119
125
set (PLATFORM_CFLAGS )
@@ -122,39 +128,39 @@ endif()
122
128
123
129
# Only disable DebugConfiguration in release builds
124
130
if (NOT FORCE_ENABLE_DEBUGCONFIGURATION )
125
- target_compile_definitions (FAudio PRIVATE $< $< CONFIG:Release> :FAUDIO_DISABLE_DEBUGCONFIGURATION> )
131
+ target_compile_definitions (${target} PRIVATE $< $< CONFIG:Release> :FAUDIO_DISABLE_DEBUGCONFIGURATION> )
126
132
endif ()
127
133
128
134
# FAudio_assert Customization
129
135
if (LOG_ASSERTIONS )
130
- target_compile_definitions (FAudio PUBLIC FAUDIO_LOG_ASSERTIONS )
136
+ target_compile_definitions (${target} PUBLIC FAUDIO_LOG_ASSERTIONS )
131
137
endif ()
132
138
133
139
# FAudio folders as includes, for other targets to consume
134
- target_include_directories (FAudio PUBLIC
140
+ target_include_directories (${target} PUBLIC
135
141
$< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /src>
136
142
$< BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR} /include>
137
143
)
138
144
139
145
# MinGW builds should statically link libgcc
140
146
if (MINGW )
141
- target_link_libraries (FAudio PRIVATE -static-libgcc )
147
+ target_link_libraries (${target} PRIVATE -static-libgcc )
142
148
endif ()
143
149
144
150
# Soname
145
- set_target_properties (FAudio PROPERTIES OUTPUT_NAME "FAudio"
151
+ set_target_properties (${target} PROPERTIES OUTPUT_NAME "FAudio"
146
152
VERSION ${LIB_VERSION}
147
153
SOVERSION ${LIB_MAJOR_VERSION}
148
154
)
149
155
150
156
# XNA_Song Support
151
157
if (NOT XNASONG )
152
- target_compile_definitions (FAudio PRIVATE DISABLE_XNASONG )
158
+ target_compile_definitions (${target} PRIVATE DISABLE_XNASONG )
153
159
endif ()
154
160
155
161
# Dump source voices to RIFF WAVE files
156
162
if (DUMP_VOICES )
157
- target_compile_definitions (FAudio PRIVATE FAUDIO_DUMP_VOICES )
163
+ target_compile_definitions (${target} PRIVATE FAUDIO_DUMP_VOICES )
158
164
endif ()
159
165
160
166
# SDL Dependency
@@ -163,8 +169,8 @@ if (PLATFORM_WIN32)
163
169
elseif (BUILD_SDL3 )
164
170
if (DEFINED SDL3_INCLUDE_DIRS AND DEFINED SDL3_LIBRARIES )
165
171
message (STATUS "using pre-defined SDL3 variables SDL3_INCLUDE_DIRS and SDL3_LIBRARIES" )
166
- target_include_directories (FAudio PUBLIC "$<BUILD_INTERFACE:${SDL3_INCLUDE_DIRS} >" )
167
- target_link_libraries (FAudio PUBLIC ${SDL3_LIBRARIES} )
172
+ target_include_directories (${target} PUBLIC "$<BUILD_INTERFACE:${SDL3_INCLUDE_DIRS} >" )
173
+ target_link_libraries (${target} PUBLIC ${SDL3_LIBRARIES} )
168
174
if (INSTALL_MINGW_DEPENDENCIES )
169
175
install_shared_libs (${SDL3_LIBRARIES} DESTINATION bin NO_INSTALL_SYMLINKS )
170
176
endif ()
@@ -173,29 +179,29 @@ elseif (BUILD_SDL3)
173
179
find_package (SDL3 CONFIG )
174
180
if (TARGET SDL3::SDL3 )
175
181
message (STATUS "using TARGET SDL3::SDL3" )
176
- target_link_libraries (FAudio PUBLIC SDL3::SDL3 )
182
+ target_link_libraries (${target} PUBLIC SDL3::SDL3 )
177
183
if (INSTALL_MINGW_DEPENDENCIES )
178
184
install_shared_libs (TARGETS SDL3::SDL3 DESTINATION bin NO_INSTALL_SYMLINKS REQUIRED )
179
185
endif ()
180
186
elseif (TARGET SDL3 )
181
187
message (STATUS "using TARGET SDL3" )
182
- target_link_libraries (FAudio PUBLIC SDL3 )
188
+ target_link_libraries (${target} PUBLIC SDL3 )
183
189
if (INSTALL_MINGW_DEPENDENCIES )
184
190
install_shared_libs (TARGETS SDL3 DESTINATION bin NO_INSTALL_SYMLINKS REQUIRED )
185
191
endif ()
186
192
else ()
187
193
message (STATUS "no TARGET SDL3::SDL3, or SDL3, using variables" )
188
- target_include_directories (FAudio PUBLIC "$<BUILD_INTERFACE:${SDL3_INCLUDE_DIRS} >" )
189
- target_link_libraries (FAudio PUBLIC ${SDL3_LIBRARIES} )
194
+ target_include_directories (${target} PUBLIC "$<BUILD_INTERFACE:${SDL3_INCLUDE_DIRS} >" )
195
+ target_link_libraries (${target} PUBLIC ${SDL3_LIBRARIES} )
190
196
if (INSTALL_MINGW_DEPENDENCIES )
191
197
install_shared_libs (${SDL3_LIBRARIES} DESTINATION bin NO_INSTALL_SYMLINKS )
192
198
endif ()
193
199
endif ()
194
200
endif ()
195
201
elseif (DEFINED SDL2_INCLUDE_DIRS AND DEFINED SDL2_LIBRARIES )
196
202
message (STATUS "using pre-defined SDL2 variables SDL2_INCLUDE_DIRS and SDL2_LIBRARIES" )
197
- target_include_directories (FAudio PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS} >" )
198
- target_link_libraries (FAudio PUBLIC ${SDL2_LIBRARIES} )
203
+ target_include_directories (${target} PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS} >" )
204
+ target_link_libraries (${target} PUBLIC ${SDL2_LIBRARIES} )
199
205
if (INSTALL_MINGW_DEPENDENCIES )
200
206
install_shared_libs (${SDL2_LIBRARIES} DESTINATION bin NO_INSTALL_SYMLINKS )
201
207
endif ()
@@ -204,20 +210,20 @@ else()
204
210
find_package (SDL2 CONFIG )
205
211
if (TARGET SDL2::SDL2 )
206
212
message (STATUS "using TARGET SDL2::SDL2" )
207
- target_link_libraries (FAudio PUBLIC SDL2::SDL2 )
213
+ target_link_libraries (${target} PUBLIC SDL2::SDL2 )
208
214
if (INSTALL_MINGW_DEPENDENCIES )
209
215
install_shared_libs (TARGETS SDL2::SDL2 DESTINATION bin NO_INSTALL_SYMLINKS REQUIRED )
210
216
endif ()
211
217
elseif (TARGET SDL2 )
212
218
message (STATUS "using TARGET SDL2" )
213
- target_link_libraries (FAudio PUBLIC SDL2 )
219
+ target_link_libraries (${target} PUBLIC SDL2 )
214
220
if (INSTALL_MINGW_DEPENDENCIES )
215
221
install_shared_libs (TARGETS SDL2 DESTINATION bin NO_INSTALL_SYMLINKS REQUIRED )
216
222
endif ()
217
223
else ()
218
224
message (STATUS "no TARGET SDL2::SDL2, or SDL2, using variables" )
219
- target_include_directories (FAudio PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS} >" )
220
- target_link_libraries (FAudio PUBLIC ${SDL2_LIBRARIES} )
225
+ target_include_directories (${target} PUBLIC "$<BUILD_INTERFACE:${SDL2_INCLUDE_DIRS} >" )
226
+ target_link_libraries (${target} PUBLIC ${SDL2_LIBRARIES} )
221
227
if (INSTALL_MINGW_DEPENDENCIES )
222
228
install_shared_libs (${SDL2_LIBRARIES} DESTINATION bin NO_INSTALL_SYMLINKS )
223
229
endif ()
@@ -242,7 +248,7 @@ if(BUILD_UTILS)
242
248
utils/uicommon/imstb_textedit.h
243
249
utils/uicommon/imstb_truetype.h
244
250
)
245
- target_link_libraries (uicommon PUBLIC FAudio )
251
+ target_link_libraries (uicommon PUBLIC ${target} )
246
252
247
253
# Shared WAV Resources
248
254
add_library (wavs STATIC utils/wavcommon/wavs.cpp )
@@ -252,11 +258,11 @@ if(BUILD_UTILS)
252
258
253
259
# These tools do NOT use uicommon
254
260
add_executable (testparse utils/testparse/testparse.c )
255
- target_link_libraries (testparse PRIVATE FAudio )
261
+ target_link_libraries (testparse PRIVATE ${target} )
256
262
add_executable (testxwma utils/testxwma/testxwma.cpp )
257
- target_link_libraries (testxwma PRIVATE FAudio )
263
+ target_link_libraries (testxwma PRIVATE ${target} )
258
264
add_executable (showriffheader utils/showriffheader/showriffheader.cpp )
259
- target_link_libraries (showriffheader PRIVATE FAudio )
265
+ target_link_libraries (showriffheader PRIVATE ${target} )
260
266
261
267
# These tools use uicommon, but NOT wavs
262
268
add_executable (facttool utils/facttool/facttool.cpp )
@@ -313,7 +319,7 @@ endif()
313
319
if (BUILD_TESTS )
314
320
add_executable (faudio_tests tests/xaudio2.c )
315
321
target_compile_definitions (faudio_tests PRIVATE _DEFAULT_SOURCE _BSD_SOURCE )
316
- target_link_libraries (faudio_tests PRIVATE FAudio )
322
+ target_link_libraries (faudio_tests PRIVATE ${target} )
317
323
endif ()
318
324
319
325
# Installation
@@ -324,9 +330,15 @@ install(
324
330
DESTINATION ${FAudio_INSTALL_INCLUDEDIR}
325
331
)
326
332
# Libraries...
333
+ set (export ${PROJECT_NAME} -targets-shared )
334
+
335
+ if (NOT BUILD_SHARED_LIBS )
336
+ set (export ${PROJECT_NAME} -targets-static )
337
+ endif ()
338
+
327
339
install (
328
- TARGETS ${PROJECT_NAME }
329
- EXPORT ${PROJECT_NAME} -targets
340
+ TARGETS ${target }
341
+ EXPORT ${export}
330
342
INCLUDES DESTINATION ${FAudio_INSTALL_INCLUDEDIR}
331
343
RUNTIME DESTINATION ${FAudio_INSTALL_BINDIR}
332
344
LIBRARY DESTINATION ${FAudio_INSTALL_LIBDIR}
@@ -367,8 +379,9 @@ install(
367
379
FILES ${CMAKE_CURRENT_BINARY_DIR} /generated/${PROJECT_NAME}Config.cmake
368
380
DESTINATION ${FAudio_INSTALL_LIBDIR} /cmake/${PROJECT_NAME}
369
381
)
382
+
370
383
install (
371
- EXPORT ${PROJECT_NAME} -targets
384
+ EXPORT ${export}
372
385
NAMESPACE ${PROJECT_NAME} ::
373
386
DESTINATION ${FAudio_INSTALL_LIBDIR} /cmake/${PROJECT_NAME}
374
387
)
0 commit comments