forked from dbry/WavPack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
703 lines (624 loc) · 21.7 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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
cmake_minimum_required(VERSION 3.2)
project(WavPack VERSION 5.5.0)
# Languages
include(CheckLanguage)
check_language(ASM)
if(CMAKE_ASM_COMPILER)
enable_language(ASM)
endif()
if(MSVC)
enable_language(ASM_MASM)
else()
check_language(ASM-ATT)
if(CMAKE_ASM-ATT_COMPILER)
enable_language(ASM-ATT)
endif()
endif()
# Policies
# CMake 3.11 warning: Include file check macros honor CMAKE_REQUIRED_LIBRARIES.
if(POLICY CMP0075)
cmake_policy(SET CMP0075 NEW)
endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
if(CMAKE_VERSION VERSION_LESS 3.11)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
endif()
if(CMAKE_VERSION VERSION_LESS 3.12)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
endif()
include(CheckCCompilerFlag)
include(CheckCLinkerFlag)
include(TestLargeFiles)
include(CheckLanguage)
include(CheckLibraryExists)
include(CheckFunctionExists)
include(CMakeDependentOption)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(FeatureSummary)
include(CPack)
include(FindOpenSSL)
# Options. See also dependent options below
option(WAVPACK_ENABLE_LEGACY "Decode legacy (< 4.0) WavPack files" OFF)
option(WAVPACK_ENABLE_DSD "Enable support for WavPack DSD files" ON)
option(WAVPACK_INSTALL_CMAKE_MODULE "Generate and install CMake package configuration module" ON)
option(WAVPACK_INSTALL_DOCS "Install documentation" ON)
option(WAVPACK_INSTALL_PKGCONFIG_MODULE "Generate and install wavpack.pc" ON)
# Configuration tests
check_library_exists(m cos "" HAVE_LIBM)
if(HAVE_LIBM)
list(APPEND CMAKE_REQUIRED_LIBRARIES m)
endif()
find_package(Threads)
find_package(Iconv)
find_package(LibXslt)
find_package(OpenSSL)
set(DOCBOOK_PREREQS_FOUND FALSE)
if(LIBXSLT_XSLTPROC_EXECUTABLE)
if(NOT $ENV{XML_CATALOG_FILES} STREQUAL "")
set(XML_CATALOG_FILEPATH $ENV{XML_CATALOG_FILES})
else()
set(XML_CATALOG_FILEPATH "/etc/xml/catalog")
endif()
find_program(XMLCATALOG_EXECUTABLE xmlcatalog)
if(XMLCATALOG_EXECUTABLE)
execute_process(
COMMAND ${XMLCATALOG_EXECUTABLE} --noout ${XML_CATALOG_FILEPATH} "-//OASIS//DTD DocBook XML V4.1.2//EN"
RESULT_VARIABLE DOCBOOK_XML_RSLT
OUTPUT_QUIET
ERROR_QUIET
)
if(DOCBOOK_XML_RSLT EQUAL 0)
execute_process(
COMMAND ${XMLCATALOG_EXECUTABLE} --noout ${XML_CATALOG_FILEPATH} "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl"
RESULT_VARIABLE DOCBOOK_XSL_RSLT
OUTPUT_QUIET
ERROR_QUIET
)
if(DOCBOOK_XML_RSLT EQUAL 0)
set(DOCBOOK_PREREQS_FOUND TRUE)
endif()
endif()
endif()
endif()
check_c_source_compiles(
"int main()
{
return __builtin_clz(1);
}"
HAVE___BUILTIN_CLZ
)
test_large_files(LARGE_FILES_SUPPORTED)
if(LARGE_FILES_SUPPORTED)
add_definitions(${LARGE_FILES_DEFINITIONS})
endif()
check_function_exists(fseeko HAVE_FSEEKO)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CPU_ASM_X64 1)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CPU_ASM_X86 1)
endif()
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i386.*|i486.*|i586.*|i686.*|i786.*")
set(CPU_ASM_X86 1)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "arm*")
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(CPU_ASM_ARM32 1)
endif()
endif()
if(WIN32 AND (NOT MINGW))
if(CMAKE_ASM_MASM_COMPILER AND (CPU_ASM_X86 OR CPU_ASM_X64))
set(HAVE_MASM 1)
endif()
else()
if(CMAKE_ASM-ATT_COMPILER)
if(CPU_ASM_X86 OR CPU_ASM_X64 OR CPU_ASM_ARM32)
set(HAVE_ASM 1)
endif()
endif()
endif()
# Dependent options
cmake_dependent_option(WAVPACK_ENABLE_ASM "Enable assembly optimizations" ON "HAVE_ASM OR HAVE_MASM" OFF)
cmake_dependent_option(WAVPACK_ENABLE_LIBCRYPTO "Use OpenSSL::Crypto library" ON "OPENSSL_FOUND" OFF)
cmake_dependent_option(WAVPACK_BUILD_PROGRAMS "Build programs" ON "Iconv_FOUND" OFF)
cmake_dependent_option(WAVPACK_BUILD_COOLEDIT_PLUGIN "Build CoolEdit plugin" ON "WIN32" OFF)
cmake_dependent_option(WAVPACK_BUILD_WINAMP_PLUGIN "Build WinAmp plugin" ON "WIN32" OFF)
cmake_dependent_option(BUILD_TESTING "Build tests" ON "NOT WIN32" OFF)
cmake_dependent_option(WAVPACK_BUILD_DOCS "Build documentation" ON "DOCBOOK_PREREQS_FOUND" OFF)
# Targets
add_library(wavpack
src/common_utils.c
src/decorr_utils.c
src/entropy_utils.c
src/extra1.c
src/extra2.c
src/open_utils.c
src/open_filename.c
src/open_legacy.c
src/open_raw.c
src/pack.c
src/pack_dns.c
src/pack_floats.c
src/pack_utils.c
src/read_words.c
src/tags.c
src/tag_utils.c
src/unpack.c
src/unpack_floats.c
src/unpack_seek.c
src/unpack_utils.c
src/write_words.c
src/decorr_tables.h
src/unpack3.h
src/wavpack_local.h
src/wavpack_version.h
$<$<BOOL:${WAVPACK_ENABLE_LEGACY}>:src/unpack3.c>
$<$<BOOL:${WAVPACK_ENABLE_LEGACY}>:src/unpack3_open.c>
$<$<BOOL:${WAVPACK_ENABLE_LEGACY}>:src/unpack3_seek.c>
$<$<BOOL:${WAVPACK_ENABLE_DSD}>:src/pack_dsd.c>
$<$<BOOL:${WAVPACK_ENABLE_DSD}>:src/unpack_dsd.c>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${HAVE_MASM}>,$<BOOL:${CPU_ASM_X86}>>:src/pack_x86.asm>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${HAVE_MASM}>,$<BOOL:${CPU_ASM_X86}>>:src/unpack_x86.asm>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${HAVE_MASM}>,$<BOOL:${CPU_ASM_X64}>>:src/pack_x64.asm>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${HAVE_MASM}>,$<BOOL:${CPU_ASM_X64}>>:src/unpack_x64.asm>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${HAVE_ASM}>,$<BOOL:${CPU_ASM_X86}>>:src/pack_x86.S>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${HAVE_ASM}>,$<BOOL:${CPU_ASM_X86}>>:src/unpack_x86.S>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${HAVE_ASM}>,$<BOOL:${CPU_ASM_X64}>>:src/pack_x64.S>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${HAVE_ASM}>,$<BOOL:${CPU_ASM_X64}>>:src/unpack_x64.S>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${HAVE_ASM}>,$<BOOL:${CPU_ASM_ARM32}>>:src/unpack_armv7.S>
$<$<AND:$<BOOL:${WIN32}>,$<BOOL:${BUILD_SHARED_LIBS}>>:wavpackdll/wavpackdll.rc>
)
target_include_directories(wavpack
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(wavpack
PRIVATE
$<$<BOOL:${HAVE_LIBM}>:m>
)
if(CMAKE_VERSION VERSION_LESS 3.4)
target_include_directories(wavpack
PRIVATE
$<$<BOOL:${WAVPACK_ENABLE_LIBCRYPTO}>:${OPENSSL_INCLUDE_DIR}>
)
target_link_libraries(wavpack
PRIVATE
$<$<BOOL:${WAVPACK_ENABLE_LIBCRYPTO}>:${OPENSSL_CRYPTO_LIBRARY}>
)
else()
target_link_libraries(wavpack
PRIVATE
$<$<BOOL:${WAVPACK_ENABLE_LIBCRYPTO}>:OpenSSL::Crypto>
)
endif()
target_compile_definitions(wavpack
PRIVATE
$<$<BOOL:${WAVPACK_ENABLE_LEGACY}>:ENABLE_LEGACY>
$<$<BOOL:${WAVPACK_ENABLE_DSD}>:ENABLE_DSD>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
$<$<BOOL:${HAVE___BUILTIN_CLZ}>:HAVE___BUILTIN_CLZ>
$<$<BOOL:${HAVE_FSEEKO}>:HAVE_FSEEKO>
$<$<BOOL:${WAVPACK_ENABLE_LIBCRYPTO}>:HAVE_LIBCRYPTO>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${CPU_ASM_X86}>>:OPT_ASM_X86>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${CPU_ASM_X64}>>:OPT_ASM_X64>
$<$<AND:$<BOOL:${WAVPACK_ENABLE_ASM}>,$<BOOL:${CPU_ASM_ARM32}>>:OPT_ASM_ARM32>
)
if(WAVPACK_ENABLE_ASM AND HAVE_MASM AND CPU_ASM_X86)
set_source_files_properties(src/pack_x86.asm src/unpack_x86.asm PROPERTIES COMPILE_FLAGS "/safeseh")
endif()
if(WIN32 AND (NOT MINGW))
if(BUILD_SHARED_LIBS)
set_target_properties(wavpack PROPERTIES OUTPUT_NAME wavpackdll)
else()
set_target_properties(wavpack PROPERTIES OUTPUT_NAME libwavpack)
endif()
endif()
# Symbols files
set(WAVPACK_EXPORT_SYMBOLS
WavpackAddWrapper
WavpackAppendBinaryTagItem
WavpackAppendTagItem
WavpackBigEndianToNative
WavpackCloseFile
WavpackDeleteTagItem
WavpackFloatNormalize
WavpackFlushSamples
WavpackFreeWrapper
WavpackGetAverageBitrate
WavpackGetBinaryTagItem
WavpackGetBinaryTagItemIndexed
WavpackGetBitsPerSample
WavpackGetBytesPerSample
WavpackGetChannelIdentities
WavpackGetChannelLayout
WavpackGetChannelMask
WavpackGetEncodedNoise
WavpackGetErrorMessage
WavpackGetFileExtension
WavpackGetFileFormat
WavpackGetFileSize
WavpackGetFileSize64
WavpackGetFloatNormExp
WavpackGetInstantBitrate
WavpackGetLibraryVersion
WavpackGetLibraryVersionString
WavpackGetMD5Sum
WavpackGetMode
WavpackGetNativeSampleRate
WavpackGetNumBinaryTagItems
WavpackGetNumChannels
WavpackGetNumErrors
WavpackGetNumSamples
WavpackGetNumSamples64
WavpackGetNumSamplesInFrame
WavpackGetNumTagItems
WavpackGetProgress
WavpackGetQualifyMode
WavpackGetRatio
WavpackGetReducedChannels
WavpackGetSampleIndex
WavpackGetSampleIndex64
WavpackGetSampleRate
WavpackGetTagItem
WavpackGetTagItemIndexed
WavpackGetVersion
WavpackGetWrapperBytes
WavpackGetWrapperData
WavpackGetWrapperLocation
WavpackLittleEndianToNative
WavpackLossyBlocks
WavpackNativeToBigEndian
WavpackNativeToLittleEndian
WavpackOpenFileInput
WavpackOpenFileInputEx
WavpackOpenFileInputEx64
WavpackOpenFileOutput
WavpackOpenRawDecoder
WavpackPackInit
WavpackPackSamples
WavpackSeekSample
WavpackSeekSample64
WavpackSeekTrailingWrapper
WavpackSetChannelLayout
WavpackSetConfiguration
WavpackSetConfiguration64
WavpackSetFileInformation
WavpackStoreMD5Sum
WavpackUnpackSamples
WavpackUpdateNumSamples
WavpackVerifySingleBlock
WavpackWriteTag
)
if(BUILD_SHARED_LIBS AND (WIN32 OR CYGWIN))
set(FILE_CONTENTS "EXPORTS\n")
foreach(EXPORT_SYMBOL ${WAVPACK_EXPORT_SYMBOLS})
list(APPEND FILE_CONTENTS " ${EXPORT_SYMBOL}\n")
endforeach()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libwavpack.def ${FILE_CONTENTS})
target_sources(wavpack PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/libwavpack.def)
elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(FILE_CONTENTS "")
foreach(EXPORT_SYMBOL ${WAVPACK_EXPORT_SYMBOLS})
list(APPEND FILE_CONTENTS "_${EXPORT_SYMBOL}\n")
endforeach()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libwavpack.sym ${FILE_CONTENTS})
if(CMAKE_VERSION VERSION_LESS 3.13)
set_target_properties(wavpack PROPERTIES LINK_FLAGS "-Wl,-exported_symbols_list,'${CMAKE_CURRENT_BINARY_DIR}/libwavpack.sym'")
else()
target_link_directories(wavpack PRIVATE "-Wl,-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/libwavpack.sym")
endif()
else()
set(CONFTTEST_CONTENTS "VERS_1 {\n global: sym\;\n\n};\n\nVERS_2 {\n global: sym;\n} VERS_1\;")
file(WRITE ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/conftest.map "${CONFTTEST_CONTENTS}")
check_c_linker_flag("-Wl,--version-script=${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/conftest.map" COMPILER_SUPPORTS_SYMBOL_MAPS)
if(COMPILER_SUPPORTS_SYMBOL_MAPS)
set(FILE_CONTENTS "{ global:\n")
foreach(EXPORT_SYMBOL ${WAVPACK_EXPORT_SYMBOLS})
list(APPEND FILE_CONTENTS "${EXPORT_SYMBOL}\;\n")
endforeach()
list(APPEND FILE_CONTENTS "local: *\; }\;")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libwavpack.map ${FILE_CONTENTS})
if(CMAKE_VERSION VERSION_LESS 3.13)
set_target_properties(wavpack PROPERTIES LINK_FLAGS "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libwavpack.map';-Wl,-no-undefined")
else()
target_link_options(wavpack PRIVATE "-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/libwavpack.map;-Wl,-no-undefined")
endif()
endif()
endif()
set_target_properties(wavpack PROPERTIES PUBLIC_HEADER include/wavpack.h)
if(WAVPACK_BUILD_PROGRAMS)
add_executable(wavpackapp
cli/wavpack.c
cli/riff.c
cli/wave64.c
cli/caff.c
cli/dsdiff.c
cli/dsf.c
cli/utils.c
cli/md5.c
cli/import_id3.c
$<$<BOOL:${WIN32}>:cli/win32_unicode_support.h>
$<$<BOOL:${WIN32}>:cli/win32_unicode_support.c>
)
target_compile_definitions(wavpackapp
PRIVATE
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
"PACKAGE_VERSION=\"${PROJECT_VERSION}\""
"VERSION_OS=\"${CMAKE_SYSTEM_NAME}\""
)
set_target_properties(wavpackapp PROPERTIES OUTPUT_NAME wavpack)
target_link_libraries(wavpackapp
PRIVATE
wavpack
Iconv::Iconv
$<$<BOOL:${HAVE_LIBM}>:m>
)
add_executable(wvunpack
cli/wvunpack.c
cli/riff_write.c
cli/wave64_write.c
cli/caff_write.c
cli/dsdiff_write.c
cli/dsf_write.c
cli/utils.c
cli/md5.c
$<$<BOOL:${WIN32}>:cli/win32_unicode_support.h>
$<$<BOOL:${WIN32}>:cli/win32_unicode_support.c>
)
target_compile_definitions(wvunpack
PRIVATE
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
"PACKAGE_VERSION=\"${PROJECT_VERSION}\""
"VERSION_OS=\"${CMAKE_SYSTEM_NAME}\""
)
set_target_properties(wvunpack PROPERTIES OUTPUT_NAME wvunpack)
target_link_libraries(wvunpack
PRIVATE
wavpack
Iconv::Iconv
$<$<BOOL:${HAVE_LIBM}>:m>
)
add_executable(wvgain
cli/wvgain.c
cli/utils.h
cli/utils.c
$<$<BOOL:${WIN32}>:cli/win32_unicode_support.h>
$<$<BOOL:${WIN32}>:cli/win32_unicode_support.c>
)
target_compile_definitions(wvgain
PRIVATE
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
"PACKAGE_VERSION=\"${PROJECT_VERSION}\""
"VERSION_OS=\"${CMAKE_SYSTEM_NAME}\""
)
set_target_properties(wvgain PROPERTIES OUTPUT_NAME wvgain)
target_link_libraries(wvgain
PRIVATE
wavpack
$<$<BOOL:${HAVE_LIBM}>:m>
)
add_executable(wvtag
cli/wvtag.c
cli/utils.c
cli/import_id3.c
$<$<BOOL:${WIN32}>:cli/win32_unicode_support.h>
$<$<BOOL:${WIN32}>:cli/win32_unicode_support.c>
)
target_compile_definitions(wvtag
PRIVATE
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
"PACKAGE_VERSION=\"${PROJECT_VERSION}\""
"VERSION_OS=\"${CMAKE_SYSTEM_NAME}\""
)
target_link_libraries(wvtag
PRIVATE
wavpack
Iconv::Iconv
$<$<BOOL:${HAVE_LIBM}>:m>
)
endif()
if(WAVPACK_BUILD_COOLEDIT_PLUGIN)
set(WAVPACK_COOLEDIT_PLUGIN_EXPORT_SYMBOLS
QueryCoolFilter
FilterUnderstandsFormat
GetSuggestedSampleType
OpenFilterInput
FilterGetFileSize
ReadFilterInput
CloseFilterInput
FilterOptions
FilterOptionsString
OpenFilterOutput
CloseFilterOutput
WriteFilterOutput
FilterGetOptions
FilterWriteSpecialData
FilterGetFirstSpecialData
FilterGetNextSpecialData
)
set(FILE_CONTENTS "EXPORTS\n")
foreach(EXPORT_SYMBOL ${WAVPACK_COOLEDIT_PLUGIN_EXPORT_SYMBOLS})
list(APPEND FILE_CONTENTS " ${EXPORT_SYMBOL}\n")
endforeach()
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/audition/cool_wv4.def ${FILE_CONTENTS})
add_library(cool_wv4 SHARED
audition/cool_wv4.c
audition/filters.h
audition/resource.h
audition/wavpack.rc
${CMAKE_CURRENT_BINARY_DIR}/audition/cool_wv4.def
)
target_compile_definitions(cool_wv4 PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>)
set_target_properties(cool_wv4 PROPERTIES
DEFINE_SYMBOL AUDITION_EXPORTS
SUFFIX ".flt"
PREFIX ""
)
target_link_libraries(cool_wv4 PRIVATE wavpack)
endif()
if(WAVPACK_BUILD_WINAMP_PLUGIN)
add_library(in_wv SHARED
winamp/in_wv.c
winamp/in2.h
winamp/out.h
winamp/resource.h
winamp/wasabi/wasabi.cpp
winamp/wasabi/wasabi.h
)
target_compile_definitions(in_wv PRIVATE $<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>)
set_target_properties(in_wv PROPERTIES DEFINE_SYMBOL WINAMP_EXPORTS)
target_link_libraries(in_wv PRIVATE wavpack)
add_library(in_wv_lang SHARED
winamp/wavpack.rc
)
target_link_libraries(in_wv_lang PRIVATE $<$<BOOL:${MSVC}>:-NOENTRY>)
set_target_properties(in_wv_lang PROPERTIES
RUNTIME_OUTPUT_NAME in_wv
PREFIX ""
SUFFIX ".lang"
)
endif()
set(WAVPACK_DOC_NAMES
wavpack
wvgain
wvunpack
wvtag
)
if(WAVPACK_BUILD_DOCS)
foreach(WAVPACK_DOC_NAME ${WAVPACK_DOC_NAMES})
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/man/${WAVPACK_DOC_NAME}.1
MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/man/${WAVPACK_DOC_NAME}.xml
COMMAND ${LIBXSLT_XSLTPROC_EXECUTABLE} -nonet --output ${CMAKE_CURRENT_BINARY_DIR}/man/${WAVPACK_DOC_NAME}.1 "http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl" ${CMAKE_CURRENT_SOURCE_DIR}/man/${WAVPACK_DOC_NAME}.xml
COMMENT "Generating MAN page '${WAVPACK_DOC_NAME}.1' from DocBook XML file ${WAVPACK_DOC_NAME}.xml..."
)
endforeach()
set(GENERATED_MANS_LIST "")
foreach(WAVPACK_DOC_NAME ${WAVPACK_DOC_NAMES})
list(APPEND GENERATED_MANS_LIST ${CMAKE_CURRENT_BINARY_DIR}/man/${WAVPACK_DOC_NAME}.1)
endforeach()
add_custom_target(GEN_DOCS ALL
DEPENDS ${GENERATED_MANS_LIST}
)
endif()
# Features
set_package_properties(OpenSSL PROPERTIES
TYPE RECOMMENDED
DESCRIPTION "TLS/SSL and crypto library"
PURPOSE "Can be used to build wavpack library."
)
set_package_properties(Iconv PROPERTIES
TYPE RECOMMENDED
DESCRIPTION "converts from one character encoding to another through Unicode conversion "
PURPOSE "Required to build programs."
)
set_package_properties(Threads PROPERTIES
TYPE OPTIONAL
DESCRIPTION "Threads library"
PURPOSE "Required to build tests."
)
set_package_properties(LibXslt PROPERTIES
TYPE OPTIONAL
DESCRIPTION " XSLT C library developed for the GNOME project."
PURPOSE "Required to generate documentation."
)
add_feature_info(BUILD_SHARED_LIBS BUILD_SHARED_LIBS "Build shared library.")
add_feature_info(BUILD_TESTING BUILD_TESTING "Build tests.")
add_feature_info(ENABLE_LEGACY WAVPACK_ENABLE_LEGACY "Decode legacy (< 4.0) WavPack files.")
add_feature_info(ENABLE_DSD WAVPACK_ENABLE_DSD "Enable support for WavPack DSD files.")
add_feature_info(INSTALL_CMAKE_MODULE WAVPACK_INSTALL_CMAKE_MODULE "Generate and install CMake package configuration module.")
add_feature_info(ENABLE_ASM WAVPACK_ENABLE_ASM "Enable assembly optimizations.")
add_feature_info(ENABLE_LIBCRYPTO WAVPACK_ENABLE_LIBCRYPTO "Use OpenSSL::Crypto library.")
add_feature_info(BUILD_PROGRAMS WAVPACK_BUILD_PROGRAMS "Build programs.")
add_feature_info(BUILD_COOLEDIT_PLUGIN WAVPACK_BUILD_COOLEDIT_PLUGIN "Build CoolEdit plugin.")
add_feature_info(BUILD_WINAMP_PLUGIN WAVPACK_BUILD_WINAMP_PLUGIN "Build WinAmp plugin.")
add_feature_info(BUILD_DOCS WAVPACK_BUILD_DOCS "Build documentation.")
add_feature_info(INSTALL_DOCS WAVPACK_INSTALL_DOCS "Install documentation.")
add_feature_info(INSTALL_PKGCONFIG_MODULE WAVPACK_INSTALL_PKGCONFIG_MODULE "Generate and install wavpack.pc.")
feature_summary(WHAT ALL)
# Installation
set(WAVPACK_INSTALL_TARGETS wavpack)
if(WAVPACK_BUILD_PROGRAMS)
list(APPEND WAVPACK_INSTALL_TARGETS wavpackapp wvunpack wvgain wvtag)
endif()
install(TARGETS ${WAVPACK_INSTALL_TARGETS}
EXPORT wavpack-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
if(WAVPACK_INSTALL_CMAKE_MODULE)
if(WIN32)
set(CMAKE_INSTALL_PACKAGEDIR cmake)
else()
set(CMAKE_INSTALL_PACKAGEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
endif()
if(CMAKE_VERSION VERSION_LESS 3.11)
write_basic_package_version_file(wavpack-config-version.cmake COMPATIBILITY SameMajorVersion)
else()
write_basic_package_version_file(wavpack-config-version.cmake COMPATIBILITY SameMinorVersion)
endif()
install(EXPORT wavpack-targets
FILE wavpack-config.cmake
NAMESPACE WavPack::
DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/wavpack-config-version.cmake
DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}
)
endif()
if(WAVPACK_INSTALL_PKGCONFIG_MODULE)
set (prefix ${CMAKE_INSTALL_PREFIX})
set (exec_prefix "\$\{prefix\}")
set (libdir "\$\{prefix\}/${CMAKE_INSTALL_LIBDIR}")
set (includedir "\$\{prefix\}/${CMAKE_INSTALL_INCLUDEDIR}")
set (PACKAGE_VERSION ${PROJECT_VERSION})
if (HAVE_LIBM)
set (LIBM "-lm")
endif ()
configure_file (wavpack.pc.in wavpack.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/wavpack.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
endif()
if(WAVPACK_INSTALL_DOCS)
set(MAN_FILES_INSTALL_LIST "")
if(WAVPACK_BUILD_DOCS)
foreach(WAVPACK_DOC_NAME ${WAVPACK_DOC_NAMES})
list(APPEND MAN_FILES_INSTALL_LIST ${CMAKE_CURRENT_BINARY_DIR}/man/${WAVPACK_DOC_NAME}.1)
endforeach()
else()
foreach(WAVPACK_DOC_NAME ${WAVPACK_DOC_NAMES})
list(APPEND MAN_FILES_INSTALL_LIST ${CMAKE_CURRENT_SOURCE_DIR}/man/${WAVPACK_DOC_NAME}.1)
endforeach()
endif()
install(
FILES ${MAN_FILES_INSTALL_LIST}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
)
endif()
# Tests
if(BUILD_TESTING AND (NOT WIN32))
enable_testing()
add_executable(wvtest
cli/wvtest.c
cli/md5.c
$<$<BOOL:${WIN32}>:cli/win32_unicode_support.h>
$<$<BOOL:${WIN32}>:cli/win32_unicode_support.c>
)
target_compile_definitions(wvtest
PRIVATE
"PACKAGE_VERSION=\"${PROJECT_VERSION}\""
"VERSION_OS=\"${CMAKE_SYSTEM_NAME}\"")
target_link_libraries(wvtest
PRIVATE
wavpack
Threads::Threads
$<$<BOOL:${HAVE_LIBM}>:m>
)
add_test(NAME wvtest COMMAND $<TARGET_FILE:wvtest> --exhaustive --short --no-extras)
endif()