1 cmake_minimum_required (VERSION 3.1..3.18)
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.
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.")
11 if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
12 cmake_policy (SET CMP0091 NEW)
14 cmake_policy (SET CMP0091 OLD)
18 project(libsndfile VERSION 1.0.31)
24 set (CMAKE_C_STANDARD 99)
25 set (CMAKE_C_STANDARD_REQUIRED TRUE)
26 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
28 set (PACKAGE_NAME ${PROJECT_NAME})
29 set (CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
30 set (CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
31 set (CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
32 set (CPACK_PACKAGE_VERSION_STAGE "")
33 set (CPACK_PACKAGE_VERSION_FULL "${PROJECT_VERSION}${CPACK_PACKAGE_VERSION_STAGE}")
36 # System-wide includes
39 include (GNUInstallDirs)
40 include (FeatureSummary)
41 include (CMakeDependentOption)
43 include (CheckCCompilerFlag)
49 option (BUILD_SHARED_LIBS "Build shared libraries" OFF)
50 if (BUILD_SHARED_LIBS AND BUILD_TESTING)
51 set (BUILD_TESTING OFF)
52 message ("Build testing required static libraries. To prevent build errors BUILD_TESTING disabled.")
54 option (BUILD_PROGRAMS "Build programs" ON)
55 option (BUILD_EXAMPLES "Build examples" ON)
56 option (ENABLE_CPACK "Enable CPack support" ON)
57 option (ENABLE_EXPERIMENTAL "Enable experimental code" OFF)
58 option (ENABLE_BOW_DOCS "Enable black-on-white html docs" OFF)
59 if (MSVC AND (DEFINED ENABLE_STATIC_RUNTIME))
60 option (ENABLE_STATIC_RUNTIME "Enable static runtime" ${ENABLE_STATIC_RUNTIME})
62 option (ENABLE_STATIC_RUNTIME "Enable static runtime" OFF)
64 option (ENABLE_PACKAGE_CONFIG "Generate and install package config file" ON)
65 option (INSTALL_PKGCONFIG_MODULE "Generate and install pkg-config module" ON)
67 list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
68 if (CMAKE_VERSION VERSION_LESS 3.14)
69 list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sqlite")
76 include(SndFileChecks)
79 cmake_dependent_option (BUILD_REGTEST "Build regtest" ON "SQLITE3_FOUND" OFF)
80 cmake_dependent_option (ENABLE_EXTERNAL_LIBS "Enable FLAC, Vorbis, and Opus codecs" ON "Vorbis_FOUND;FLAC_FOUND;OPUS_FOUND" OFF)
81 cmake_dependent_option (ENABLE_CPU_CLIP "Enable tricky cpu specific clipper" ON "CPU_CLIPS_POSITIVE;CPU_CLIPS_NEGATIVE" OFF)
82 if (NOT ENABLE_CPU_CLIP)
83 set (CPU_CLIPS_POSITIVE FALSE)
84 set (CPU_CLIPS_NEGATIVE FALSE)
86 cmake_dependent_option (ENABLE_COMPATIBLE_LIBSNDFILE_NAME "Set DLL name to libsndfile-1.dll (canonical name), sndfile.dll otherwise" OFF "WIN32;BUILD_SHARED_LIBS" OFF)
87 cmake_dependent_option (INSTALL_MANPAGES "Install man pages for programs" ON "BUILD_PROGRAMS" OFF)
91 check_c_compiler_flag (-msse2 HAVE_MSSE2_COMPILER_FLAG)
92 if (HAVE_MSSE2_COMPILER_FLAG)
93 cmake_dependent_option (ENABLE_SSE2 "Add SSE2 compiler flag" ON "HAVE_MSSE2_COMPILER_FLAG" OFF)
98 add_compile_options (-msse2)
101 set (HAVE_EXTERNAL_XIPH_LIBS ${ENABLE_EXTERNAL_LIBS})
102 set (HAVE_SQLITE3 ${BUILD_REGTEST})
103 set (HAVE_ALSA_ASOUNDLIB_H ${ALSA_FOUND})
104 set (HAVE_SNDIO_H ${SNDIO_FOUND})
106 set (ENABLE_EXPERIMENTAL_CODE ${ENABLE_EXPERIMENTAL})
107 set (HAVE_SPEEX ${ENABLE_EXPERIMENTAL})
108 set (HAVE_OPUS ${ENABLE_EXPERIMENTAL})
110 add_feature_info (BUILD_SHARED_LIBS BUILD_SHARED_LIBS "build shared libraries")
111 add_feature_info (ENABLE_EXTERNAL_LIBS ENABLE_EXTERNAL_LIBS "enable FLAC, Vorbis, and Opus codecs")
112 add_feature_info (ENABLE_EXPERIMENTAL ENABLE_EXPERIMENTAL "enable experimental code")
113 add_feature_info (BUILD_TESTING BUILD_TESTING "build tests")
114 add_feature_info (BUILD_REGTEST BUILD_REGTEST "build regtest")
115 add_feature_info (ENABLE_CPACK ENABLE_CPACK "enable CPack support")
116 add_feature_info (ENABLE_CPU_CLIP ENABLE_CPU_CLIP "Enable tricky cpu specific clipper")
117 add_feature_info (ENABLE_BOW_DOCS ENABLE_BOW_DOCS "enable black-on-white html docs")
118 add_feature_info (ENABLE_PACKAGE_CONFIG ENABLE_PACKAGE_CONFIG "generate and install package config file")
119 add_feature_info (INSTALL_PKGCONFIG_MODULE INSTALL_PKGCONFIG_MODULE "generate and install pkg-config module")
120 add_feature_info (INSTALL_MANPAGES INSTALL_MANPAGES "install man pages for programs")
121 if (WIN32 AND BUILD_SHARED_LIBS)
122 add_feature_info (ENABLE_COMPATIBLE_LIBSNDFILE_NAME ENABLE_COMPATIBLE_LIBSNDFILE_NAME "Set DLL name to libsndfile-1.dll (canonical name), sndfile.dll otherwise")
125 if (HAVE_MSSE2_COMPILER_FLAG)
126 add_feature_info (ENABLE_SSE2 ENABLE_SSE2 "add SSE2 compiler flag")
132 set_package_properties (Ogg PROPERTIES
134 URL "www.xiph.org/ogg/"
135 DESCRIPTION "library for manipulating ogg bitstreams"
136 PURPOSE "Required to enable Vorbis, Speex, and Opus support"
138 set_package_properties (Vorbis PROPERTIES
140 URL "www.vorbis.com/"
141 DESCRIPTION "open source lossy audio codec"
142 PURPOSE "Enables Vorbis support"
144 set_package_properties (FLAC PROPERTIES
146 URL "www.xiph.org/flac/"
147 DESCRIPTION "Free Lossless Audio Codec Library"
148 PURPOSE "Enables FLAC support"
150 set_package_properties(Opus PROPERTIES
152 URL "www.opus-codec.org/"
153 DESCRIPTION "Standardized open source low-latency fullband codec"
154 PURPOSE "Enables experimental Opus support"
156 set_package_properties(Speex PROPERTIES TYPE OPTIONAL
158 DESCRIPTION "an audio codec tuned for speech"
159 PURPOSE "Enables experemental Speex support"
161 set_package_properties (SQLite3 PROPERTIES
163 URL "www.sqlite.org/"
164 DESCRIPTION "light weight SQL database engine."
165 PURPOSE "Enables regtest"
167 if (BUILD_SHARED_LIBS)
168 set_package_properties (PythonInterp PROPERTIES
170 URL "www.python.org/"
171 DESCRIPTION "Python is a widely used high-level programming language."
172 PURPOSE "Required to build shared libraries"
176 feature_summary (WHAT ALL)
179 # Setup configuration
182 configure_file (src/config.h.cmake src/config.h)
184 configure_file (include/sndfile.h.in include/sndfile.h)
186 if (INSTALL_PKGCONFIG_MODULE)
188 set (prefix ${CMAKE_INSTALL_PREFIX})
189 set (exec_prefix "\$\{prefix\}")
190 set (libdir "\$\{prefix\}/${CMAKE_INSTALL_LIBDIR}")
191 set (includedir "\$\{prefix\}/${CMAKE_INSTALL_INCLUDEDIR}")
192 set (VERSION ${PROJECT_VERSION})
193 if (ENABLE_EXTERNAL_LIBS)
194 set (EXTERNAL_XIPH_REQUIRE "flac ogg vorbis vorbisenc opus")
195 if (ENABLE_EXPERIMENTAL)
196 set (EXTERNAL_XIPH_REQUIRE "${EXTERNAL_XIPH_REQUIRE} speex")
200 configure_file (sndfile.pc.in sndfile.pc @ONLY)
208 # Public libsndfile headers
211 ${CMAKE_CURRENT_BINARY_DIR}/include/sndfile.h
215 # libsndfile static library
251 $<$<BOOL:${WIN32}>:src/windows.c>
291 src/GSM610/gsm610_priv.h
295 src/GSM610/gsm_create.c
296 src/GSM610/gsm_decode.c
297 src/GSM610/gsm_destroy.c
298 src/GSM610/gsm_encode.c
299 src/GSM610/gsm_option.c
300 src/GSM610/long_term.c
302 src/GSM610/preprocess.c
304 src/GSM610/short_term.c
313 src/ALAC/ALACAudioTypes.h
314 src/ALAC/ALACBitUtilities.h
315 src/ALAC/EndianPortable.h
319 src/ALAC/alac_codec.h
321 src/ALAC/ALACBitUtilities.c
326 src/ALAC/matrix_dec.c
327 src/ALAC/matrix_enc.c
328 src/ALAC/alac_decoder.c
329 src/ALAC/alac_encoder.c
331 ${CMAKE_CURRENT_BINARY_DIR}/src/config.h
334 add_library (SndFile::sndfile ALIAS sndfile)
336 target_include_directories (sndfile
338 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
339 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
340 $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
343 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/src>
345 target_link_libraries (sndfile
347 $<$<BOOL:${LIBM_REQUIRED}>:m>
348 $<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Vorbis::vorbisenc>
349 $<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:FLAC::FLAC>
350 $<$<AND:$<BOOL:${ENABLE_EXPERIMENTAL}>,$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>,$<BOOL:${HAVE_SPEEX}>>:Speex::Speex>
351 $<$<BOOL:${HAVE_EXTERNAL_XIPH_LIBS}>:Opus::opus>
353 set_target_properties (sndfile PROPERTIES
354 PUBLIC_HEADER "${sndfile_HDRS}"
357 if (ENABLE_COMPATIBLE_LIBSNDFILE_NAME)
359 set_target_properties (sndfile PROPERTIES
360 RUNTIME_OUTPUT_NAME "sndfile-1"
363 set_target_properties (sndfile PROPERTIES
364 RUNTIME_OUTPUT_NAME "libsndfile-1"
369 if (BUILD_SHARED_LIBS)
372 set (VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR})
375 set (WIN_RC_VERSION "${CPACK_PACKAGE_VERSION_MAJOR},${CPACK_PACKAGE_VERSION_MINOR},${CPACK_PACKAGE_VERSION_PATCH}")
376 set (CLEAN_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
377 set (PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
379 configure_file (src/version-metadata.rc.in src/version-metadata.rc @ONLY)
380 target_sources (sndfile PRIVATE ${PROJECT_BINARY_DIR}/src/version-metadata.rc)
383 set_target_properties (sndfile PROPERTIES
384 SOVERSION ${PROJECT_VERSION_MAJOR}
385 VERSION ${PROJECT_VERSION}
388 # Symbol files generation
391 set (SYMBOL_FILENAME "sndfile.def")
392 set (SYMBOL_OS "win32")
393 elseif ((CMAKE_SYSTEM_NAME MATCHES "Darwin") OR (CMAKE_SYSTEM_NAME MATCHES "Rhapsody"))
394 set (SYMBOL_FILENAME "Symbols.darwin")
395 set (SYMBOL_OS "darwin")
396 elseif (CMAKE_SYSTEM_NAME MATCHES "OS2")
397 set (SYMBOL_FILENAME "Symbols.os2")
398 set (SYMBOL_OS "os2")
400 set (SYMBOL_FILENAME "Symbols.gnu-binutils")
401 set (SYMBOL_OS "linux")
404 if (DEFINED SYMBOL_OS)
406 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}
407 COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/create_symbols_file.py ${SYMBOL_OS} ${PROJECT_VERSION} > ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}
408 COMMENT "Generating ${SYMBOL_FILENAME}..."
411 add_custom_target (GENFILES DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME})
412 if (SYMBOL_OS MATCHES "win32")
413 target_sources (sndfile
415 ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}
417 elseif (SYMBOL_OS MATCHES "darwin")
418 add_dependencies (sndfile GENFILES)
419 if (CMAKE_VERSION VERSION_LESS 3.13)
420 set_property (TARGET sndfile APPEND_STRING PROPERTY
421 LINK_FLAGS "-Wl,-exported_symbols_list -Wl,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}"
424 target_link_options (sndfile PRIVATE "LINKER:-exported_symbols_list,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}")
426 elseif (SYMBOL_OS MATCHES "os")
427 add_dependencies (sndfile GENFILES)
428 if (CMAKE_VERSION VERSION_LESS 3.13)
429 set_property (TARGET sndfile APPEND_STRING PROPERTY
430 LINK_FLAGS "-Wl,-export-symbols ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}"
433 target_link_options (sndfile PRIVATE "LINKER:-export-symbols ${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}")
436 add_dependencies (sndfile GENFILES)
437 if (CMAKE_VERSION VERSION_LESS 3.13)
438 set_property (TARGET sndfile APPEND_STRING PROPERTY
439 LINK_FLAGS "-Wl,--version-script,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}"
442 target_link_options (sndfile PRIVATE "LINKER:--version-script,${CMAKE_CURRENT_BINARY_DIR}/src/${SYMBOL_FILENAME}")
457 add_executable (sndfile-info
458 programs/sndfile-info.c
462 target_link_libraries (sndfile-info
465 $<$<BOOL:${LIBM_REQUIRED}>:m>
470 add_executable (sndfile-play
471 $<$<NOT:$<BOOL:${BEOS}>>:programs/sndfile-play.c>
472 $<$<NOT:$<BOOL:${BEOS}>>:programs/common.c>
473 $<$<NOT:$<BOOL:${BEOS}>>:programs/sndfile-play.c>
474 $<$<BOOL:${BEOS}>:programs/sndfile-play-beos.cpp>
476 target_include_directories (sndfile-play
479 ${CMAKE_CURRENT_BINARY_DIR}/src
481 target_link_libraries (sndfile-play PRIVATE $<$<BOOL:${LIBM_REQUIRED}>:m>)
482 target_link_libraries (sndfile-play PRIVATE sndfile)
484 target_link_libraries(sndfile-play PRIVATE winmm)
485 # Maybe ALSA & Sndio are present in BeOS. They are not required
486 # so skip them anyway.
487 elseif ((NOT BEOS) AND ALSA_FOUND)
488 target_include_directories (sndfile-play PRIVATE ${ALSA_INCLUDE_DIRS})
489 target_link_libraries (sndfile-play PRIVATE ${ALSA_LIBRARIES})
490 elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
491 target_link_libraries (sndfile-play PRIVATE Sndio::Sndio)
496 add_executable (sndfile-convert
497 programs/sndfile-convert.c
501 target_link_libraries (sndfile-convert PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>)
505 add_executable (sndfile-cmp
506 programs/sndfile-cmp.c
510 target_include_directories (sndfile-cmp
513 ${CMAKE_CURRENT_BINARY_DIR}/src
514 ${CMAKE_CURRENT_BINARY_DIR}/tests
516 target_link_libraries (sndfile-cmp PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>)
518 # sndfile-metadata-set
520 add_executable (sndfile-metadata-set
521 programs/sndfile-metadata-set.c
525 target_include_directories (sndfile-metadata-set
528 ${CMAKE_CURRENT_BINARY_DIR}/src
529 ${CMAKE_CURRENT_BINARY_DIR}/tests
531 target_link_libraries (sndfile-metadata-set PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>)
533 # sndfile-metadata-get
535 add_executable (sndfile-metadata-get
536 programs/sndfile-metadata-get.c
540 target_include_directories (sndfile-metadata-get
543 ${CMAKE_CURRENT_BINARY_DIR}/src
544 ${CMAKE_CURRENT_BINARY_DIR}/tests
546 target_link_libraries (sndfile-metadata-get PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>)
550 add_executable (sndfile-interleave
551 programs/sndfile-interleave.c
555 target_link_libraries (sndfile-interleave PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>)
557 # sndfile-deinterleave
559 add_executable (sndfile-deinterleave
560 programs/sndfile-deinterleave.c
564 target_link_libraries (sndfile-deinterleave PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>)
568 add_executable (sndfile-concat
569 programs/sndfile-concat.c
573 target_link_libraries (sndfile-concat PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>)
577 add_executable (sndfile-salvage
578 programs/sndfile-salvage.c
582 target_include_directories (sndfile-salvage
585 ${CMAKE_CURRENT_BINARY_DIR}/src
586 ${CMAKE_CURRENT_BINARY_DIR}/tests
588 target_link_libraries (sndfile-salvage PRIVATE sndfile $<$<BOOL:${LIBM_REQUIRED}>:m>)
590 set (SNDFILE_PROGRAM_TARGETS
603 set_target_properties(${SNDFILE_PROGRAM_TARGETS} PROPERTIES FOLDER Programs)
615 add_executable (sndfile-to-text examples/sndfile-to-text.c)
616 target_link_libraries (sndfile-to-text PRIVATE sndfile)
620 add_executable (sndfile-loopify examples/sndfile-loopify.c)
621 target_link_libraries (sndfile-loopify PRIVATE sndfile)
625 add_executable (make_sine examples/make_sine.c)
626 target_link_libraries (make_sine
629 $<$<BOOL:${LIBM_REQUIRED}>:m>
634 add_executable (sfprocess examples/sfprocess.c)
635 target_link_libraries (sfprocess
638 $<$<BOOL:${LIBM_REQUIRED}>:m>
643 add_executable (list_formats examples/list_formats.c)
644 target_link_libraries (list_formats
647 $<$<BOOL:${LIBM_REQUIRED}>:m>
652 add_executable (sndfilehandle examples/sndfilehandle.cc)
653 target_link_libraries (sndfilehandle PUBLIC sndfile)
655 set (SNDFILE_EXAMPLE_TARGETS
664 set_target_properties(${SNDFILE_EXAMPLE_TARGETS} PROPERTIES FOLDER Examples)
675 add_executable (sndfile-regtest
676 regtest/sndfile-regtest.c
680 target_include_directories (sndfile-regtest
683 ${CMAKE_CURRENT_BINARY_DIR}/src
684 ${CMAKE_CURRENT_BINARY_DIR}/tests
686 target_link_libraries(sndfile-regtest
690 $<$<BOOL:${LIBM_REQUIRED}>:m>
699 if (ENABLE_PACKAGE_CONFIG)
701 if (WIN32 AND (NOT MINGW) AND (NOT CYGWIN))
702 set (CMAKE_INSTALL_PACKAGEDIR cmake)
704 set (CMAKE_INSTALL_PACKAGEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/SndFile)
707 install (TARGETS ${SNDFILE_PROGRAM_TARGETS}
708 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
711 install (TARGETS sndfile
712 EXPORT SndFileTargets
713 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
714 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
715 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
716 PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
719 include (CMakePackageConfigHelpers)
721 if (ENABLE_EXTERNAL_LIBS)
722 set (SndFile_WITH_EXTERNAL_LIBS 1)
724 set (SndFile_WITH_EXTERNAL_LIBS 0)
727 set (INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR})
728 configure_package_config_file(cmake/SndFileConfig.cmake.in SndFileConfig.cmake
729 INSTALL_DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}
730 PATH_VARS INCLUDE_INSTALL_DIR
732 write_basic_package_version_file (SndFileConfigVersion.cmake COMPATIBILITY SameMajorVersion)
734 install(EXPORT SndFileTargets
736 DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}
740 ${CMAKE_CURRENT_BINARY_DIR}/SndFileConfig.cmake
741 ${CMAKE_CURRENT_BINARY_DIR}/SndFileConfigVersion.cmake
742 DESTINATION ${CMAKE_INSTALL_PACKAGEDIR}
747 install (TARGETS sndfile ${sdnfile_PROGRAMS}
748 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
749 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
750 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
751 PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
755 if (INSTALL_MANPAGES)
760 man/sndfile-convert.1
762 man/sndfile-metadata-get.1
764 man/sndfile-interleave.1
765 man/sndfile-salvage.1
767 install (FILES ${man_MANS} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
768 install (FILES man/sndfile-metadata-get.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME sndfile-metadata-set.1)
769 install (FILES man/sndfile-interleave.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 RENAME sndfile-deinterleave.1)
773 set (HTML_BGCOLOUR "white")
774 set (HTML_FGCOLOUR "black")
776 set (HTML_BGCOLOUR "black")
777 set (HTML_FGCOLOUR "white")
789 docs/new_file_type_howto.md
793 docs/embedded_files.md
797 install (FILES ${dist_doc_DATA} DESTINATION ${CMAKE_INSTALL_DOCDIR})
799 if (INSTALL_PKGCONFIG_MODULE)
800 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/sndfile.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
811 include (CMakeAutoGen)
813 # generate tests sources from autogen templates
814 lsf_autogen (tests benchmark c)
815 lsf_autogen (tests floating_point_test c)
816 lsf_autogen (tests header_test c)
817 lsf_autogen (tests pcm_test c)
818 lsf_autogen (tests pipe_test c)
819 lsf_autogen (tests rdwr_test c)
820 lsf_autogen (tests scale_clip_test c)
821 lsf_autogen (tests utils c h)
822 lsf_autogen (tests write_read_test c)
823 lsf_autogen (src test_endswap c)
825 # utils static library
826 add_library(test_utils STATIC tests/utils.c)
827 target_include_directories (test_utils
830 ${CMAKE_CURRENT_BINARY_DIR}/src
831 ${CMAKE_CURRENT_BINARY_DIR}/tests
833 target_link_libraries(test_utils PRIVATE sndfile)
837 add_executable (test_main
840 src/test_conversions.c
843 src/test_audio_detect.c
844 src/test_log_printf.c
846 src/test_ima_oki_adpcm.c
847 src/test_strncpy_crlf.c
848 src/test_broadcast_var.c
850 src/test_binheader_writef.c
853 target_include_directories (test_main
856 ${CMAKE_CURRENT_BINARY_DIR}/src
857 ${CMAKE_CURRENT_BINARY_DIR}/tests
859 target_link_libraries (test_main PRIVATE sndfile)
861 target_compile_definitions (test_main PRIVATE _USE_MATH_DEFINES)
863 add_test (test_main test_main)
867 add_executable (sfversion tests/sfversion.c)
868 target_include_directories (sfversion
871 ${CMAKE_CURRENT_BINARY_DIR}/src
873 target_link_libraries (sfversion sndfile)
874 add_test (sfversion sfversion)
875 set_tests_properties (sfversion PROPERTIES
876 PASS_REGULAR_EXPRESSION "${PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_FULL}"
881 add_executable (error_test tests/error_test.c)
882 target_link_libraries (error_test
886 $<$<BOOL:${LIBM_REQUIRED}>:m>
888 add_test (error_test error_test)
891 add_executable (ulaw_test tests/ulaw_test.c)
892 target_link_libraries (ulaw_test
896 $<$<BOOL:${LIBM_REQUIRED}>:m>
898 add_test (ulaw_test ulaw_test)
901 add_executable (alaw_test tests/alaw_test.c)
902 target_link_libraries (alaw_test
906 $<$<BOOL:${LIBM_REQUIRED}>:m>
908 add_test (alaw_test alaw_test)
912 add_executable (dwvw_test tests/dwvw_test.c)
913 target_link_libraries (dwvw_test
917 $<$<BOOL:${LIBM_REQUIRED}>:m>
919 add_test (dwvw_test dwvw_test)
923 add_executable (command_test tests/command_test.c)
924 target_link_libraries (command_test
928 $<$<BOOL:${LIBM_REQUIRED}>:m>
930 add_test (command_test command_test all)
932 ### floating_point_test
934 add_executable (floating_point_test
936 tests/floating_point_test.c
938 target_link_libraries (floating_point_test
942 $<$<BOOL:${LIBM_REQUIRED}>:m>
944 target_include_directories (floating_point_test PRIVATE tests)
945 add_test (floating_point_test floating_point_test)
949 add_executable (checksum_test tests/checksum_test.c)
950 target_link_libraries (checksum_test
954 $<$<BOOL:${LIBM_REQUIRED}>:m>
956 add_test (checksum_test checksum_test)
960 add_executable (scale_clip_test tests/scale_clip_test.c)
961 target_link_libraries (scale_clip_test
965 $<$<BOOL:${LIBM_REQUIRED}>:m>
967 add_test (scale_clip_test scale_clip_test)
971 add_executable (headerless_test tests/headerless_test.c)
972 target_link_libraries (headerless_test
976 $<$<BOOL:${LIBM_REQUIRED}>:m>
978 add_test (headerless_test headerless_test)
982 add_executable (rdwr_test tests/rdwr_test.c)
983 target_link_libraries (rdwr_test
987 $<$<BOOL:${LIBM_REQUIRED}>:m>
989 add_test (rdwr_test rdwr_test)
993 add_executable (locale_test tests/locale_test.c)
994 target_link_libraries (locale_test
998 $<$<BOOL:${LIBM_REQUIRED}>:m>
1000 add_test (locale_test locale_test)
1002 ### win32_ordinal_test
1004 # Disabled because we cannot test with shared sndfile library
1005 # if (WIN32 AND BUILD_SHARED_LIBS)
1006 # add_executable (win32_ordinal_test tests/win32_ordinal_test.c)
1007 # target_link_libraries (win32_ordinal_test PRIVATE sndfile test_utils)
1008 # add_test (win32_ordinal_test win32_ordinal_test)
1013 add_executable (cpp_test tests/cpp_test.cc)
1014 target_link_libraries (cpp_test
1018 $<$<BOOL:${LIBM_REQUIRED}>:m>
1020 add_test (cpp_test cpp_test)
1022 ### external_libs_test
1024 add_executable (external_libs_test tests/external_libs_test.c)
1025 target_link_libraries (external_libs_test
1029 $<$<BOOL:${LIBM_REQUIRED}>:m>
1031 add_test (external_libs_test external_libs_test)
1033 ### format_check_test
1035 add_executable (format_check_test tests/format_check_test.c)
1036 target_link_libraries (format_check_test
1040 $<$<BOOL:${LIBM_REQUIRED}>:m>
1042 add_test (format_check_test format_check_test)
1046 add_executable (channel_test tests/channel_test.c)
1047 target_link_libraries (channel_test
1051 $<$<BOOL:${LIBM_REQUIRED}>:m>
1053 add_test (channel_test channel_test)
1057 add_executable (pcm_test tests/pcm_test.c)
1058 target_link_libraries (pcm_test
1062 $<$<BOOL:${LIBM_REQUIRED}>:m>
1064 add_test (pcm_test pcm_test)
1066 ### common test executables
1068 add_executable (write_read_test
1070 tests/write_read_test.c
1072 target_link_libraries (write_read_test
1076 $<$<BOOL:${LIBM_REQUIRED}>:m>
1078 target_include_directories (write_read_test PRIVATE tests)
1080 add_executable (lossy_comp_test tests/lossy_comp_test.c)
1081 target_link_libraries (lossy_comp_test
1085 $<$<BOOL:${LIBM_REQUIRED}>:m>
1088 add_executable (peak_chunk_test tests/peak_chunk_test.c)
1089 target_link_libraries (peak_chunk_test
1093 $<$<BOOL:${LIBM_REQUIRED}>:m>
1096 add_executable (header_test tests/header_test.c)
1097 target_link_libraries (header_test
1101 $<$<BOOL:${LIBM_REQUIRED}>:m>
1104 add_executable (misc_test tests/misc_test.c)
1105 target_link_libraries (misc_test
1109 $<$<BOOL:${LIBM_REQUIRED}>:m>
1112 add_executable (string_test tests/string_test.c)
1113 target_link_libraries (string_test
1117 $<$<BOOL:${LIBM_REQUIRED}>:m>
1120 add_executable (multi_file_test tests/multi_file_test.c)
1121 target_link_libraries (multi_file_test
1125 $<$<BOOL:${LIBM_REQUIRED}>:m>
1128 add_executable (aiff_rw_test tests/aiff_rw_test.c)
1129 target_link_libraries (aiff_rw_test
1133 $<$<BOOL:${LIBM_REQUIRED}>:m>
1136 add_executable (chunk_test tests/chunk_test.c)
1137 target_link_libraries (chunk_test
1141 $<$<BOOL:${LIBM_REQUIRED}>:m>
1144 add_executable (long_read_write_test tests/long_read_write_test.c)
1145 target_link_libraries (long_read_write_test
1149 $<$<BOOL:${LIBM_REQUIRED}>:m>
1152 add_executable (raw_test tests/raw_test.c)
1153 target_link_libraries (raw_test
1157 $<$<BOOL:${LIBM_REQUIRED}>:m>
1160 add_executable (compression_size_test tests/compression_size_test.c)
1161 target_link_libraries (compression_size_test
1165 $<$<BOOL:${LIBM_REQUIRED}>:m>
1168 add_executable (ogg_test tests/ogg_test.c)
1169 target_link_libraries (ogg_test
1173 $<$<BOOL:${LIBM_REQUIRED}>:m>
1176 add_executable (ogg_opus_test tests/ogg_opus_test.c)
1177 target_link_libraries (ogg_opus_test
1181 $<$<BOOL:${LIBM_REQUIRED}>:m>
1184 add_executable (stdin_test tests/stdin_test.c)
1185 target_link_libraries (stdin_test
1189 $<$<BOOL:${LIBM_REQUIRED}>:m>
1191 set_target_properties (stdin_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "tests")
1193 add_executable (stdout_test tests/stdout_test.c)
1194 target_link_libraries (stdout_test
1198 $<$<BOOL:${LIBM_REQUIRED}>:m>
1200 set_target_properties (stdout_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY "tests")
1202 add_executable (stdio_test tests/stdio_test.c)
1203 target_link_libraries (stdio_test
1207 $<$<BOOL:${LIBM_REQUIRED}>:m>
1210 add_executable (pipe_test tests/pipe_test.c)
1211 target_link_libraries (pipe_test
1215 $<$<BOOL:${LIBM_REQUIRED}>:m>
1218 add_executable (virtual_io_test tests/virtual_io_test.c)
1219 target_link_libraries (virtual_io_test
1223 $<$<BOOL:${LIBM_REQUIRED}>:m>
1228 add_executable (g72x_test src/G72x/g72x_test.c)
1229 target_include_directories (g72x_test
1232 ${CMAKE_CURRENT_BINARY_DIR}/src
1234 target_link_libraries (g72x_test
1237 $<$<BOOL:${LIBM_REQUIRED}>:m>
1239 add_test (g72x_test g72x_test all)
1243 add_test (write_read_test_aiff write_read_test aiff)
1244 add_test (lossy_comp_test_aiff_ulaw lossy_comp_test aiff_ulaw)
1245 add_test (lossy_comp_test_aiff_alaw lossy_comp_test aiff_alaw)
1246 add_test (lossy_comp_test_aiff_gsm610 lossy_comp_test aiff_gsm610)
1247 add_test (peak_chunk_test_aiff peak_chunk_test aiff)
1248 add_test (header_test_aiff header_test aiff)
1249 add_test (misc_test_aiff misc_test aiff)
1250 add_test (string_test_aiff string_test aiff)
1251 add_test (multi_file_test_aiff multi_file_test aiff)
1252 add_test (aiff_rw_test aiff_rw_test)
1256 add_test (write_read_test_au write_read_test au)
1257 add_test (lossy_comp_test_au_ulaw lossy_comp_test au_ulaw)
1258 add_test (lossy_comp_test_au_alaw lossy_comp_test au_alaw)
1259 add_test (lossy_comp_test_au_g721 lossy_comp_test au_g721)
1260 add_test (lossy_comp_test_au_g723 lossy_comp_test au_g723)
1261 add_test (header_test_au header_test au)
1262 add_test (misc_test_au misc_test au)
1263 add_test (multi_file_test_au multi_file_test au)
1267 add_test (write_read_test_caf write_read_test caf)
1268 add_test (lossy_comp_test_caf_ulaw lossy_comp_test caf_ulaw)
1269 add_test (lossy_comp_test_caf_alaw lossy_comp_test caf_alaw)
1270 add_test (header_test_caf header_test caf)
1271 add_test (peak_chunk_test_caf peak_chunk_test caf)
1272 add_test (misc_test_caf misc_test caf)
1273 add_test (chunk_test_caf chunk_test caf)
1274 add_test (string_test_caf string_test caf)
1275 add_test (long_read_write_test_alac long_read_write_test alac)
1278 add_test (write_read_test_wav write_read_test wav)
1279 add_test (lossy_comp_test_wav_pcm lossy_comp_test wav_pcm)
1280 add_test (lossy_comp_test_wav_ima lossy_comp_test wav_ima)
1281 add_test (lossy_comp_test_wav_msadpcm lossy_comp_test wav_msadpcm)
1282 add_test (lossy_comp_test_wav_ulaw lossy_comp_test wav_ulaw)
1283 add_test (lossy_comp_test_wav_alaw lossy_comp_test wav_alaw)
1284 add_test (lossy_comp_test_wav_gsm610 lossy_comp_test wav_gsm610)
1285 add_test (lossy_comp_test_wav_g721 lossy_comp_test wav_g721)
1286 add_test (lossy_comp_test_wav_nmsadpcm lossy_comp_test wav_nmsadpcm)
1287 add_test (peak_chunk_test_wav peak_chunk_test wav)
1288 add_test (header_test_wav header_test wav)
1289 add_test (misc_test_wav misc_test wav)
1290 add_test (string_test_wav string_test wav)
1291 add_test (multi_file_test_wav multi_file_test wav)
1292 add_test (chunk_test_wav chunk_test wav)
1296 add_test (write_read_test_w64 write_read_test w64)
1297 add_test (lossy_comp_test_w64_ima lossy_comp_test w64_ima)
1298 add_test (lossy_comp_test_w64_msadpcm lossy_comp_test w64_msadpcm)
1299 add_test (lossy_comp_test_w64_ulaw lossy_comp_test w64_ulaw)
1300 add_test (lossy_comp_test_w64_alaw lossy_comp_test w64_alaw)
1301 add_test (lossy_comp_test_w64_gsm610 lossy_comp_test w64_gsm610)
1302 add_test (header_test_w64 header_test w64)
1303 add_test (misc_test_w64 misc_test w64)
1307 add_test (write_read_test_rf64 write_read_test rf64)
1308 add_test (header_test_rf64 header_test rf64)
1309 add_test (misc_test_rf64 misc_test rf64)
1310 add_test (string_test_rf64 string_test rf64)
1311 add_test (peak_chunk_test_rf64 peak_chunk_test rf64)
1312 add_test (chunk_test_rf64 chunk_test rf64)
1315 add_test (write_read_test_raw write_read_test raw)
1316 add_test (lossy_comp_test_raw_ulaw lossy_comp_test raw_ulaw)
1317 add_test (lossy_comp_test_raw_alaw lossy_comp_test raw_alaw)
1318 add_test (lossy_comp_test_raw_gsm610 lossy_comp_test raw_gsm610)
1319 add_test (lossy_comp_test_vox_adpcm lossy_comp_test vox_adpcm)
1320 add_test (raw_test raw_test)
1323 add_test (write_read_test_paf write_read_test paf)
1324 add_test (header_test_paf header_test paf)
1325 add_test (misc_test_paf misc_test paf)
1328 add_test (write_read_test_svx write_read_test svx)
1329 add_test (header_test_svx header_test svx)
1330 add_test (misc_test_svx misc_test svx)
1333 add_test (write_read_test_nist write_read_test nist)
1334 add_test (lossy_comp_test_nist_ulaw lossy_comp_test nist_ulaw)
1335 add_test (lossy_comp_test_nist_alaw lossy_comp_test nist_alaw)
1336 add_test (header_test_nist header_test nist)
1337 add_test (misc_test_nist misc_test nist)
1340 add_test (write_read_test_ircam write_read_test ircam)
1341 add_test (lossy_comp_test_ircam_ulaw lossy_comp_test ircam_ulaw)
1342 add_test (lossy_comp_test_ircam_alaw lossy_comp_test ircam_alaw)
1343 add_test (header_test_ircam header_test ircam)
1344 add_test (misc_test_ircam misc_test ircam)
1347 add_test (write_read_test_voc write_read_test voc)
1348 add_test (lossy_comp_test_voc_ulaw lossy_comp_test voc_ulaw)
1349 add_test (lossy_comp_test_voc_alaw lossy_comp_test voc_alaw)
1350 add_test (header_test_voc header_test voc)
1351 add_test (misc_test_voc misc_test voc)
1354 add_test (write_read_test_mat4 write_read_test mat4)
1355 add_test (header_test_mat4 header_test mat4)
1356 add_test (misc_test_mat4 misc_test mat4)
1359 add_test (write_read_test_mat5 write_read_test mat5)
1360 add_test (header_test_mat5 header_test mat5)
1361 add_test (misc_test_mat5 misc_test mat5)
1364 add_test (write_read_test_pvf write_read_test pvf)
1365 add_test (header_test_pvf header_test pvf)
1366 add_test (misc_test_pvf misc_test pvf)
1369 add_test (lossy_comp_test_xi_dpcm lossy_comp_test xi_dpcm)
1372 add_test (write_read_test_htk write_read_test htk)
1373 add_test (header_test_htk header_test htk)
1374 add_test (misc_test_htk misc_test htk)
1377 add_test (write_read_test_avr write_read_test avr)
1378 add_test (header_test_avr header_test avr)
1379 add_test (misc_test_avr misc_test avr)
1382 add_test (write_read_test_sds write_read_test sds)
1383 add_test (header_test_sds header_test sds)
1384 add_test (misc_test_sds misc_test sds)
1387 add_test (write_read_test_sd2 write_read_test sd2)
1390 add_test (lossy_comp_test_wve lossy_comp_test wve)
1393 add_test (write_read_test_mpc2k write_read_test mpc2k)
1394 add_test (header_test_mpc2k header_test mpc2k)
1395 add_test (misc_test_mpc2k misc_test mpc2k)
1398 add_test (write_read_test_flac write_read_test flac)
1399 add_test (compression_size_test_flac compression_size_test flac)
1400 add_test (string_test_flac string_test flac)
1403 add_test (ogg_test ogg_test)
1404 add_test (compression_size_test_vorbis compression_size_test vorbis)
1405 add_test (lossy_comp_test_ogg_vorbis lossy_comp_test ogg_vorbis)
1406 add_test (string_test_ogg string_test ogg)
1407 add_test (misc_test_ogg misc_test ogg)
1410 add_test (ogg_opus_test ogg_opus_test)
1411 add_test (compression_size_test_opus compression_size_test opus)
1412 add_test (lossy_comp_test_ogg_opus lossy_comp_test ogg_opus)
1413 add_test (string_test_opus string_test opus)
1416 add_test (stdio_test stdio_test)
1417 add_test (pipe_test pipe_test)
1418 add_test (virtual_io_test virtual_io_test)
1420 set (SNDFILE_TEST_TARGETS
1449 long_read_write_test
1451 compression_size_test
1461 # if (WIN32 AND BUILD_SHARED_LIBS)
1462 # list (APPEND SNDFILE_TEST_TARGETS win32_ordinal_test)
1465 set_target_properties(${SNDFILE_TEST_TARGETS} PROPERTIES FOLDER Tests)