1cmake_minimum_required (VERSION 3.1..3.18) 2 3# MSVC runtime library flags are selected by an abstraction, CMake >= 3.15 4# This policy still need to be set even with cmake_minimum_required() command above. 5if (POLICY CMP0091) 6 if ((DEFINED ENABLE_STATIC_RUNTIME) AND (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)) 7 message (FATAL_ERROR "Both ENABLE_STATIC_RUNTIME and CMAKE_MSVC_RUNTIME_LIBRARY are set.") 8 return () 9 endif () 10 11 if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY) 12 cmake_policy (SET CMP0091 NEW) 13 else () 14 cmake_policy (SET CMP0091 OLD) 15 endif () 16endif () 17 18option (ENABLE_EXTERNAL_LIBS "Enable FLAC, Vorbis, and Opus codecs" ON) 19if (ENABLE_EXTERNAL_LIBS) 20 list (APPEND VCPKG_MANIFEST_FEATURES "external-libs") 21endif () 22 23option (ENABLE_MPEG "Enable MPEG codecs" ON) 24if (ENABLE_MPEG) 25 list (APPEND VCPKG_MANIFEST_FEATURES "mpeg") 26endif () 27 28option (ENABLE_EXPERIMENTAL "Enable experimental code" OFF) 29if (ENABLE_EXPERIMENTAL) 30 list (APPEND VCPKG_MANIFEST_FEATURES "speex") 31endif () 32 33option (BUILD_REGTEST "Build regtest" OFF) 34if (BUILD_REGTEST) 35 list (APPEND VCPKG_MANIFEST_FEATURES "regtest") 36endif () 37 38project(libsndfile VERSION 1.2.0) 39 40# 41# Variables 42# 43 44set (CMAKE_C_STANDARD 99) 45set (CMAKE_C_STANDARD_REQUIRED TRUE) 46set_property(GLOBAL PROPERTY USE_FOLDERS ON) 47 48set (PACKAGE_NAME ${PROJECT_NAME}) 49set (CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) 50set (CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) 51set (CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) 52set (CPACK_PACKAGE_VERSION_STAGE "") 53set (CPACK_PACKAGE_VERSION_FULL "${PROJECT_VERSION}${CPACK_PACKAGE_VERSION_STAGE}") 54 55# 56# System-wide includes 57# 58 59include (GNUInstallDirs) 60include (FeatureSummary) 61include (CMakeDependentOption) 62include (CTest) 63include (CheckCCompilerFlag) 64 65# 66# Options 67# 68 69option (BUILD_SHARED_LIBS "Build shared libraries" OFF) 70if (BUILD_SHARED_LIBS AND BUILD_TESTING) 71 set (BUILD_TESTING OFF) 72 message ("Build testing required static libraries. To prevent build errors BUILD_TESTING disabled.") 73endif () 74option (BUILD_PROGRAMS "Build programs" ON) 75option (BUILD_EXAMPLES "Build examples" ON) 76option (ENABLE_CPACK "Enable CPack support" ON) 77option (ENABLE_BOW_DOCS "Enable black-on-white html docs" OFF) 78if (MSVC AND (DEFINED ENABLE_STATIC_RUNTIME)) 79 option (ENABLE_STATIC_RUNTIME "Enable static runtime" ${ENABLE_STATIC_RUNTIME}) 80elseif (MINGW) 81 option (ENABLE_STATIC_RUNTIME "Enable static runtime" OFF) 82endif () 83option (ENABLE_PACKAGE_CONFIG "Generate and install package config file" ON) 84option (INSTALL_PKGCONFIG_MODULE "Generate and install pkg-config module" ON) 85 86list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 87if (CMAKE_VERSION VERSION_LESS 3.14) 88 list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sqlite") 89endif () 90 91# 92# Setup definitions 93# 94 95include(SndFileChecks) 96 97if (ENABLE_EXTERNAL_LIBS AND NOT (Vorbis_FOUND OR FLAC_FOUND OR OPUS_FOUND)) 98 set (ENABLE_EXTERNAL_LIBS OFF) 99endif() 100if(ENABLE_MPEG AND (NOT HAVE_MPEG_LIBS)) 101 set (ENABLE_MPEG OFF) 102endif() 103if (BUILD_REGTEST AND (NOT SQLITE3_FOUND)) 104 set (BUILD_REGTEST OFF) 105endif() 106 107cmake_dependent_option (ENABLE_CPU_CLIP "Enable tricky cpu specific clipper" ON "CPU_CLIPS_POSITIVE;CPU_CLIPS_NEGATIVE" OFF) 108if (NOT ENABLE_CPU_CLIP) 109 set (CPU_CLIPS_POSITIVE FALSE) 110 set (CPU_CLIPS_NEGATIVE FALSE) 111endif () 112cmake_dependent_option (ENABLE_COMPATIBLE_LIBSNDFILE_NAME "Set DLL name to libsndfile-1.dll (canonical name), sndfile.dll otherwise" OFF "WIN32;BUILD_SHARED_LIBS" OFF) 113cmake_dependent_option (INSTALL_MANPAGES "Install man pages for programs" ON "BUILD_PROGRAMS" OFF) 114 115if (NOT MSVC) 116 if (CPU_IS_X86) 117 check_c_compiler_flag (-msse2 HAVE_MSSE2_COMPILER_FLAG) 118 if (HAVE_MSSE2_COMPILER_FLAG) 119 cmake_dependent_option (ENABLE_SSE2 "Add SSE2 compiler flag" ON "HAVE_MSSE2_COMPILER_FLAG" OFF) 120 endif () 121 endif () 122endif () 123if (ENABLE_SSE2) 124 add_compile_options (-msse2) 125endif () 126 127set (HAVE_EXTERNAL_XIPH_LIBS ${ENABLE_EXTERNAL_LIBS}) 128set (HAVE_SQLITE3 ${BUILD_REGTEST}) 129set (HAVE_ALSA_ASOUNDLIB_H ${ALSA_FOUND}) 130set (HAVE_SNDIO_H ${SNDIO_FOUND}) 131 132set (ENABLE_EXPERIMENTAL_CODE ${ENABLE_EXPERIMENTAL}) 133set (HAVE_MPEG ${ENABLE_MPEG}) 134set (HAVE_SPEEX ${ENABLE_EXPERIMENTAL}) 135 136add_feature_info (BUILD_SHARED_LIBS BUILD_SHARED_LIBS "build shared libraries") 137add_feature_info (ENABLE_EXTERNAL_LIBS ENABLE_EXTERNAL_LIBS "enable FLAC, Vorbis, and Opus codecs") 138add_feature_info (ENABLE_MPEG ENABLE_MPEG "enable MPEG audio (including mp3) codecs") 139add_feature_info (ENABLE_EXPERIMENTAL ENABLE_EXPERIMENTAL "enable experimental code") 140add_feature_info (BUILD_TESTING BUILD_TESTING "build tests") 141add_feature_info (BUILD_REGTEST BUILD_REGTEST "build regtest") 142add_feature_info (ENABLE_CPACK ENABLE_CPACK "enable CPack support") 143add_feature_info (ENABLE_CPU_CLIP ENABLE_CPU_CLIP "Enable tricky cpu specific clipper") 144add_feature_info (ENABLE_BOW_DOCS ENABLE_BOW_DOCS "enable black-on-white html docs") 145add_feature_info (ENABLE_PACKAGE_CONFIG ENABLE_PACKAGE_CONFIG "generate and install package config file") 146add_feature_info (INSTALL_PKGCONFIG_MODULE INSTALL_PKGCONFIG_MODULE "generate and install pkg-config module") 147add_feature_info (INSTALL_MANPAGES INSTALL_MANPAGES "install man pages for programs") 148if (WIN32 AND BUILD_SHARED_LIBS) 149 add_feature_info (ENABLE_COMPATIBLE_LIBSNDFILE_NAME ENABLE_COMPATIBLE_LIBSNDFILE_NAME "Set DLL name to libsndfile-1.dll (canonical name), sndfile.dll otherwise") 150endif () 151 152if (HAVE_MSSE2_COMPILER_FLAG) 153 add_feature_info (ENABLE_SSE2 ENABLE_SSE2 "add SSE2 compiler flag") 154endif () 155 156 157 158 159set_package_properties (Ogg PROPERTIES 160 TYPE RECOMMENDED 161 URL "www.xiph.org/ogg/" 162 DESCRIPTION "library for manipulating ogg bitstreams" 163 PURPOSE "Required to enable Vorbis, Speex, and Opus support" 164 ) 165set_package_properties (Vorbis PROPERTIES 166 TYPE RECOMMENDED 167 URL "www.vorbis.com/" 168 DESCRIPTION "open source lossy audio codec" 169 PURPOSE "Enables Vorbis support" 170 ) 171set_package_properties (FLAC PROPERTIES 172 TYPE RECOMMENDED 173 URL "www.xiph.org/flac/" 174 DESCRIPTION "Free Lossless Audio Codec Library" 175 PURPOSE "Enables FLAC support" 176 ) 177set_package_properties (mp3lame PROPERTIES 178 TYPE RECOMMENDED 179 URL "https://lame.sourceforge.io/" 180 DESCRIPTION "High quality MPEG Audio Layer III (MP3) encoder" 181 PURPOSE "Enables MPEG layer III (MP3) writing support" 182 ) 183set_package_properties (MPG123 PROPERTIES 184 TYPE RECOMMENDED 185 URL "https://www.mpg123.de/" 186 DESCRIPTION "MPEG Audio Layer I/II/III decoder" 187 PURPOSE "Enables MPEG Audio reading support" 188 ) 189set_package_properties(Opus PROPERTIES 190 TYPE RECOMMENDED 191 URL "www.opus-codec.org/" 192 DESCRIPTION "Standardized open source low-latency fullband codec" 193 PURPOSE "Enables experimental Opus support" 194 ) 195set_package_properties(Speex PROPERTIES TYPE OPTIONAL 196 URL "www.speex.org/" 197 DESCRIPTION "an audio codec tuned for speech" 198 PURPOSE "Enables experemental Speex support" 199 ) 200set_package_properties (SQLite3 PROPERTIES 201 TYPE OPTIONAL 202 URL "www.sqlite.org/" 203 DESCRIPTION "light weight SQL database engine." 204 PURPOSE "Enables regtest" 205 ) 206if (BUILD_SHARED_LIBS) 207 set_package_properties (PythonInterp PROPERTIES 208 TYPE REQUIRED 209 URL "www.python.org/" 210 DESCRIPTION "Python is a widely used high-level programming language." 211 PURPOSE "Required to build shared libraries" 212 ) 213endif() 214 215feature_summary (WHAT ALL) 216 217# 218# Setup configuration 219# 220 221configure_file (src/config.h.cmake src/config.h) 222 223if (INSTALL_PKGCONFIG_MODULE) 224 225 set (prefix ${CMAKE_INSTALL_PREFIX}) 226 set (exec_prefix "\$\{prefix\}") 227 set (libdir "\$\{prefix\}/${CMAKE_INSTALL_LIBDIR}") 228 set (includedir "\$\{prefix\}/${CMAKE_INSTALL_INCLUDEDIR}") 229 set (VERSION ${PROJECT_VERSION}) 230 if (ENABLE_EXTERNAL_LIBS) 231 set (EXTERNAL_XIPH_REQUIRE "flac ogg vorbis vorbisenc opus") 232 if (ENABLE_EXPERIMENTAL) 233 set (EXTERNAL_XIPH_REQUIRE "${EXTERNAL_XIPH_REQUIRE} speex") 234 endif () 235 endif () 236 if (ENABLE_MPEG) 237 set (EXTERNAL_MPEG_REQUIRE "libmpg123") 238 set (EXTERNAL_MPEG_LIBS "-lmp3lame") 239 endif () 240 241 configure_file (sndfile.pc.in sndfile.pc @ONLY) 242 243endif () 244 245# 246# libsndfile 247# 248 249# Public libsndfile headers 250set (sndfile_HDRS 251 include/sndfile.h 252 include/sndfile.hh 253 ) 254 255# 256# libsndfile static library 257# 258 259add_library (sndfile 260 src/sfconfig.h 261 src/sfendian.h 262 src/sf_unistd.h 263 src/common.h 264 src/common.c 265 src/file_io.c 266 src/command.c 267 src/pcm.c 268 src/ulaw.c 269 src/alaw.c 270 src/float32.c 271 src/double64.c 272 src/ima_adpcm.c 273 src/ms_adpcm.c 274 src/gsm610.c 275 src/dwvw.c 276 src/vox_adpcm.c 277 src/interleave.c 278 src/strings.c 279 src/dither.c 280 src/cart.c 281 src/broadcast.c 282 src/audio_detect.c 283 src/ima_oki_adpcm.c 284 src/ima_oki_adpcm.h 285 src/alac.c 286 src/chunk.c 287 src/ogg.h 288 src/ogg.c 289 src/chanmap.h 290 src/chanmap.c 291 src/id3.h 292 src/id3.c 293 $<$<BOOL:${WIN32}>:src/windows.c> 294 src/sndfile.c 295 src/aiff.c 296 src/au.c 297 src/avr.c 298 src/caf.c 299 src/dwd.c 300 src/flac.c 301 src/g72x.c 302 src/htk.c 303 src/ircam.c 304 src/macos.c 305 src/mat4.c 306 src/mat5.c 307 src/nist.c 308 src/paf.c 309 src/pvf.c 310 src/raw.c 311 src/rx2.c 312 src/sd2.c 313 src/sds.c 314 src/svx.c 315 src/txw.c 316 src/voc.c 317 src/wve.c 318 src/w64.c 319 src/wavlike.h 320 src/wavlike.c 321 src/wav.c 322 src/xi.c 323 src/mpc2k.c 324 src/rf64.c 325 src/ogg_vorbis.c 326 src/ogg_speex.c 327 src/ogg_pcm.c 328 src/ogg_opus.c 329 src/ogg_vcomment.h 330 src/ogg_vcomment.c 331 src/nms_adpcm.c 332 src/mpeg.c 333 src/mpeg_decode.c 334 src/mpeg_l3_encode.c 335 src/GSM610/config.h 336 src/GSM610/gsm.h 337 src/GSM610/gsm610_priv.h 338 src/GSM610/add.c 339 src/GSM610/code.c 340 src/GSM610/decode.c 341 src/GSM610/gsm_create.c 342 src/GSM610/gsm_decode.c 343 src/GSM610/gsm_destroy.c 344 src/GSM610/gsm_encode.c 345 src/GSM610/gsm_option.c 346 src/GSM610/long_term.c 347 src/GSM610/lpc.c 348 src/GSM610/preprocess.c 349 src/GSM610/rpe.c 350 src/GSM610/short_term.c 351 src/GSM610/table.c 352 src/G72x/g72x.h 353 src/G72x/g72x_priv.h 354 src/G72x/g721.c 355 src/G72x/g723_16.c 356 src/G72x/g723_24.c 357 src/G72x/g723_40.c 358 src/G72x/g72x.c 359 src/ALAC/ALACAudioTypes.h 360 src/ALAC/ALACBitUtilities.h 361 src/ALAC/EndianPortable.h 362 src/ALAC/aglib.h 363 src/ALAC/dplib.h 364 src/ALAC/matrixlib.h 365 src/ALAC/alac_codec.h 366 src/ALAC/shift.h 367 src/ALAC/ALACBitUtilities.c 368 src/ALAC/ag_dec.c 369 src/ALAC/ag_enc.c 370 src/ALAC/dp_dec.c 371 src/ALAC/dp_enc.c 372 src/ALAC/matrix_dec.c 373 src/ALAC/matrix_enc.c 374 src/ALAC/alac_decoder.c 375 src/ALAC/alac_encoder.c 376 ${sndfile_HDRS} 377 ${CMAKE_CURRENT_BINARY_DIR}/src/config.h 378 ) 379 380add_library (SndFile::sndfile ALIAS sndfile) 381 382target_include_directories (sndfile 383 PUBLIC 384 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> 385 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> 386 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> 387 PRIVATE 388 src 389 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src> 390 ) 391target_link_libraries (sndfile 392 PRIVATE 393 $<$<BOOL:${LIBM_REQUIRED}>:m> 394 $<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Vorbis::vorbisenc> 395 $<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:FLAC::FLAC> 396 $<$<AND:$<BOOL:${ENABLE_EXPERIMENTAL}>,$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>,$<BOOL:${HAVE_SPEEX}>>:Speex::Speex> 397 $<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Opus::opus> 398 $<$<BOOL:${HAVE_MPEG}>:MPG123::libmpg123> 399 $<$<BOOL:${HAVE_MPEG}>:mp3lame::mp3lame> 400 ) 401set_target_properties (sndfile PROPERTIES 402 PUBLIC_HEADER "${sndfile_HDRS}" 403 ) 404 405if (ENABLE_COMPATIBLE_LIBSNDFILE_NAME) 406 if (MINGW OR CYGWIN) 407 set_target_properties (sndfile PROPERTIES 408 RUNTIME_OUTPUT_NAME "sndfile-1" 409 ) 410 else () 411 set_target_properties (sndfile PROPERTIES 412 RUNTIME_OUTPUT_NAME "libsndfile-1" 413 ) 414 endif () 415endif () 416 417if (BUILD_SHARED_LIBS) 418 419 # 420 # ABI version of library. 421 # 422 423 # 424 # Read libtool version from `configure.ac` and set libsndfile ABI version: 425 # 426 # SNDFILE_ABI_VERSION_MAJOR 427 # SNDFILE_ABI_VERSION_MINOR 428 # SNDFILE_ABI_VERSION_PATCH 429 # SNDFILE_ABI_VERSION 430 # 431 # and Mach-O current and compatibility versions: 432 # 433 # SNDFILE_MACHO_CURRENT_VERSION 434 # SNDFILE_MACHO_COMPATIBILITY_VERSION 435 # 436 437 include (SetupABIVersions) 438 439 setup_abi_versions() 440 441 if (WIN32) 442 set (VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR}) 443 set (GEN_TOOL cmake) 444 445 set (WIN_RC_VERSION "${CPACK_PACKAGE_VERSION_MAJOR},${CPACK_PACKAGE_VERSION_MINOR},${CPACK_PACKAGE_VERSION_PATCH}") 446 set (CLEAN_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") 447 set (PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}) 448 449 configure_file (src/version-metadata.rc.in src/version-metadata.rc @ONLY) 450 target_sources (sndfile PRIVATE ${PROJECT_BINARY_DIR}/src/version-metadata.rc) 451 endif () 452 453 454 set_target_properties (sndfile PROPERTIES 455 SOVERSION ${SNDFILE_ABI_VERSION_MAJOR} 456 VERSION ${SNDFILE_ABI_VERSION} 457 ) 458 459 if (APPLE) 460 if (NOT (CMAKE_VERSION VERSION_LESS 3.17)) 461 set_target_properties (sndfile PROPERTIES 462 MACHO_CURRENT_VERSION ${SNDFILE_MACHO_CURRENT_VERSION} 463 MACHO_COMPATIBILITY_VERSION ${SNDFILE_MACHO_COMPATIBILITY_VERSION} 464 ) 465 else () 466 message (FATAL_ERROR "Apple platform requires cmake >= 3.17 to build dylib.") 467 endif () 468 endif () 469 470 # Symbol files generation 471 472 if (WIN32) 473 set (SYMBOL_FILENAME "sndfile.def") 474 set (SYMBOL_OS "win32") 475 elseif ((CMAKE_SYSTEM_NAME MATCHES "Darwin") OR (CMAKE_SYSTEM_NAME MATCHES "Rhapsody")) 476 set (SYMBOL_FILENAME "Symbols.darwin") 477 set (SYMBOL_OS "darwin") 478 elseif (CMAKE_SYSTEM_NAME MATCHES "OS2") 479 set (SYMBOL_FILENAME "Symbols.os2") 480 set (SYMBOL_OS "os2") 481 elseif (UNIX) 482 set (SYMBOL_FILENAME "Symbols.gnu-binutils") 483 set (SYMBOL_OS "linux") 484 endif () 485 486 if (DEFINED SYMBOL_OS) 487 add_custom_command ( 488 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME} 489 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/create_symbols_file.py ${SYMBOL_OS} ${SNDFILE_ABI_VERSION} > ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME} 490 COMMENT "Generating ${SYMBOL_FILENAME}..." 491 ) 492 493 add_custom_target (GENFILES DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}) 494 if (SYMBOL_OS MATCHES "win32") 495 target_sources (sndfile 496 PRIVATE 497 ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME} 498 ) 499 elseif (SYMBOL_OS MATCHES "darwin") 500 add_dependencies (sndfile GENFILES) 501 if (CMAKE_VERSION VERSION_LESS 3.13) 502 set_property (TARGET sndfile APPEND_STRING PROPERTY 503 LINK_FLAGS "-Wl,-exported_symbols_list -Wl,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}" 504 ) 505 else () 506 target_link_options (sndfile PRIVATE "LINKER:-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}") 507 endif() 508 elseif (SYMBOL_OS MATCHES "os") 509 add_dependencies (sndfile GENFILES) 510 if (CMAKE_VERSION VERSION_LESS 3.13) 511 set_property (TARGET sndfile APPEND_STRING PROPERTY 512 LINK_FLAGS "-Wl,-export-symbols ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}" 513 ) 514 else () 515 target_link_options (sndfile PRIVATE "LINKER:-export-symbols ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}") 516 endif() 517 elseif (UNIX) 518 add_dependencies (sndfile GENFILES) 519 if (CMAKE_VERSION VERSION_LESS 3.13) 520 set_property (TARGET sndfile APPEND_STRING PROPERTY 521 LINK_FLAGS "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}" 522 ) 523 else () 524 target_link_options (sndfile PRIVATE "LINKER:--version-script,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}") 525 endif() 526 endif() 527 endif() 528 529endif () 530 531# 532# Programs 533# 534 535if (BUILD_PROGRAMS) 536 537# sndfile-info 538 539 add_executable (sndfile-info 540 programs/sndfile-info.c 541 programs/common.c 542 programs/common.h 543 ) 544 target_link_libraries (sndfile-info 545 PRIVATE 546 sndfile 547 $<$<BOOL:${LIBM_REQUIRED}>:m> 548 ) 549 550# sndfile-play 551 552 add_executable (sndfile-play 553 $<$<NOT:$<BOOL:${BEOS}>>:programs/sndfile-play.c> 554 $<$<NOT:$<BOOL:${BEOS}>>:programs/common.c> 555 $<$<NOT:$<BOOL:${BEOS}>>:programs/sndfile-play.c> 556 $<$<BOOL:${BEOS}>:programs/sndfile-play-beos.cpp> 557 ) 558 target_include_directories (sndfile-play 559 PRIVATE 560 src 561 ${CMAKE_CURRENT_BINARY_DIR}/src 562 ) 563 target_link_libraries (sndfile-play PRIVATE $<$<BOOL:${LIBM_REQUIRED}>:m>) 564 target_link_libraries (sndfile-play PRIVATE sndfile) 565 if (WIN32) 566 target_link_libraries(sndfile-play PRIVATE winmm) 567 # Maybe ALSA & Sndio are present in BeOS. They are not required 568 # so skip them anyway. 569 elseif ((NOT BEOS) AND ALSA_FOUND) 570 target_include_directories (sndfile-play PRIVATE ${ALSA_INCLUDE_DIRS}) 571 target_link_libraries (sndfile-play PRIVATE ${ALSA_LIBRARIES}) 572 elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD") 573 target_link_libraries (sndfile-play PRIVATE Sndio::Sndio) 574 endif () 575 576# sndfile-convert 577 578 add_executable (sndfile-convert 579 programs/sndfile-convert.c 580 programs/common.c 581 programs/common.h 582 ) 583 target_link_libraries (sndfile-convert PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>) 584 585# sndfile-cmp 586 587 add_executable (sndfile-cmp 588 programs/sndfile-cmp.c 589 programs/common.c 590 programs/common.h 591 ) 592 target_include_directories (sndfile-cmp 593 PUBLIC 594 src 595 ${CMAKE_CURRENT_BINARY_DIR}/src 596 ${CMAKE_CURRENT_BINARY_DIR}/tests 597 ) 598 target_link_libraries (sndfile-cmp PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>) 599 600# sndfile-metadata-set 601 602 add_executable (sndfile-metadata-set 603 programs/sndfile-metadata-set.c 604 programs/common.c 605 programs/common.h 606 ) 607 target_include_directories (sndfile-metadata-set 608 PUBLIC 609 src 610 ${CMAKE_CURRENT_BINARY_DIR}/src 611 ${CMAKE_CURRENT_BINARY_DIR}/tests 612 ) 613 target_link_libraries (sndfile-metadata-set PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>) 614 615# sndfile-metadata-get 616 617 add_executable (sndfile-metadata-get 618 programs/sndfile-metadata-get.c 619 programs/common.c 620 programs/common.h 621 ) 622 target_include_directories (sndfile-metadata-get 623 PUBLIC 624 src 625 ${CMAKE_CURRENT_BINARY_DIR}/src 626 ${CMAKE_CURRENT_BINARY_DIR}/tests 627 ) 628 target_link_libraries (sndfile-metadata-get PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>) 629 630# sndfile-interleave 631 632 add_executable (sndfile-interleave 633 programs/sndfile-interleave.c 634 programs/common.c 635 programs/common.h 636 ) 637 target_link_libraries (sndfile-interleave PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>) 638 639# sndfile-deinterleave 640 641 add_executable (sndfile-deinterleave 642 programs/sndfile-deinterleave.c 643 programs/common.c 644 programs/common.h 645 ) 646 target_link_libraries (sndfile-deinterleave PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>) 647 648# sndfile-concat 649 650 add_executable (sndfile-concat 651 programs/sndfile-concat.c 652 programs/common.c 653 programs/common.h 654 ) 655 target_link_libraries (sndfile-concat PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>) 656 657# sndfile-salvage 658 659 add_executable (sndfile-salvage 660 programs/sndfile-salvage.c 661 programs/common.c 662 programs/common.h 663 ) 664 target_include_directories (sndfile-salvage 665 PUBLIC 666 src 667 ${CMAKE_CURRENT_BINARY_DIR}/src 668 ${CMAKE_CURRENT_BINARY_DIR}/tests 669 ) 670 target_link_libraries (sndfile-salvage PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>) 671 672 set (SNDFILE_PROGRAM_TARGETS 673 sndfile-info 674 sndfile-play 675 sndfile-convert 676 sndfile-cmp 677 sndfile-metadata-set 678 sndfile-metadata-get 679 sndfile-interleave 680 sndfile-deinterleave 681 sndfile-concat 682 sndfile-salvage 683 ) 684 685 set_target_properties(${SNDFILE_PROGRAM_TARGETS} PROPERTIES FOLDER Programs) 686 687endif () 688 689# 690# Examples 691# 692 693if (BUILD_EXAMPLES) 694 695# sndfile-to-text 696 697 add_executable (sndfile-to-text examples/sndfile-to-text.c) 698 target_link_libraries (sndfile-to-text PRIVATE sndfile) 699 700# sndfile-loopify 701 702 add_executable (sndfile-loopify examples/sndfile-loopify.c) 703 target_link_libraries (sndfile-loopify PRIVATE sndfile) 704 705# make_sine 706 707 add_executable (make_sine examples/make_sine.c) 708 target_link_libraries (make_sine 709 PRIVATE 710 sndfile 711 $<$<BOOL:${LIBM_REQUIRED}>:m> 712 ) 713 714# sfprocess 715 716 add_executable (sfprocess examples/sfprocess.c) 717 target_link_libraries (sfprocess 718 PRIVATE 719 sndfile 720 $<$<BOOL:${LIBM_REQUIRED}>:m> 721 ) 722 723# list_formats 724 725 add_executable (list_formats examples/list_formats.c) 726 target_link_libraries (list_formats 727 PRIVATE 728 sndfile 729 $<$<BOOL:${LIBM_REQUIRED}>:m> 730 ) 731 732# generate 733 734 add_executable (generate examples/generate.c) 735 target_link_libraries (generate PRIVATE sndfile) 736 737# sndfilehandle 738 739 add_executable (sndfilehandle examples/sndfilehandle.cc) 740 target_link_libraries (sndfilehandle PUBLIC sndfile) 741 742 set (SNDFILE_EXAMPLE_TARGETS 743 sndfile-to-text 744 sndfile-loopify 745 make_sine 746 sfprocess 747 list_formats 748 generate 749 sndfilehandle 750 ) 751 752 set_target_properties(${SNDFILE_EXAMPLE_TARGETS} PROPERTIES FOLDER Examples) 753 754 755endif () 756 757# 758# sndfile-regtest 759# 760 761if (BUILD_REGTEST) 762 763 add_executable (sndfile-regtest 764 regtest/sndfile-regtest.c 765 regtest/database.c 766 regtest/checksum.c 767 ) 768 target_include_directories (sndfile-regtest 769 PUBLIC 770 src 771 ${CMAKE_CURRENT_BINARY_DIR}/src 772 ${CMAKE_CURRENT_BINARY_DIR}/tests 773 ) 774 target_link_libraries(sndfile-regtest 775 PRIVATE 776 sndfile 777 SQLite::SQLite3 778 $<$<BOOL:${LIBM_REQUIRED}>:m> 779 ) 780 781endif () 782 783# 784# Installation 785# 786 787if (ENABLE_PACKAGE_CONFIG) 788 789 if (WIN32 AND (NOT MINGW) AND (NOT CYGWIN)) 790 set (CMAKE_INSTALL_PACKAGEDIR cmake) 791 else () 792 set (CMAKE_INSTALL_PACKAGEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/SndFile) 793 endif() 794 795 install (TARGETS ${SNDFILE_PROGRAM_TARGETS} 796 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 797 ) 798 799 install (TARGETS sndfile 800 EXPORT SndFileTargets 801 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 802 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 803 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 804 PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 805 ) 806 807 export (EXPORT SndFileTargets NAMESPACE SndFile:: FILE ${PROJECT_BINARY_DIR}/SndFileTargets.cmake) 808 809 include (CMakePackageConfigHelpers) 810 811 if (ENABLE_EXTERNAL_LIBS) 812 set (SndFile_WITH_EXTERNAL_LIBS 1) 813 else () 814 set (SndFile_WITH_EXTERNAL_LIBS 0) 815 endif () 816 817 if(ENABLE_MPEG) 818 set (SndFile_WITH_MPEG 1) 819 else () 820 set (SndFile_WITH_MPEG 0) 821 endif () 822 823 set (INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) 824 configure_package_config_file(cmake/SndFileConfig.cmake.in SndFileConfig.cmake 825 INSTALL_DESTINATION ${PROJECT_BINARY_DIR} 826 INSTALL_PREFIX ${PROJECT_BINARY_DIR} 827 PATH_VARS INCLUDE_INSTALL_DIR 828 ) 829 configure_package_config_file(cmake/SndFileConfig.cmake.in SndFileConfig2.cmake 830 INSTALL_DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} 831 PATH_VARS INCLUDE_INSTALL_DIR 832 ) 833 write_basic_package_version_file (SndFileConfigVersion.cmake COMPATIBILITY SameMajorVersion) 834 835 install(EXPORT SndFileTargets 836 NAMESPACE SndFile:: 837 DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} 838 ) 839 install( 840 FILES ${CMAKE_CURRENT_BINARY_DIR}/SndFileConfig2.cmake 841 RENAME SndFileConfig.cmake 842 DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} 843 ) 844 install( 845 FILES 846 ${CMAKE_CURRENT_BINARY_DIR}/SndFileConfigVersion.cmake 847 DESTINATION ${CMAKE_INSTALL_PACKAGEDIR} 848 ) 849 850else () 851 852 install (TARGETS sndfile ${sdnfile_PROGRAMS} 853 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 854 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 855 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 856 PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 857 858endif () 859 860if (INSTALL_MANPAGES) 861 862 set (man_MANS 863 man/sndfile-info.1 864 man/sndfile-play.1 865 man/sndfile-convert.1 866 man/sndfile-cmp.1 867 man/sndfile-metadata-get.1 868 man/sndfile-concat.1 869 man/sndfile-interleave.1 870 man/sndfile-salvage.1 871 ) 872 install (FILES ${man_MANS} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) 873 install (FILES man/sndfile-metadata-get.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME sndfile-metadata-set.1) 874 install (FILES man/sndfile-interleave.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME sndfile-deinterleave.1) 875endif () 876 877if (ENABLE_BOW_DOCS) 878 set (HTML_BGCOLOUR "white") 879 set (HTML_FGCOLOUR "black") 880else () 881 set (HTML_BGCOLOUR "black") 882 set (HTML_FGCOLOUR "white") 883endif () 884set (dist_doc_DATA 885 docs/index.md 886 docs/libsndfile.jpg 887 docs/libsndfile.css 888 docs/print.css 889 docs/api.md 890 docs/command.md 891 docs/bugs.md 892 docs/formats.md 893 docs/sndfile_info.md 894 docs/new_file_type_howto.md 895 docs/win32.md 896 docs/FAQ.md 897 docs/lists.md 898 docs/embedded_files.md 899 docs/octave.md 900 docs/tutorial.md 901 ) 902install (FILES ${dist_doc_DATA} DESTINATION ${CMAKE_INSTALL_DOCDIR}) 903 904if (INSTALL_PKGCONFIG_MODULE) 905 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/sndfile.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 906endif () 907 908# 909# Testing 910# 911 912if (BUILD_TESTING) 913 914 enable_testing () 915 916 include (CMakeAutoGen) 917 918 # generate tests sources from autogen templates 919 lsf_autogen (tests benchmark c) 920 lsf_autogen (tests floating_point_test c) 921 lsf_autogen (tests header_test c) 922 lsf_autogen (tests pcm_test c) 923 lsf_autogen (tests pipe_test c) 924 lsf_autogen (tests rdwr_test c) 925 lsf_autogen (tests scale_clip_test c) 926 lsf_autogen (tests utils c h) 927 lsf_autogen (tests write_read_test c) 928 lsf_autogen (src test_endswap c) 929 930 # utils static library 931 add_library(test_utils STATIC tests/utils.c) 932 target_include_directories (test_utils 933 PUBLIC 934 src 935 ${CMAKE_CURRENT_BINARY_DIR}/src 936 ${CMAKE_CURRENT_BINARY_DIR}/tests 937 ) 938 target_link_libraries(test_utils PRIVATE sndfile) 939 940 ### test_main 941 942 add_executable (test_main 943 src/test_main.c 944 src/test_main.h 945 src/test_conversions.c 946 src/test_float.c 947 src/test_endswap.c 948 src/test_audio_detect.c 949 src/test_log_printf.c 950 src/test_file_io.c 951 src/test_ima_oki_adpcm.c 952 src/test_strncpy_crlf.c 953 src/test_broadcast_var.c 954 src/test_cart_var.c 955 src/test_binheader_writef.c 956 src/test_nms_adpcm.c 957 ) 958 target_include_directories (test_main 959 PUBLIC 960 src 961 ${CMAKE_CURRENT_BINARY_DIR}/src 962 ${CMAKE_CURRENT_BINARY_DIR}/tests 963 ) 964 target_link_libraries (test_main PRIVATE sndfile) 965 if (MSVC) 966 target_compile_definitions (test_main PRIVATE _USE_MATH_DEFINES) 967 endif () 968 add_test (test_main test_main) 969 970 ### sfversion_test 971 972 add_executable (sfversion tests/sfversion.c) 973 target_include_directories (sfversion 974 PRIVATE 975 src 976 ${CMAKE_CURRENT_BINARY_DIR}/src 977 ) 978 target_link_libraries (sfversion sndfile) 979 add_test (sfversion sfversion) 980 set_tests_properties (sfversion PROPERTIES 981 PASS_REGULAR_EXPRESSION "${PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_FULL}" 982 ) 983 984 ### error_test 985 986 add_executable (error_test tests/error_test.c) 987 target_link_libraries (error_test 988 PRIVATE 989 sndfile 990 test_utils 991 $<$<BOOL:${LIBM_REQUIRED}>:m> 992 ) 993 add_test (error_test error_test) 994 995 ### ulaw_test 996 add_executable (ulaw_test tests/ulaw_test.c) 997 target_link_libraries (ulaw_test 998 PRIVATE 999 sndfile 1000 test_utils 1001 $<$<BOOL:${LIBM_REQUIRED}>:m> 1002 ) 1003 add_test (ulaw_test ulaw_test) 1004 1005 ### alaw_test 1006 add_executable (alaw_test tests/alaw_test.c) 1007 target_link_libraries (alaw_test 1008 PRIVATE 1009 sndfile 1010 test_utils 1011 $<$<BOOL:${LIBM_REQUIRED}>:m> 1012 ) 1013 add_test (alaw_test alaw_test) 1014 1015 ### dwvw_test 1016 1017 add_executable (dwvw_test tests/dwvw_test.c) 1018 target_link_libraries (dwvw_test 1019 PRIVATE 1020 sndfile 1021 test_utils 1022 $<$<BOOL:${LIBM_REQUIRED}>:m> 1023 ) 1024 add_test (dwvw_test dwvw_test) 1025 1026 ### command_test 1027 1028 add_executable (command_test tests/command_test.c) 1029 target_link_libraries (command_test 1030 PRIVATE 1031 sndfile 1032 test_utils 1033 $<$<BOOL:${LIBM_REQUIRED}>:m> 1034 ) 1035 add_test (command_test command_test all) 1036 1037 ### floating_point_test 1038 1039 add_executable (floating_point_test 1040 tests/dft_cmp.c 1041 tests/floating_point_test.c 1042 ) 1043 target_link_libraries (floating_point_test 1044 PRIVATE 1045 sndfile 1046 test_utils 1047 $<$<BOOL:${LIBM_REQUIRED}>:m> 1048 ) 1049 target_include_directories (floating_point_test PRIVATE tests) 1050 add_test (floating_point_test floating_point_test) 1051 1052 ### checksum_test 1053 1054 add_executable (checksum_test tests/checksum_test.c) 1055 target_link_libraries (checksum_test 1056 PRIVATE 1057 sndfile 1058 test_utils 1059 $<$<BOOL:${LIBM_REQUIRED}>:m> 1060 ) 1061 add_test (checksum_test checksum_test) 1062 1063 ### scale_clip_test 1064 1065 add_executable (scale_clip_test tests/scale_clip_test.c) 1066 target_link_libraries (scale_clip_test 1067 PRIVATE 1068 sndfile 1069 test_utils 1070 $<$<BOOL:${LIBM_REQUIRED}>:m> 1071 ) 1072 add_test (scale_clip_test scale_clip_test) 1073 1074 ### headerless_test 1075 1076 add_executable (headerless_test tests/headerless_test.c) 1077 target_link_libraries (headerless_test 1078 PRIVATE 1079 sndfile 1080 test_utils 1081 $<$<BOOL:${LIBM_REQUIRED}>:m> 1082 ) 1083 add_test (headerless_test headerless_test) 1084 1085 ### rdwr_test 1086 1087 add_executable (rdwr_test tests/rdwr_test.c) 1088 target_link_libraries (rdwr_test 1089 PRIVATE 1090 sndfile 1091 test_utils 1092 $<$<BOOL:${LIBM_REQUIRED}>:m> 1093 ) 1094 add_test (rdwr_test rdwr_test) 1095 1096 ### locale_test 1097 1098 add_executable (locale_test tests/locale_test.c) 1099 target_link_libraries (locale_test 1100 PRIVATE 1101 sndfile 1102 test_utils 1103 $<$<BOOL:${LIBM_REQUIRED}>:m> 1104 ) 1105 add_test (locale_test locale_test) 1106 1107 ### win32_ordinal_test 1108 1109# Disabled because we cannot test with shared sndfile library 1110# if (WIN32 AND BUILD_SHARED_LIBS) 1111# add_executable (win32_ordinal_test tests/win32_ordinal_test.c) 1112# target_link_libraries (win32_ordinal_test PRIVATE sndfile test_utils) 1113# add_test (win32_ordinal_test win32_ordinal_test) 1114# endif () 1115 1116 ### cpp_test 1117 1118 add_executable (cpp_test tests/cpp_test.cc) 1119 target_link_libraries (cpp_test 1120 PRIVATE 1121 sndfile 1122 test_utils 1123 $<$<BOOL:${LIBM_REQUIRED}>:m> 1124 ) 1125 add_test (cpp_test cpp_test) 1126 1127 ### external_libs_test 1128 1129 add_executable (external_libs_test tests/external_libs_test.c) 1130 target_link_libraries (external_libs_test 1131 PRIVATE 1132 sndfile 1133 test_utils 1134 $<$<BOOL:${LIBM_REQUIRED}>:m> 1135 ) 1136 add_test (external_libs_test external_libs_test) 1137 1138 ### format_check_test 1139 1140 add_executable (format_check_test tests/format_check_test.c) 1141 target_link_libraries (format_check_test 1142 PRIVATE 1143 sndfile 1144 test_utils 1145 $<$<BOOL:${LIBM_REQUIRED}>:m> 1146 ) 1147 add_test (format_check_test format_check_test) 1148 1149 ### channel_test 1150 1151 add_executable (channel_test tests/channel_test.c) 1152 target_link_libraries (channel_test 1153 PRIVATE 1154 sndfile 1155 test_utils 1156 $<$<BOOL:${LIBM_REQUIRED}>:m> 1157 ) 1158 add_test (channel_test channel_test) 1159 1160 ### pcm_test 1161 1162 add_executable (pcm_test tests/pcm_test.c) 1163 target_link_libraries (pcm_test 1164 PRIVATE 1165 sndfile 1166 test_utils 1167 $<$<BOOL:${LIBM_REQUIRED}>:m> 1168 ) 1169 add_test (pcm_test pcm_test) 1170 1171 ### common test executables 1172 1173 add_executable (write_read_test 1174 tests/generate.c 1175 tests/write_read_test.c 1176 ) 1177 target_link_libraries (write_read_test 1178 PRIVATE 1179 sndfile 1180 test_utils 1181 $<$<BOOL:${LIBM_REQUIRED}>:m> 1182 ) 1183 target_include_directories (write_read_test PRIVATE tests) 1184 1185 add_executable (lossy_comp_test tests/lossy_comp_test.c) 1186 target_link_libraries (lossy_comp_test 1187 PRIVATE 1188 sndfile 1189 test_utils 1190 $<$<BOOL:${LIBM_REQUIRED}>:m> 1191 ) 1192 1193 add_executable (peak_chunk_test tests/peak_chunk_test.c) 1194 target_link_libraries (peak_chunk_test 1195 PRIVATE 1196 sndfile 1197 test_utils 1198 $<$<BOOL:${LIBM_REQUIRED}>:m> 1199 ) 1200 1201 add_executable (header_test tests/header_test.c) 1202 target_link_libraries (header_test 1203 PRIVATE 1204 sndfile 1205 test_utils 1206 $<$<BOOL:${LIBM_REQUIRED}>:m> 1207 ) 1208 1209 add_executable (misc_test tests/misc_test.c) 1210 target_link_libraries (misc_test 1211 PRIVATE 1212 sndfile 1213 test_utils 1214 $<$<BOOL:${LIBM_REQUIRED}>:m> 1215 ) 1216 1217 add_executable (string_test tests/string_test.c) 1218 target_link_libraries (string_test 1219 PRIVATE 1220 sndfile 1221 test_utils 1222 $<$<BOOL:${LIBM_REQUIRED}>:m> 1223 ) 1224 1225 add_executable (multi_file_test tests/multi_file_test.c) 1226 target_link_libraries (multi_file_test 1227 PRIVATE 1228 sndfile 1229 test_utils 1230 $<$<BOOL:${LIBM_REQUIRED}>:m> 1231 ) 1232 1233 add_executable (aiff_rw_test tests/aiff_rw_test.c) 1234 target_link_libraries (aiff_rw_test 1235 PRIVATE 1236 sndfile 1237 test_utils 1238 $<$<BOOL:${LIBM_REQUIRED}>:m> 1239 ) 1240 1241 add_executable (chunk_test tests/chunk_test.c) 1242 target_link_libraries (chunk_test 1243 PRIVATE 1244 sndfile 1245 test_utils 1246 $<$<BOOL:${LIBM_REQUIRED}>:m> 1247 ) 1248 1249 add_executable (long_read_write_test tests/long_read_write_test.c) 1250 target_link_libraries (long_read_write_test 1251 PRIVATE 1252 sndfile 1253 test_utils 1254 $<$<BOOL:${LIBM_REQUIRED}>:m> 1255 ) 1256 1257 add_executable (raw_test tests/raw_test.c) 1258 target_link_libraries (raw_test 1259 PRIVATE 1260 sndfile 1261 test_utils 1262 $<$<BOOL:${LIBM_REQUIRED}>:m> 1263 ) 1264 1265 add_executable (compression_size_test tests/compression_size_test.c) 1266 target_link_libraries (compression_size_test 1267 PRIVATE 1268 sndfile 1269 test_utils 1270 $<$<BOOL:${LIBM_REQUIRED}>:m> 1271 ) 1272 1273 add_executable (ogg_test tests/ogg_test.c) 1274 target_link_libraries (ogg_test 1275 PRIVATE 1276 sndfile 1277 test_utils 1278 $<$<BOOL:${LIBM_REQUIRED}>:m> 1279 ) 1280 1281 add_executable (ogg_opus_test tests/ogg_opus_test.c) 1282 target_link_libraries (ogg_opus_test 1283 PRIVATE 1284 sndfile 1285 test_utils 1286 $<$<BOOL:${LIBM_REQUIRED}>:m> 1287 ) 1288 1289 add_executable (mpeg_test tests/mpeg_test.c) 1290 target_link_libraries (mpeg_test 1291 PRIVATE 1292 sndfile 1293 test_utils 1294 $<$<BOOL:${LIBM_REQUIRED}>:m> 1295 ) 1296 1297 add_executable (stdin_test tests/stdin_test.c) 1298 target_link_libraries (stdin_test 1299 PRIVATE 1300 sndfile 1301 test_utils 1302 $<$<BOOL:${LIBM_REQUIRED}>:m> 1303 ) 1304 set_target_properties (stdin_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "tests") 1305 1306 add_executable (stdout_test tests/stdout_test.c) 1307 target_link_libraries (stdout_test 1308 PRIVATE 1309 sndfile 1310 test_utils 1311 $<$<BOOL:${LIBM_REQUIRED}>:m> 1312 ) 1313 set_target_properties (stdout_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "tests") 1314 1315 add_executable (stdio_test tests/stdio_test.c) 1316 target_link_libraries (stdio_test 1317 PRIVATE 1318 sndfile 1319 test_utils 1320 $<$<BOOL:${LIBM_REQUIRED}>:m> 1321 ) 1322 1323 add_executable (pipe_test tests/pipe_test.c) 1324 target_link_libraries (pipe_test 1325 PRIVATE 1326 sndfile 1327 test_utils 1328 $<$<BOOL:${LIBM_REQUIRED}>:m> 1329 ) 1330 1331 add_executable (virtual_io_test tests/virtual_io_test.c) 1332 target_link_libraries (virtual_io_test 1333 PRIVATE 1334 sndfile 1335 test_utils 1336 $<$<BOOL:${LIBM_REQUIRED}>:m> 1337 ) 1338 1339 ### g72x_test 1340 1341 add_executable (g72x_test src/G72x/g72x_test.c) 1342 target_include_directories (g72x_test 1343 PRIVATE 1344 src 1345 ${CMAKE_CURRENT_BINARY_DIR}/src 1346 ) 1347 target_link_libraries (g72x_test 1348 PRIVATE 1349 sndfile 1350 $<$<BOOL:${LIBM_REQUIRED}>:m> 1351 ) 1352 add_test (g72x_test g72x_test all) 1353 1354 ### aiff-tests 1355 1356 add_test (write_read_test_aiff write_read_test aiff) 1357 add_test (lossy_comp_test_aiff_ulaw lossy_comp_test aiff_ulaw) 1358 add_test (lossy_comp_test_aiff_alaw lossy_comp_test aiff_alaw) 1359 add_test (lossy_comp_test_aiff_gsm610 lossy_comp_test aiff_gsm610) 1360 add_test (peak_chunk_test_aiff peak_chunk_test aiff) 1361 add_test (header_test_aiff header_test aiff) 1362 add_test (misc_test_aiff misc_test aiff) 1363 add_test (string_test_aiff string_test aiff) 1364 add_test (multi_file_test_aiff multi_file_test aiff) 1365 add_test (aiff_rw_test aiff_rw_test) 1366 1367 ### au-tests 1368 1369 add_test (write_read_test_au write_read_test au) 1370 add_test (lossy_comp_test_au_ulaw lossy_comp_test au_ulaw) 1371 add_test (lossy_comp_test_au_alaw lossy_comp_test au_alaw) 1372 add_test (lossy_comp_test_au_g721 lossy_comp_test au_g721) 1373 add_test (lossy_comp_test_au_g723 lossy_comp_test au_g723) 1374 add_test (header_test_au header_test au) 1375 add_test (misc_test_au misc_test au) 1376 add_test (multi_file_test_au multi_file_test au) 1377 1378 ### caf-tests 1379 1380 add_test (write_read_test_caf write_read_test caf) 1381 add_test (lossy_comp_test_caf_ulaw lossy_comp_test caf_ulaw) 1382 add_test (lossy_comp_test_caf_alaw lossy_comp_test caf_alaw) 1383 add_test (header_test_caf header_test caf) 1384 add_test (peak_chunk_test_caf peak_chunk_test caf) 1385 add_test (misc_test_caf misc_test caf) 1386 add_test (chunk_test_caf chunk_test caf) 1387 add_test (string_test_caf string_test caf) 1388 add_test (long_read_write_test_alac long_read_write_test alac) 1389 1390 # wav-tests 1391 add_test (write_read_test_wav write_read_test wav) 1392 add_test (lossy_comp_test_wav_pcm lossy_comp_test wav_pcm) 1393 add_test (lossy_comp_test_wav_ima lossy_comp_test wav_ima) 1394 add_test (lossy_comp_test_wav_msadpcm lossy_comp_test wav_msadpcm) 1395 add_test (lossy_comp_test_wav_ulaw lossy_comp_test wav_ulaw) 1396 add_test (lossy_comp_test_wav_alaw lossy_comp_test wav_alaw) 1397 add_test (lossy_comp_test_wav_gsm610 lossy_comp_test wav_gsm610) 1398 add_test (lossy_comp_test_wav_g721 lossy_comp_test wav_g721) 1399 add_test (lossy_comp_test_wav_nmsadpcm lossy_comp_test wav_nmsadpcm) 1400 add_test (peak_chunk_test_wav peak_chunk_test wav) 1401 add_test (header_test_wav header_test wav) 1402 add_test (misc_test_wav misc_test wav) 1403 add_test (string_test_wav string_test wav) 1404 add_test (multi_file_test_wav multi_file_test wav) 1405 add_test (chunk_test_wav chunk_test wav) 1406 1407 ### w64-tests 1408 1409 add_test (write_read_test_w64 write_read_test w64) 1410 add_test (lossy_comp_test_w64_ima lossy_comp_test w64_ima) 1411 add_test (lossy_comp_test_w64_msadpcm lossy_comp_test w64_msadpcm) 1412 add_test (lossy_comp_test_w64_ulaw lossy_comp_test w64_ulaw) 1413 add_test (lossy_comp_test_w64_alaw lossy_comp_test w64_alaw) 1414 add_test (lossy_comp_test_w64_gsm610 lossy_comp_test w64_gsm610) 1415 add_test (header_test_w64 header_test w64) 1416 add_test (misc_test_w64 misc_test w64) 1417 1418 ### rf64-tests 1419 1420 add_test (write_read_test_rf64 write_read_test rf64) 1421 add_test (header_test_rf64 header_test rf64) 1422 add_test (misc_test_rf64 misc_test rf64) 1423 add_test (string_test_rf64 string_test rf64) 1424 add_test (peak_chunk_test_rf64 peak_chunk_test rf64) 1425 add_test (chunk_test_rf64 chunk_test rf64) 1426 1427 ### raw-tests 1428 add_test (write_read_test_raw write_read_test raw) 1429 add_test (lossy_comp_test_raw_ulaw lossy_comp_test raw_ulaw) 1430 add_test (lossy_comp_test_raw_alaw lossy_comp_test raw_alaw) 1431 add_test (lossy_comp_test_raw_gsm610 lossy_comp_test raw_gsm610) 1432 add_test (lossy_comp_test_vox_adpcm lossy_comp_test vox_adpcm) 1433 add_test (raw_test raw_test) 1434 1435 ### paf-tests 1436 add_test (write_read_test_paf write_read_test paf) 1437 add_test (header_test_paf header_test paf) 1438 add_test (misc_test_paf misc_test paf) 1439 1440 ### svx-tests 1441 add_test (write_read_test_svx write_read_test svx) 1442 add_test (header_test_svx header_test svx) 1443 add_test (misc_test_svx misc_test svx) 1444 1445 ### nist-tests 1446 add_test (write_read_test_nist write_read_test nist) 1447 add_test (lossy_comp_test_nist_ulaw lossy_comp_test nist_ulaw) 1448 add_test (lossy_comp_test_nist_alaw lossy_comp_test nist_alaw) 1449 add_test (header_test_nist header_test nist) 1450 add_test (misc_test_nist misc_test nist) 1451 1452 ### ircam-tests 1453 add_test (write_read_test_ircam write_read_test ircam) 1454 add_test (lossy_comp_test_ircam_ulaw lossy_comp_test ircam_ulaw) 1455 add_test (lossy_comp_test_ircam_alaw lossy_comp_test ircam_alaw) 1456 add_test (header_test_ircam header_test ircam) 1457 add_test (misc_test_ircam misc_test ircam) 1458 1459 ### voc-tests 1460 add_test (write_read_test_voc write_read_test voc) 1461 add_test (lossy_comp_test_voc_ulaw lossy_comp_test voc_ulaw) 1462 add_test (lossy_comp_test_voc_alaw lossy_comp_test voc_alaw) 1463 add_test (header_test_voc header_test voc) 1464 add_test (misc_test_voc misc_test voc) 1465 1466 ### mat4-tests 1467 add_test (write_read_test_mat4 write_read_test mat4) 1468 add_test (header_test_mat4 header_test mat4) 1469 add_test (misc_test_mat4 misc_test mat4) 1470 1471 ### mat5-tests 1472 add_test (write_read_test_mat5 write_read_test mat5) 1473 add_test (header_test_mat5 header_test mat5) 1474 add_test (misc_test_mat5 misc_test mat5) 1475 1476 ### pvf-tests 1477 add_test (write_read_test_pvf write_read_test pvf) 1478 add_test (header_test_pvf header_test pvf) 1479 add_test (misc_test_pvf misc_test pvf) 1480 1481 ### xi-tests 1482 add_test (lossy_comp_test_xi_dpcm lossy_comp_test xi_dpcm) 1483 1484 ### htk-tests 1485 add_test (write_read_test_htk write_read_test htk) 1486 add_test (header_test_htk header_test htk) 1487 add_test (misc_test_htk misc_test htk) 1488 1489 ### avr-tests 1490 add_test (write_read_test_avr write_read_test avr) 1491 add_test (header_test_avr header_test avr) 1492 add_test (misc_test_avr misc_test avr) 1493 1494 ### sds-tests 1495 add_test (write_read_test_sds write_read_test sds) 1496 add_test (header_test_sds header_test sds) 1497 add_test (misc_test_sds misc_test sds) 1498 1499 # sd2-tests 1500 add_test (write_read_test_sd2 write_read_test sd2) 1501 1502 ### wve-tests 1503 add_test (lossy_comp_test_wve lossy_comp_test wve) 1504 1505 ### mpc2k-tests 1506 add_test (write_read_test_mpc2k write_read_test mpc2k) 1507 add_test (header_test_mpc2k header_test mpc2k) 1508 add_test (misc_test_mpc2k misc_test mpc2k) 1509 1510 ### flac-tests 1511 add_test (write_read_test_flac write_read_test flac) 1512 add_test (compression_size_test_flac compression_size_test flac) 1513 add_test (string_test_flac string_test flac) 1514 1515 ### vorbis-tests 1516 add_test (ogg_test ogg_test) 1517 add_test (compression_size_test_vorbis compression_size_test vorbis) 1518 add_test (lossy_comp_test_ogg_vorbis lossy_comp_test ogg_vorbis) 1519 add_test (string_test_ogg string_test ogg) 1520 add_test (misc_test_ogg misc_test ogg) 1521 1522 ### opus-tests ### 1523 add_test (ogg_opus_test ogg_opus_test) 1524 add_test (compression_size_test_opus compression_size_test opus) 1525 add_test (lossy_comp_test_ogg_opus lossy_comp_test ogg_opus) 1526 add_test (string_test_opus string_test opus) 1527 1528 ### mpeg-tests ### 1529 add_test (mpeg_test mpeg_test) 1530 add_test (compression_size_test_mpeg compression_size_test mpeg) 1531 1532 ### io-tests 1533 add_test (stdio_test stdio_test) 1534 add_test (pipe_test pipe_test) 1535 add_test (virtual_io_test virtual_io_test) 1536 1537 set (SNDFILE_TEST_TARGETS 1538 test_utils 1539 test_main 1540 sfversion 1541 error_test 1542 ulaw_test 1543 alaw_test 1544 dwvw_test 1545 command_test 1546 floating_point_test 1547 checksum_test 1548 scale_clip_test 1549 headerless_test 1550 rdwr_test 1551 locale_test 1552 cpp_test 1553 external_libs_test 1554 format_check_test 1555 channel_test 1556 pcm_test 1557 write_read_test 1558 lossy_comp_test 1559 peak_chunk_test 1560 header_test 1561 misc_test 1562 string_test 1563 multi_file_test 1564 aiff_rw_test 1565 chunk_test 1566 long_read_write_test 1567 raw_test 1568 compression_size_test 1569 ogg_test 1570 stdin_test 1571 stdout_test 1572 stdio_test 1573 pipe_test 1574 virtual_io_test 1575 g72x_test 1576 ) 1577 1578# if (WIN32 AND BUILD_SHARED_LIBS) 1579# list (APPEND SNDFILE_TEST_TARGETS win32_ordinal_test) 1580# endif () 1581 1582 set_target_properties(${SNDFILE_TEST_TARGETS} PROPERTIES FOLDER Tests) 1583 1584endif () 1585 1586if (ENABLE_CPACK) 1587 if ((NOT CPACK_PACKAGE_VERSION) AND CPACK_PACKAGE_VERSION_STAGE) 1588 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_FULL}") 1589 endif () 1590 include (CPack) 1591endif () 1592