Rework CMake build system

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
This commit is contained in:
Erik de Castro Lopo 2016-07-26 18:41:17 +10:00
parent 356a8c8fe3
commit 1c0ea87cc3
32 changed files with 2158 additions and 745 deletions

15
.gitignore vendored
View File

@ -1,14 +1,25 @@
*.8svx
*.a
*.aif
*.aifc
*.aiff
*.au
*.bin
*.caf
*.cm*
/*.cmake
/src/*.cmake
/src/ALAC/*.cmake
/src/G72x/*.cmake
/src/GSM610/*.cmake
/tests/*.cmake
/programs/*.cmake
!src/config.h.cmake
!*.in.cmake
*.dll
*.exe
*.flac
*.la
*.lib
*.lo
*.loT
*.o
@ -21,6 +32,7 @@
*.sd2
*.sds
*.svx
/*.so*
*.w64
*.wav
*.wavex
@ -90,6 +102,7 @@ src/Symbols.os2
src/Symbols.static
src/config.h
src/config.h.in
src/config.h.in~
src/libsndfile.so*
src/libsndfile-1.def
src/sndfile.h

View File

@ -1,13 +1,43 @@
sudo: false
language: c
sudo: required
dist: trusty
matrix:
include:
- os: linux
dist: trusty
compiler: clang
addons:
apt:
packages:
- libogg-dev
- libvorbis-dev
- libflac-dev
- libasound2-dev
- os: linux
dist: trusty
compiler: gcc
addons:
apt:
packages:
- libogg-dev
- libvorbis-dev
- libflac-dev
- libasound2-dev
- os: osx
compiler: clang
before_install:
- sudo apt-get update
- sudo apt-get install -y libogg-dev libflac-dev libvorbis-dev
- |
if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
brew install autogen flac libogg libvorbis
fi
install:
- true
script:
- ./autogen.sh
- ./configure
- make distcheck
- mkdir cmake-build && (cd cmake-build && cmake .. -DCMAKE_BUILD_TYPE=Release && make VERBOSE=1 && ctest -V)
- pwd
- ./autogen.sh
- ./configure --enable-werror && make clean all check

View File

@ -1,17 +0,0 @@
function (lsf_autogen dir basefilename)
# Only generate the file if it does not already exist.
if (NOT (EXISTS "${CMAKE_SOURCE_DIR}/${dir}/${basefilename}.c"))
# If it doesn't exist, but we don't have autogen its an error.
if (NOT AUTOGEN)
message (FATAL_ERROR "Need GNU autogen to generate '${dir}/${basefilename}.c'.")
endif ()
execute_process (
COMMAND ${AUTOGEN} --writable ${basefilename}.def
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/${dir}
)
endif ()
endfunction ()

View File

@ -1,73 +0,0 @@
# Build recipe for building programs in the programs/ directory.
function (lsf_build_program prog_name)
add_executable (${prog_name}
programs/common.c
programs/${prog_name}.c
)
target_link_libraries (${prog_name} sndfile)
set_target_properties (${prog_name}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY programs
)
endfunction ()
function (lsf_build_program_extra prog_name extra_libs)
add_executable (${prog_name}
programs/common.c
programs/${prog_name}.c
)
target_link_libraries (${prog_name} sndfile ${extra_libs})
set_target_properties (${prog_name}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY programs
)
endfunction ()
# Build recipe for building C tests in the src/ directory.
function (lsf_build_src_test_c test_name extra_files)
add_executable (${test_name}
src/${test_name}.c
${extra_files}
)
target_link_libraries (${test_name} m)
set_target_properties (${test_name}
PROPERTIES
EXCLUDE_FROM_DEFAULT_BUILD TRUE
EXCLUDE_FROM_ALL TRUE
RUNTIME_OUTPUT_DIRECTORY src
)
add_dependencies (check ${test_name})
endfunction ()
# Build recipe for building C tests in the tests/ directory.
function (lsf_build_test_c test_name extra_files)
add_executable (${test_name}
tests/${test_name}.c
tests/utils.c
${extra_files}
)
target_link_libraries (${test_name} sndfile)
set_target_properties (${test_name}
PROPERTIES
EXCLUDE_FROM_DEFAULT_BUILD TRUE
EXCLUDE_FROM_ALL TRUE
RUNTIME_OUTPUT_DIRECTORY tests
)
add_dependencies (check ${test_name})
endfunction ()
# Build recipe for building C++ tests in the tests/ directory.
function (lsf_build_test_cc test_name)
add_executable (${test_name}
tests/utils.c
tests/${test_name}.cc
)
target_link_libraries (${test_name} sndfile)
set_target_properties (${test_name}
PROPERTIES
EXCLUDE_FROM_DEFAULT_BUILD TRUE
EXCLUDE_FROM_ALL TRUE
RUNTIME_OUTPUT_DIRECTORY tests
)
add_dependencies (check ${test_name})
endfunction ()

View File

@ -1,92 +0,0 @@
include (CheckFunctionExists)
include (CheckIncludeFile)
include (CheckLibraryExists)
include (CheckTypeSize)
include (TestBigEndian)
function (lsf_try_compile_c_result c_file result_name result_pass result_fail)
try_compile (compile_result
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/${c_file}
OUTPUT_VARIABLE LOG2
)
if (${compile_result})
set (${result_name} ${result_pass} PARENT_SCOPE)
else (${compile_result})
set (${result_name} ${result_fail} PARENT_SCOPE)
endif (${compile_result})
endfunction ()
function (lsf_check_include_file header_name result_name)
check_include_file (${header_name} header_${result_name})
if (header_${result_name})
set (${result_name} 1 PARENT_SCOPE)
else (header_${result_name})
set (${result_name} 0 PARENT_SCOPE)
endif (header_${result_name})
unset (header_${result_name})
endfunction ()
function (lsf_check_type_size type_name result_size)
string (REPLACE "*" "_P" tmp1 ${type_name})
string (REPLACE " " "_" tmp2 ${tmp1})
check_type_size (${type_name} size_${tmp2})
if (size_${type_name})
set (${result_size} ${size_${type_name}} PARENT_SCOPE)
else (size_${type_name})
set (${result_size} 0 PARENT_SCOPE)
endif (size_${type_name})
unset (tmp1)
unset (tmp2)
unset (size_${tmp2})
endfunction ()
function (lsf_check_function_exists func_name result_name)
check_function_exists (${func_name} func_${result_name})
if (func_${result_name})
set (${result_name} 1 PARENT_SCOPE)
else (func_${result_name})
set (${result_name} 0 PARENT_SCOPE)
endif (func_${result_name})
unset (func_${result_name})
endfunction ()
# Unix does not link libm by default while windows does. We therefore have
# a special function for testing math functions.
function (lsf_check_math_function_exists func_name result_name)
if (${UNIX})
check_library_exists (m ${func_name} "" func_${result_name})
else (${UNIX})
check_function_exists (${func_name} func_${result_name})
endif (${UNIX})
if (func_${result_name})
set (${result_name} 1 PARENT_SCOPE)
else (func_${result_name})
set (${result_name} 0 PARENT_SCOPE)
endif (func_${result_name})
unset (func_${result_name})
endfunction ()
function (lsf_check_library_exists lib_name lib_func location result_name)
check_library_exists (${lib_name} ${lib_func} "${location}" lib_${result_name})
if (lib_${result_name})
set (${result_name} 1 PARENT_SCOPE)
else (lib_${result_name})
set (${result_name} 0 PARENT_SCOPE)
endif (lib_${result_name})
unset (lib_${result_name})
endfunction ()

View File

@ -1,11 +0,0 @@
int main (void)
{
#if __GNUC__
#if __clang__
This is clang
# endif
#else
This is not GCC.
#endif
return 0 ;
}

View File

@ -1,99 +0,0 @@
find_package (PkgConfig)
include (FindPackageHandleStandardArgs)
function (find_libogg return_name)
pkg_check_modules (PC_LIBOGG QUIET libogg)
set (LIBOGG_DEFINITIONS ${PC_LIBOGG_CFLAGS_OTHER})
find_path (LIBOGG_INCLUDE_DIR ogg/ogg.h
HINTS ${PC_LIBOGG_INCLUDEDIR} ${PC_LIBOGG_INCLUDE_DIRS}
PATH_SUFFIXES libogg)
find_library (LIBOGG_LIBRARY NAMES ogg libogg
HINTS ${PC_LIBOGG_LIBDIR} ${PC_LIBOGG_LIBRARY_DIRS})
find_package_handle_standard_args (LibOgg DEFAULT_MSG
LIBOGG_LIBRARY LIBOGG_INCLUDE_DIR)
mark_as_advanced (LIBOGG_INCLUDE_DIR LIBOGG_LIBRARY)
set (LIBOGG_LIBRARIES ${LIBOGG_LIBRARY} PARENT_SCOPE)
set (LIBOGG_INCLUDE_DIRS ${LIBOGG_INCLUDE_DIR} PARENT_SCOPE)
set (${return_name} ${LIBOGG_FOUND} PARENT_SCOPE)
endfunction (find_libogg)
function (find_libvorbis return_name)
pkg_check_modules (PC_LIBVORBIS QUIET libvorbis)
set (LIBVORBIS_DEFINITIONS ${PC_LIBVORBIS_CFLAGS_OTHER})
find_path (LIBVORBIS_INCLUDE_DIR vorbis/codec.h
HINTS ${PC_LIBVORBIS_INCLUDEDIR} ${PC_LIBVORBIS_INCLUDE_DIRS}
PATH_SUFFIXES libvorbis)
find_library (LIBVORBIS_LIBRARY NAMES vorbis libvorbis
HINTS ${PC_LIBVORBIS_LIBDIR} ${PC_LIBVORBIS_LIBRARY_DIRS})
find_package_handle_standard_args (LibVorbis DEFAULT_MSG
LIBVORBIS_LIBRARY LIBVORBIS_INCLUDE_DIR)
mark_as_advanced (LIBVORBIS_INCLUDE_DIR LIBVORBIS_LIBRARY)
set (LIBVORBIS_LIBRARIES ${LIBVORBIS_LIBRARY} PARENT_SCOPE)
set (LIBVORBIS_INCLUDE_DIRS ${LIBVORBIS_INCLUDE_DIR} PARENT_SCOPE)
set (${return_name} ${LIBVORBIS_FOUND} PARENT_SCOPE)
endfunction (find_libvorbis)
function (find_libflac return_name)
pkg_check_modules (PC_LIBFLAC QUIET libFLAC)
set (LIBFLAC_DEFINITIONS ${PC_LIBFLAC_CFLAGS_OTHER})
find_path (LIBFLAC_INCLUDE_DIR FLAC/all.h
HINTS ${PC_LIBFLAC_INCLUDEDIR} ${PC_LIBFLAC_INCLUDE_DIRS}
PATH_SUFFIXES libFLAC)
find_library (LIBFLAC_LIBRARY NAMES FLAC libFLAC
HINTS ${PC_LIBFLAC_LIBDIR} ${PC_LIBFLAC_LIBRARY_DIRS})
find_package_handle_standard_args (LibFlac DEFAULT_MSG
LIBFLAC_LIBRARY LIBFLAC_INCLUDE_DIR)
mark_as_advanced (LIBFLAC_INCLUDE_DIR LIBFLAC_LIBRARY)
set (LIBFLAC_LIBRARIES ${LIBFLAC_LIBRARY} PARENT_SCOPE)
set (LIBFLAC_INCLUDE_DIRS ${LIBFLAC_INCLUDE_DIR} PARENT_SCOPE)
set (${return_name} ${LIBFLAC_FOUND} PARENT_SCOPE)
endfunction (find_libflac)
function (find_external_xiph_libs return_name include_dirs external_libs)
find_libogg (LIBOGG_FOUND)
find_libvorbis (LIBVORBIS_FOUND)
find_libflac (LIBFLAC_FOUND)
set (name 1)
set (includes "")
set (libs "")
if (LIBOGG_FOUND AND LIBVORBIS_FOUND AND LIBFLAC_FOUND)
set (${name} 1)
if (NOT (LIBOGG_INCLUDE_DIR STREQUAL "/usr/include"))
set (${includes} "${includes} ${LIBOGG_INCLUDE_DIR}")
endif ()
if (NOT (LIBVORBIS_INCLUDE_DIR STREQUAL "/usr/include"))
set (${includes} "${includes} ${LIBVORBIS_INCLUDE_DIR}")
endif ()
if (NOT (LIBFLAC_INCLUDE_DIR STREQUAL "/usr/include"))
set (${includes} "${includes} ${LIBFLAC_INCLUDE_DIR}")
endif ()
set (libs "FLAC;vorbis;vorbisenc;ogg")
endif ()
set (${return_name} ${name} PARENT_SCOPE)
set (${include_dirs} "${includes}" PARENT_SCOPE)
set (${external_libs} "${libs}" PARENT_SCOPE)
endfunction (find_external_xiph_libs)

View File

@ -1,37 +0,0 @@
function (file_line_count filename variable)
# Assume `find_progam (WC wc)` has already set this.
if (NOT WC)
message (FATAL_ERROR "Need the 'wc' program to find line coount.")
endif ()
if (NOT SED)
message (FATAL_ERROR "Need the 'sed' program to find line coount.")
endif ()
if (NOT (EXISTS "${filename}"))
message (FATAL_ERROR "File ${filename} does not exist.")
endif ()
execute_process (
COMMAND ${WC} -l ${filename}
COMMAND ${SED} "s/^[ ]*//" # wc output on Mac has leading whitespace.
COMMAND ${SED} "s/ .*//"
OUTPUT_VARIABLE line_count
)
# Tedious!
string (STRIP ${line_count} line_count)
set (${variable} ${line_count} PARENT_SCOPE)
endfunction ()
function (assert_line_count_non_zero filename)
file_line_count (${filename} line_count)
if (${line_count} LESS 1)
message (FATAL_ERROR "Line count of ${filename} is ${line_count}, which is less than expected.")
endif ()
endfunction ()

View File

@ -1,6 +0,0 @@
#include <sys/stat.h>
int main (void)
{
/* This will fail to compile if S_IRGRP doesn't exist. */
return S_IRGRP ;
}

View File

@ -1,113 +0,0 @@
include (CMake/check.cmake)
lsf_check_include_file (alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H)
lsf_check_include_file (byteswap.h HAVE_BYTESWAP_H)
lsf_check_include_file (dlfcn.h HAVE_DLFCN_H)
lsf_check_include_file (endian.h HAVE_ENDIAN_H)
lsf_check_include_file (inttypes.h HAVE_INTTYPES_H)
lsf_check_include_file (locale.h HAVE_LOCALE_H)
lsf_check_include_file (memory.h HAVE_MEMORY_H)
lsf_check_include_file (sndio.h HAVE_SNDIO_H)
lsf_check_include_file (stdint.h HAVE_STDINT_H)
lsf_check_include_file (stdlib.h HAVE_STDLIB_H)
lsf_check_include_file (string.h HAVE_STRING_H)
lsf_check_include_file (strings.h HAVE_STRINGS_H)
lsf_check_include_file (sys/stat.h HAVE_SYS_STAT_H)
lsf_check_include_file (sys/time.h HAVE_SYS_TIME_H)
lsf_check_include_file (sys/types.h HAVE_SYS_TYPES_H)
lsf_check_include_file (sys/wait.h HAVE_SYS_WAIT_H)
lsf_check_include_file (unistd.h HAVE_UNISTD_H)
lsf_check_type_size (double SIZEOF_DOUBLE)
lsf_check_type_size (float SIZEOF_FLOAT)
lsf_check_type_size (int SIZEOF_INT)
lsf_check_type_size (int64_t SIZEOF_INT64_T)
lsf_check_type_size (loff_t SIZEOF_LOFF_T)
lsf_check_type_size (long SIZEOF_LONG)
lsf_check_type_size (long\ long SIZEOF_LONG_LONG)
lsf_check_type_size (offt64_t SIZEOF_OFF64_T)
lsf_check_type_size (off_t SIZEOF_OFF_T)
lsf_check_type_size (short SIZEOF_SHORT)
lsf_check_type_size (size_t SIZEOF_SIZE_T)
lsf_check_type_size (ssize_t SIZEOF_SSIZE_T)
lsf_check_type_size (void* SIZEOF_VOIDP)
lsf_check_type_size (wchar_t SIZEOF_WCHAR_T)
set (SIZEOF_SF_COUNT_T ${SIZEOF_INT64_T})
set (TYPEOF_SF_COUNT_T int64_t)
set (SF_COUNT_MAX 0x7fffffffffffffffll)
# Can't figure out how to make CMAKE_COMPILER_IS_GNUCC set something to either
# 1 or 0 so we do this:
lsf_try_compile_c_result (CMake/compiler_is_gcc.c COMPILER_IS_GCC 1 0)
lsf_try_compile_c_result (CMake/have_decl_s_irgrp.c HAVE_DECL_S_IRGRP 1 0)
TEST_BIG_ENDIAN (BIGENDIAN)
if (${BIGENDIAN})
set (WORDS_BIGENDIAN 1)
set (CPU_IS_BIG_ENDIAN 1)
set (CPU_IS_LITTLE_ENDIAN 0)
else (${BIGENDIAN})
set (WORDS_BIGENDIAN 0)
set (CPU_IS_LITTLE_ENDIAN 1)
set (CPU_IS_BIG_ENDIAN 0)
endif (${BIGENDIAN})
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set (OS_IS_WIN32 1)
set (USE_WINDOWS_API 1)
set (USE_WINDOWS_API 1)
set (WIN32_TARGET_DLL 1)
set (__USE_MINGW_ANSI_STDIO 1)
else (${WINDOWS})
set (OS_IS_WIN32 0)
set (USE_WINDOWS_API 0)
set (USE_WINDOWS_API 0)
set (WIN32_TARGET_DLL 0)
set (__USE_MINGW_ANSI_STDIO 0)
endif ()
if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
set (OS_IS_OPENBSD 1)
else ()
set (OS_IS_OPENBSD 0)
endif ()
lsf_check_library_exists (m floor "" HAVE_LIBM)
lsf_check_library_exists (sqlite3 sqlite3_close "" HAVE_SQLITE3)
lsf_check_function_exists (calloc HAVE_CALLOC)
lsf_check_function_exists (free HAVE_FREE)
lsf_check_function_exists (fstat HAVE_FSTAT)
lsf_check_function_exists (fstat64 HAVE_FSTAT64)
lsf_check_function_exists (fsync HAVE_FSYNC)
lsf_check_function_exists (ftruncate HAVE_FTRUNCATE)
lsf_check_function_exists (getpagesize HAVE_GETPAGESIZE)
lsf_check_function_exists (gettimeofday HAVE_GETTIMEOFDAY)
lsf_check_function_exists (gmtime HAVE_GMTIME)
lsf_check_function_exists (gmtime_r HAVE_GMTIME_R)
lsf_check_function_exists (localtime HAVE_LOCALTIME)
lsf_check_function_exists (localtime_r HAVE_LOCALTIME_R)
lsf_check_function_exists (lseek HAVE_LSEEK)
lsf_check_function_exists (lseek64 HAVE_LSEEK64)
lsf_check_function_exists (malloc HAVE_MALLOC)
lsf_check_function_exists (mmap HAVE_MMAP)
lsf_check_function_exists (open HAVE_OPEN)
lsf_check_function_exists (pipe HAVE_PIPE)
lsf_check_function_exists (read HAVE_READ)
lsf_check_function_exists (realloc HAVE_REALLOC)
lsf_check_function_exists (setlocale HAVE_SETLOCALE)
lsf_check_function_exists (snprintf HAVE_SNPRINTF)
lsf_check_function_exists (vsnprintf HAVE_VSNPRINTF)
lsf_check_function_exists (waitpid HAVE_WAITPID)
lsf_check_function_exists (write HAVE_WRITE)
lsf_check_math_function_exists (ceil HAVE_CEIL)
lsf_check_math_function_exists (floor HAVE_FLOOR)
lsf_check_math_function_exists (fmod HAVE_FMOD)
lsf_check_math_function_exists (lrint HAVE_LRINT)
lsf_check_math_function_exists (lrintf HAVE_LRINTF)
lsf_check_math_function_exists (lround HAVE_LROUND)

File diff suppressed because it is too large Load Diff

View File

@ -14,14 +14,14 @@ if FULL_SUITE
SUBDIRS += man doc $(octave_dir) regtest programs
endif
DIST_SUBDIRS = M4 man doc Win32 src Octave examples regtest tests programs
DIST_SUBDIRS = M4 cmake man doc Win32 src Octave examples regtest tests programs
EXTRA_DIST = libsndfile.spec.in sndfile.pc.in Scripts/android-configure.sh \
Scripts/linux-to-win-cross-configure.sh Scripts/build-test-tarball.mk.in \
CMakeLists.txt CMake/autogen.cmake CMake/build.cmake CMake/check.cmake \
CMake/compiler_is_gcc.c CMake/external_libs.cmake CMake/file.cmake \
CMake/have_decl_s_irgrp.c CMake/libsndfile.cmake .editorconfig
CMake/have_decl_s_irgrp.c CMake/libsndfile.cmake .editorconfig \
CMakeLists.txt sndfile.pc.cmake.in
CLEANFILES = *~

92
cmake/ClipMode.cmake Normal file
View File

@ -0,0 +1,92 @@
include (CheckCSourceRuns)
include (CMakePushCheckState)
macro (CLIP_MODE)
set (CLIP_MODE_POSITIVE_MESSAGE "Target processor clips on positive float to int conversion")
set (CLIP_MODE_NEGATIVE_MESSAGE "Target processor clips on negative float to int conversion")
message (STATUS "Checking processor clipping capabilities...")
if (CMAKE_CROSSCOMPILING)
set (CLIP_MSG "disabled")
set (CPU_CLIPS_POSITIVE FALSE CACHE BOOL ${CLIP_MODE_POSITIVE_MESSAGE})
set (CPU_CLIPS_NEGATIVE FALSE CACHE BOOL ${CLIP_MODE_NEGATIVE_MESSAGE})
else (NOT CMAKE_CROSSCOMPILING)
cmake_push_check_state ()
set (CMAKE_REQUIRED_QUIET TRUE)
if (LIBM_REQUIRED)
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY})
endif ()
check_c_source_runs (
"
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC99 1
#define __USE_ISOC9X 1
#include <math.h>
int main (void)
{ double fval ;
int k, ival ;
fval = 1.0 * 0x7FFFFFFF ;
for (k = 0 ; k < 100 ; k++)
{ ival = (lrint (fval)) >> 24 ;
if (ival != 127)
return 1 ;
fval *= 1.2499999 ;
} ;
return 0 ;
}
"
CPU_CLIPS_POSITIVE)
check_c_source_runs (
"
#define _ISOC9X_SOURCE 1
#define _ISOC99_SOURCE 1
#define __USE_ISOC99 1
#define __USE_ISOC9X 1
#include <math.h>
int main (void)
{ double fval ;
int k, ival ;
fval = -8.0 * 0x10000000 ;
for (k = 0 ; k < 100 ; k++)
{ ival = (lrint (fval)) >> 24 ;
if (ival != -128)
return 1 ;
fval *= 1.2499999 ;
} ;
return 0 ;
}
"
CPU_CLIPS_NEGATIVE)
cmake_pop_check_state ()
if (CPU_CLIPS_POSITIVE AND (NOT CPU_CLIPS_NEGATIVE))
set (CLIP_MSG "positive")
elseif (CPU_CLIPS_NEGATIVE AND (NOT CPU_CLIPS_POSITIVE))
set (CLIP_MSG "negative")
elseif (CPU_CLIPS_POSITIVE AND CPU_CLIPS_NEGATIVE)
set (CLIP_MSG "both")
else ()
set (CLIP_MSG "none")
endif ()
endif (CMAKE_CROSSCOMPILING)
message (STATUS "Checking processor clipping capabilities... ${CLIP_MSG}")
endmacro (CLIP_MODE)

47
cmake/FindFLAC.cmake Normal file
View File

@ -0,0 +1,47 @@
# - Find FLAC
# Find the native FLAC includes and libraries
#
# FLAC_INCLUDE_DIRS - where to find FLAC headers.
# FLAC_LIBRARIES - List of libraries when using libFLAC.
# FLAC_FOUND - True if libFLAC found.
# FLAC_DEFINITIONS - FLAC compile definitons
if (FLAC_INCLUDE_DIR)
# Already in cache, be silent
set (FLAC_FIND_QUIETLY TRUE)
endif (FLAC_INCLUDE_DIR)
find_package (Ogg QUIET)
find_package (PkgConfig QUIET)
pkg_check_modules(PC_FLAC QUIET flac)
find_path (FLAC_INCLUDE_DIR FLAC/stream_decoder.h
HINTS ${PC_FLAC_INCLUDEDIR} ${PC_FLAC_INCLUDE_DIRS} ${FLAC_ROOT}
PATH_SUFFIXES include)
# MSVC built libraries can name them *_static, which is good as it
# distinguishes import libraries from static libraries with the same extension.
find_library (FLAC_LIBRARY NAMES FLAC libFLAC libFLAC_dynamic libFLAC_static
HINTS ${PC_FLAC_LIBDIR} ${PC_FLAC_LIBRARY_DIRS} ${FLAC_ROOT}
PATH_SUFFIXES lib)
# Handle the QUIETLY and REQUIRED arguments and set FLAC_FOUND to TRUE if
# all listed variables are TRUE.
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (FLAC DEFAULT_MSG
FLAC_INCLUDE_DIR FLAC_LIBRARY)
if (FLAC_FOUND)
set (FLAC_INCLUDE_DIRS ${FLAC_INCLUDE_DIR} ${OGG_INCLUDE_DIRS})
set (FLAC_LIBRARIES ${FLAC_LIBRARY} ${OGG_LIBRARIES})
if (WIN32)
set (FLAC_LIBRARIES ${FLAC_LIBRARIES} wsock32)
get_filename_component (FLAC_LIBRARY_FILENAME ${FLAC_LIBRARY} NAME_WE)
if (FLAC_LIBRARY_FILENAME MATCHES "libFLAC_static")
set (FLAC_DEFINITIONS -DFLAC__NO_DLL)
endif ()
endif (WIN32)
endif (FLAC_FOUND)
mark_as_advanced(FLAC_INCLUDE_DIR FLAC_LIBRARY)

30
cmake/FindOgg.cmake Normal file
View File

@ -0,0 +1,30 @@
# - Find ogg
# Find the native ogg includes and libraries
#
# OGG_INCLUDE_DIRS - where to find ogg.h, etc.
# OGG_LIBRARIES - List of libraries when using ogg.
# Ogg_FOUND - True if ogg found.
if(OGG_INCLUDE_DIR)
# Already in cache, be silent
set(OGG_FIND_QUIETLY TRUE)
endif(OGG_INCLUDE_DIR)
find_package (PkgConfig QUIET)
pkg_check_modules(PC_OGG QUIET ogg)
find_path(OGG_INCLUDE_DIR ogg/ogg.h HINTS ${PC_OGG_INCLUDEDIR} ${PC_OGG_INCLUDE_DIRS} ${OGG_ROOT} PATH_SUFFIXES include)
# MSVC built ogg may be named ogg_static.
# The provided project files name the library with the lib prefix.
find_library(OGG_LIBRARY NAMES ogg ogg_static libogg libogg_static HINTS ${PC_OGG_LIBDIR} ${PC_OGG_LIBRARY_DIRS} ${OGG_ROOT} PATH_SUFFIXES lib)
# Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND
# to TRUE if all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Ogg DEFAULT_MSG OGG_INCLUDE_DIR OGG_LIBRARY)
if (OGG_FOUND)
set (OGG_LIBRARIES ${OGG_LIBRARY})
set (OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR})
endif (OGG_FOUND)
mark_as_advanced(OGG_INCLUDE_DIR OGG_LIBRARY)

33
cmake/FindSndio.cmake Normal file
View File

@ -0,0 +1,33 @@
# - Find SoundIO (sndio) includes and libraries
#
# Sndio_FOUND - True if SNDIO_INCLUDE_DIR & SNDIO_LIBRARY are
# found
# SNDIO_LIBRARIES - Set when SNDIO_LIBRARY is found
# SNDIO_INCLUDE_DIRS - Set when SNDIO_INCLUDE_DIR is found
#
# SNDIO_INCLUDE_DIR - where to find sndio.h, etc.
# SNDIO_LIBRARY - the sndio library
#
find_path(SNDIO_INCLUDE_DIR
NAMES sndio.h
DOC "The SoundIO include directory"
)
find_library(SNDIO_LIBRARY
NAMES sndio
DOC "The SoundIO library"
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sndio
REQUIRED_VARS SNDIO_LIBRARY SNDIO_INCLUDE_DIR
)
if(Sndio_FOUND)
set(SNDIO_LIBRARIES ${SNDIO_LIBRARY})
set(SNDIO_INCLUDE_DIRS ${SNDIO_INCLUDE_DIR})
endif()
mark_as_advanced(SNDIO_INCLUDE_DIR SNDIO_LIBRARY)

25
cmake/FindSpeex.cmake Normal file
View File

@ -0,0 +1,25 @@
# - Find Speex
# Find the native Speex includes and libraries
#
# SPEEX_INCLUDE_DIRS - where to find speex.h, etc.
# SPEEX_LIBRARIES - List of libraries when using Speex.
# Speex_FOUND - True if Speex found.
if (SPEEX_INCLUDE_DIR)
set (SPEEX_FIND_QUIETLY TRUE)
endif ()
find_package (PkgConfig QUIET)
pkg_check_modules(PC_SPEEX QUIET speex)
find_path (SPEEX_INCLUDE_DIR speex/speex.h HINTS ${PC_SPEEX_INCLUDEDIR} ${PC_SPEEX_INCLUDE_DIRS} ${SPEEX_ROOT} PATH_SUFFIXES include)
find_library (SPEEX_LIBRARY NAMES speex HINTS ${PC_SPEEX_LIBDIR} ${PC_SPEEX_LIBRARY_DIRS} ${SPEEX_ROOT} PATH_SUFFIXES lib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Speex DEFAULT_MSG SPEEX_INCLUDE_DIR SPEEX_LIBRARY)
mark_as_advanced (SPEEX_INCLUDE_DIR SPEEX_LIBRARY)
set(SPEEX_INCLUDE_DIRS ${SPEEX_INCLUDE_DIR})
set(SPEEX_LIBRARIES ${SPEEX_LIBRARY})

49
cmake/FindVorbis.cmake Normal file
View File

@ -0,0 +1,49 @@
# - Find vorbis
# Find the native vorbis includes and libraries
#
# VORBIS_INCLUDE_DIRS - where to find vorbis.h, etc.
# VORBIS_LIBRARIES - List of libraries when using vorbis(file).
# Vorbis_FOUND - True if vorbis found.
if(VORBIS_INCLUDE_DIR)
# Already in cache, be silent
set(VORBIS_FIND_QUIETLY TRUE)
endif(VORBIS_INCLUDE_DIR)
find_package (Ogg QUIET)
find_package (PkgConfig QUIET)
pkg_check_modules(PC_VORBIS QUIET vorbis)
pkg_check_modules(PC_VORBISFILE QUIET vorbisfile)
pkg_check_modules(PC_VORBISENC QUIET vorbisenc)
find_path(VORBIS_INCLUDE_DIR vorbis/codec.h vorbis/vorbisfile.h vorbis/vorbisfile.h
HINTS ${PC_VORBIS_INCLUDEDIR} ${PC_VORBIS_INCLUDE_DIRS} ${VORBIS_ROOT}
PATH_SUFFIXES include)
# MSVC built vorbis may be named vorbis_static
# The provided project files name the library with the lib prefix.
find_library(VORBIS_LIBRARY
NAMES vorbis vorbis_static libvorbis libvorbis_static
HINTS ${PC_VORBIS_LIBDIR} ${PC_VORBIS_LIBRARY_DIRS} ${VORBIS_ROOT}
PATH_SUFFIXES lib)
find_library(VORBISFILE_LIBRARY
NAMES vorbisfile vorbisfile_static libvorbisfile libvorbisfile_static
HINTS ${PC_VORBISFILE_LIBDIR} ${PC_VORBISFILE_LIBRARY_DIRS} ${VORBIS_ROOT}
PATH_SUFFIXES lib)
find_library(VORBISENC_LIBRARY
NAMES vorbisenc vorbisenc_static libvorbisenc libvorbisenc_static
HINTS ${PC_VORBISENC_LIBDIR} ${PC_VORBISENC_LIBRARY_DIRS} ${VORBIS_ROOT}
PATH_SUFFIXES lib)
# Handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND
# to TRUE if all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Vorbis DEFAULT_MSG VORBIS_INCLUDE_DIR VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY)
if (VORBIS_FOUND)
set (VORBIS_INCLUDE_DIRS ${VORBIS_INCLUDE_DIR} ${OGG_INCLUDE_DIRS})
set (VORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${VORBISENC_LIBRARY}
${OGG_LIBRARIES})
endif (VORBIS_FOUND)
mark_as_advanced(VORBIS_INCLUDE_DIR VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY)

3
cmake/Makefile.am Normal file
View File

@ -0,0 +1,3 @@
EXTRA_DIST = FindFLAC.cmake FindOgg.cmake FindSndio.cmake \
FindSpeex.cmake FindVorbis.cmake SndFileChecks.cmake \
TestInline.cmake TestInline.c.in TestLargeFiles.cmake

198
cmake/SndFileChecks.cmake Normal file
View File

@ -0,0 +1,198 @@
include (CheckFunctionExists)
include (CheckIncludeFile)
include (CheckLibraryExists)
include (CheckSymbolExists)
include (CheckTypeSize)
include (TestBigEndian)
include (TestInline)
include (ClipMode)
include(TestLargeFiles)
test_large_files(_LARGEFILES)
if (LARGE_FILES_DEFINITIONS)
add_definitions(${LARGE_FILES_DEFINITIONS})
endif ()
if (WIN32)
set(TYPEOF_SF_COUNT_T __int64)
else (UNIX)
set(TYPEOF_SF_COUNT_T int64_t)
endif ()
set(SF_COUNT_MAX 0x7fffffffffffffffll)
if (NOT WIN32)
find_package (ALSA)
if (ALSA_FOUND)
set (HAVE_ALSA_ASOUNDLIB_H TRUE)
else ()
find_package (Sndio)
set (HAVE_SNDIO_H ${SNDIO_FOUND})
endif (ALSA_FOUND)
endif ()
if (NOT DISABLE_EXTERNAL_LIBS)
find_package (Ogg)
find_package (Vorbis)
find_package (FLAC)
if (OGG_FOUND AND VORBIS_FOUND AND FLAC_FOUND)
set (HAVE_EXTERNAL_XIPH_LIBS 1)
set (EXTERNAL_XIPH_LIBS
${OGG_LIBRARIES}
${VORBIS_LIBRARIES}
${FLAC_LIBRARIES})
else ()
set (DISABLE_EXTERNAL_LIBS ON)
endif ()
endif ()
if (ENABLE_EXPERIMENTAL)
find_package (Speex)
endif ()
check_include_file(byteswap.h HAVE_BYTESWAP_H)
check_include_file(dlfcn.h HAVE_DLFCN_H)
check_include_file(endian.h HAVE_ENDIAN_H)
check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(locale.h HAVE_LOCALE_H)
check_include_file(memory.h HAVE_MEMORY_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stdlib.h HAVE_STDLIB_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(sys/wait.h HAVE_SYS_WAIT_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(io.h HAVE_IO_H)
check_type_size(int64_t SIZEOF_INT64_T)
check_type_size(double SIZEOF_DOUBLE)
check_type_size(float SIZEOF_FLOAT)
check_type_size(int SIZEOF_INT)
check_type_size(loff_t SIZEOF_LOFF_T)
check_type_size(long SIZEOF_LONG)
check_type_size(long\ long SIZEOF_LONG_LONG)
check_type_size(offt64_t SIZEOF_OFF64_T)
check_type_size(short SIZEOF_SHORT)
check_type_size(size_t SIZEOF_SIZE_T)
check_type_size(ssize_t SIZEOF_SSIZE_T)
check_type_size(void* SIZEOF_VOIDP)
check_type_size(wchar_t SIZEOF_WCHAR_T)
if ((SIZEOF_OFF_T EQUAL 8) OR (SIZEOF_LOFF_T EQUAL 8) OR (SIZEOF_OFF64_T EQUAL 8))
set (TYPEOF_SF_COUNT_T "int64_t")
set (SF_COUNT_MAX "0x7FFFFFFFFFFFFFFFLL")
set (SIZEOF_SF_COUNT_T 8)
else ()
if (WIN32)
set (TYPEOF_SF_COUNT_T "__int64")
set (SF_COUNT_MAX "0x7FFFFFFFFFFFFFFFLL")
set (SIZEOF_SF_COUNT_T 8)
else (NOT WIN32)
message ("")
message ("*** The configure process has determined that this system is capable")
message ("*** of Large File Support but has not been able to find a type which")
message ("*** is an unambiguous 64 bit file offset.")
message ("*** Please contact the author to help resolve this problem.")
message ("")
message (FATAL_ERROR "Bad file offset type.")
endif (WIN32)
endif ()
check_type_size(${TYPEOF_SF_COUNT_T} SIZEOF_SF_COUNT_T)
find_library (M_LIBRARY m)
if (M_LIBRARY)
# Check if he need to link 'm' for math functions
check_library_exists (m floor "" LIBM_REQUIRED)
if (LIBM_REQUIRED)
list (APPEND CMAKE_REQUIRED_LIBRARIES ${M_LIBRARY})
else ()
unset (M_LIBRARY)
endif ()
endif ()
check_library_exists (sqlite3 sqlite3_close "" HAVE_SQLITE3)
check_function_exists(calloc HAVE_CALLOC)
check_function_exists(free HAVE_FREE)
check_function_exists(fstat HAVE_FSTAT)
check_function_exists(fstat64 HAVE_FSTAT64)
check_function_exists(fsync HAVE_FSYNC)
check_function_exists(ftruncate HAVE_FTRUNCATE)
check_function_exists(getpagesize HAVE_GETPAGESIZE)
check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
check_function_exists(gmtime HAVE_GMTIME)
check_function_exists(gmtime_r HAVE_GMTIME_R)
check_function_exists(localtime HAVE_LOCALTIME)
check_function_exists(localtime_r HAVE_LOCALTIME_R)
check_function_exists(lseek HAVE_LSEEK)
check_function_exists(lseek64 HAVE_LSEEK64)
check_function_exists(malloc HAVE_MALLOC)
check_function_exists(mmap HAVE_MMAP)
check_function_exists(open HAVE_OPEN)
check_function_exists(pipe HAVE_PIPE)
check_function_exists(read HAVE_READ)
check_function_exists(realloc HAVE_REALLOC)
check_function_exists(setlocale HAVE_SETLOCALE)
check_function_exists(snprintf HAVE_SNPRINTF)
check_function_exists(vsnprintf HAVE_VSNPRINTF)
check_function_exists(waitpid HAVE_WAITPID)
check_function_exists(write HAVE_WRITE)
check_function_exists(ceil HAVE_CEIL)
check_function_exists(floor HAVE_FLOOR)
check_function_exists(fmod HAVE_FMOD)
check_function_exists(lrint HAVE_LRINT)
check_function_exists(lrintf HAVE_LRINTF)
check_function_exists(lround HAVE_LROUND)
check_symbol_exists (S_IRGRP sys/stat.h HAVE_DECL_S_IRGRP)
test_big_endian(WORDS_BIGENDIAN)
if (WORDS_BIGENDIAN)
set (WORDS_BIGENDIAN 1)
set (CPU_IS_BIG_ENDIAN 1)
else (${LITTLE_ENDIAN})
set (CPU_IS_LITTLE_ENDIAN 1)
endif ()
if (WIN32)
set (OS_IS_WIN32 1)
set (USE_WINDOWS_API 1)
if (BUILD_SHARED_LIBS)
set (WIN32_TARGET_DLL 1)
endif ()
if (MINGW)
set (__USE_MINGW_ANSI_STDIO 1)
endif (MINGW)
endif (WIN32)
if (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
set (OS_IS_OPENBSD 1)
endif ()
if (CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
set (COMPILER_IS_GCC 1)
endif ()
if (COMPILER_IS_GCC)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
endif ()
if (ENABLE_EXPERIMENTAL)
set (ENABLE_EXPERIMENTAL_CODE 1)
endif ()
test_inline ()
if (NOT DISABLE_CPU_CLIP)
clip_mode ()
endif ()
find_program (AUTOGEN_EXECUTABLE NAMES autogen)
if (NOT AUTOGEN_EXECUTABLE)
message ("autogen tool not found: tests will not be build.")
SET (BUILD_TESTING OFF)
endif ()

10
cmake/TestInline.c.in Normal file
View File

@ -0,0 +1,10 @@
static @INLINE_KEYWORD@ void test_inline(void)
{
return;
}
int main (void)
{
test_inline ();
return 0;
}

54
cmake/TestInline.cmake Normal file
View File

@ -0,0 +1,54 @@
macro (TEST_INLINE)
if (NOT DEFINED INLINE_CODE)
message (STATUS "Checking for inline...")
set (INLINE_KEYWORD "inline")
configure_file (${CMAKE_SOURCE_DIR}/cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c)
try_compile (HAVE_INLINE "${CMAKE_CURRENT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c")
if (HAVE_INLINE)
message (STATUS "Checking for inline... supported")
else ()
message (STATUS "Checking for inline... not supported")
message (STATUS "Checking for __inline...")
set (INLINE_KEYWORD "__inline")
configure_file (${CMAKE_SOURCE_DIR}/cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c)
try_compile (HAVE___INLINE "${CMAKE_CURRENT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c")
if (HAVE___INLINE)
message (STATUS "Checking for __inline... supported")
else ()
message (STATUS "Checking for __inline... not supported")
message (STATUS "Checking for __inline__...")
set (INLINE_KEYWORD "__inline__")
configure_file (${CMAKE_SOURCE_DIR}/cmake/TestInline.c.in ${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c)
try_compile (HAVE___INLINE "${CMAKE_CURRENT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c")
if (HAVE___INLINE)
message (STATUS "Checking for __inline__... supported")
message (STATUS "Checking for __inline__...")
set (INLINE_KEYWORD "__inline__")
configure_file (${CMAKE_SOURCE_DIR}/cmake/TestInline.c.in ${CMAKE_SOURCE_DIR}/cmake/TestInline.c)
try_compile (HAVE___INLINE__ "${CMAKE_CURRENT_BINARY_DIR}"
"${PROJECT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/TestInline.c")
else ()
message (STATUS "Checking for __inline__... not supported")
set (INLINE_KEYWORD "")
endif ()
endif ()
endif ()
if (HAVE_INLINE)
set (INLINE_CODE "/* #undef inline */" CACHE INTERNAL "")
elseif (HAVE___INLINE)
set (INLINE_CODE "#define inline __inline" CACHE INTERNAL "")
elseif (HAVE___INLINE__)
set (INLINE_CODE "#define inline __inline__" CACHE INTERNAL "")
else ()
set (INLINE_CODE "#define inline " CACHE INTERNAL "")
endif ()
endif ()
endmacro (TEST_INLINE)

113
cmake/TestLargeFiles.cmake Normal file
View File

@ -0,0 +1,113 @@
include (CheckIncludeFile)
include (CheckTypeSize)
include (CMakePushCheckState)
macro (TEST_LARGE_FILES VARIABLE)
if (NOT DEFINED ${VARIABLE})
cmake_push_check_state()
message (STATUS "")
message (STATUS "")
message (STATUS "Checking large files support...")
message (STATUS "")
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stddef.h HAVE_STDDEF_H)
message (STATUS "")
message (STATUS "Checking size of off_t without any definitions:")
check_type_size (off_t SIZEOF_OFF_T)
message (STATUS "Checking of off_t without any definitions: ${SIZEOF_OFF_T}")
if (SIZEOF_OFF_T EQUAL 8)
set (LARGE_FILES_DEFINITIONS "" CACHE INTERNAL "64-bit off_t required definitions")
set (FILE64 TRUE)
else ()
unset (HAVE_SIZEOF_OFF_T CACHE)
unset (SIZEOF_OFF_T CACHE)
unset (SIZEOF_OFF_T_CODE CACHE)
cmake_pop_check_state()
set (FILE64 FALSE)
endif ()
if (NOT FILE64)
set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_FILE_OFFSET_BITS=64)
message (STATUS "")
message (STATUS "Checking size of off_t with _FILE_OFFSET_BITS=64:")
check_type_size (off_t SIZEOF_OFF_T)
message (STATUS "Checking size of off_t with _FILE_OFFSET_BITS=64: ${SIZEOF_OFF_T}")
if (SIZEOF_OFF_T EQUAL 8)
set (_FILE_OFFSET_BITS 64 CACHE INTERNAL "")
set (_FILE_OFFSET_BITS_CODE "#define _FILE_OFFSET_BITS 64" CACHE INTERNAL "")
set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_FILE_OFFSET_BITS=64" CACHE INTERNAL "64-bit off_t required definitions")
set (FILE64 TRUE)
else ()
set (_FILE_OFFSET_BITS_CODE "" CACHE INTERNAL "")
unset (HAVE_SIZEOF_OFF_T CACHE)
unset (SIZEOF_OFF_T CACHE)
unset (SIZEOF_OFF_T_CODE CACHE)
cmake_pop_check_state()
set (FILE64 FALSE)
endif ()
endif ()
if (NOT FILE64)
set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_LARGE_FILES)
message (STATUS "")
message (STATUS "Checking size of off_t with _LARGE_FILES:")
check_type_size (off_t SIZEOF_OFF_T)
message (STATUS "Checking size of off_t with _LARGE_FILES: ${SIZEOF_OFF_T}")
if (SIZEOF_OFF_T EQUAL 8)
set (_LARGE_FILES 1 CACHE INTERNAL "")
set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_LARGE_FILES" CACHE INTERNAL "64-bit off_t required definitions")
set (FILE64 TRUE)
else ()
unset (HAVE_SIZEOF_OFF_T CACHE)
unset (SIZEOF_OFF_T CACHE)
unset (SIZEOF_OFF_T_CODE CACHE)
cmake_pop_check_state()
set (FILE64 FALSE)
endif ()
endif ()
if (NOT FILE64)
set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} /D_LARGEFILE_SOURCE)
unset (HAVE_SIZEOF_OFF_T CACHE)
unset (SIZEOF_OFF_T CACHE)
unset (SIZEOF_OFF_T_CODE CACHE)
message (STATUS "")
message (STATUS "Checking size of off_t with _LARGEFILE_SOURCE:")
check_type_size (off_t SIZEOF_OFF_T)
message (STATUS "Checking size of off_t with _LARGEFILE_SOURCE: ${SIZEOF_OFF_T}")
if (SIZEOF_OFF_T EQUAL 8)
set (_LARGEFILE_SOURCE 1 CACHE INTERNAL "")
set (LARGE_FILES_DEFINITIONS ${LARGE_FILES_DEFINITIONS} "/D_LARGEFILE_SOURCE" CACHE INTERNAL "64-bit off_t required definitions")
set (FILE64 TRUE)
else ()
cmake_pop_check_state()
set (FILE64 FALSE)
endif ()
endif ()
message (STATUS "")
if (FILE64)
set (${VARIABLE} 1 CACHE INTERNAL "Result of tests for large file support" FORCE)
if (NOT SIZEOF_OFF_T_REQURED_DEFINITIONS)
message (STATUS "Result of checking large files support: supported")
else ()
message (STATUS "Result of checking large files support: supported with ${LARGE_FILES_DEFINITIONS}")
message (STATUS "Add LARGE_FILES_DEFINITIONS to your compiler definitions or configure with _FILE_OFFSET_BITS,")
message (STATUS "_FILE_OFFSET_BITS_CODE, _LARGE_FILES and _LARGEFILE_SOURCE variables.")
endif ()
else ()
message ("Result of checking large files support: not supported")
set (${VARIABLE} 0 CACHE INTERNAL "Result of test for large file support" FORCE)
endif ()
message ("")
message ("")
endif (NOT DEFINED ${VARIABLE})
endmacro (TEST_LARGE_FILES VARIABLE)

View File

@ -30,6 +30,8 @@
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "sfconfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -37,7 +39,11 @@
#include <ctype.h>
#include <math.h>
#include <errno.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#include "sf_unistd.h"
#endif
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>

12
sndfile.pc.cmake.in Normal file
View File

@ -0,0 +1,12 @@
prefix=@PC_PREFIX@
exec_prefix=@PC_EXEC_PREFIX@
libdir=@PC_LIBDIR@
includedir=@PC_INCLUDEDIR@
Name: sndfile
Description: A library for reading and writing audio files
Requires:
Version: @PC_VERSION@
Libs: -L${libdir} -lsndfile
Libs.private: @PC_PRIVATE_LIBS@
Cflags: -I${includedir}

View File

@ -14,7 +14,8 @@ EXTRA_DIST = sndfile.h.in config.h.in test_endswap.c test_endswap.tpl test_endsw
$(SYMBOL_FILES) create_symbols_file.py binheader_writef_check.py \
GSM610/README GSM610/COPYRIGHT GSM610/ChangeLog \
G72x/README G72x/README.original G72x/ChangeLog \
make-static-lib-hidden-privates.sh
make-static-lib-hidden-privates.sh \
config.h.cmake libsndfile.def.in.cmake version-metadata.rc.in.cmake
noinst_HEADERS = common.h sfconfig.h sfendian.h wavlike.h sf_unistd.h ogg.h chanmap.h

View File

@ -22,6 +22,8 @@
#include <string.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#else
#include "sf_unistd.h"
#endif
#include <ctype.h>
#include <math.h>

311
src/config.h.cmake Normal file
View File

@ -0,0 +1,311 @@
/* Set to 1 if the compile is GNU GCC. */
#cmakedefine01 COMPILER_IS_GCC
/* Target processor clips on negative float to int conversion. */
#cmakedefine01 CPU_CLIPS_NEGATIVE
/* Target processor clips on positive float to int conversion. */
#cmakedefine01 CPU_CLIPS_POSITIVE
/* Target processor is big endian. */
#cmakedefine01 CPU_IS_BIG_ENDIAN
/* Target processor is little endian. */
#cmakedefine01 CPU_IS_LITTLE_ENDIAN
/* Set to 1 to enable experimental code. */
#cmakedefine01 ENABLE_EXPERIMENTAL_CODE
/* Define to 1 if you have the <alsa/asoundlib.h> header file. */
#cmakedefine01 HAVE_ALSA_ASOUNDLIB_H
/* Define to 1 if you have the <byteswap.h> header file. */
#cmakedefine01 HAVE_BYTESWAP_H
/* Define to 1 if you have the `calloc' function. */
#cmakedefine01 HAVE_CALLOC
/* Define to 1 if you have the `ceil' function. */
#cmakedefine01 HAVE_CEIL
/* Set to 1 if S_IRGRP is defined. */
#cmakedefine01 HAVE_DECL_S_IRGRP
/* Define to 1 if you have the <dlfcn.h> header file. */
#cmakedefine01 HAVE_DLFCN_H
/* Define to 1 if you have the <endian.h> header file. */
#cmakedefine01 HAVE_ENDIAN_H
/* Will be set to 1 if flac, ogg and vorbis are available. */
#cmakedefine01 HAVE_EXTERNAL_XIPH_LIBS
/* Define to 1 if you have the `floor' function. */
#cmakedefine01 HAVE_FLOOR
/* Define to 1 if you have the `fmod' function. */
#cmakedefine01 HAVE_FMOD
/* Define to 1 if you have the `free' function. */
#cmakedefine01 HAVE_FREE
/* Define to 1 if you have the `fstat' function. */
#cmakedefine01 HAVE_FSTAT
/* Define to 1 if you have the `fstat64' function. */
#cmakedefine01 HAVE_FSTAT64
/* Define to 1 if you have the `fsync' function. */
#cmakedefine01 HAVE_FSYNC
/* Define to 1 if you have the `ftruncate' function. */
#cmakedefine01 HAVE_FTRUNCATE
/* Define to 1 if you have the `getpagesize' function. */
#cmakedefine01 HAVE_GETPAGESIZE
/* Define to 1 if you have the `gettimeofday' function. */
#cmakedefine01 HAVE_GETTIMEOFDAY
/* Define if you have the `gmtime' function. */
#cmakedefine HAVE_GMTIME
/* Define if you have the `gmtime_r' function. */
#cmakedefine HAVE_GMTIME_R
/* Define to 1 if you have the <inttypes.h> header file. */
#cmakedefine01 HAVE_INTTYPES_H
/* Define to 1 if you have the <io.h> header file. */
#cmakedefine HAVE_IO_H
/* Define to 1 if you have the `m' library (-lm). */
#cmakedefine01 HAVE_LIBM
/* Define to 1 if you have the <locale.h> header file. */
#cmakedefine01 HAVE_LOCALE_H
/* Define if you have the `localtime' function. */
#cmakedefine HAVE_LOCALTIME
/* Define if you have the `localtime_r' function. */
#cmakedefine HAVE_LOCALTIME_R
/* Define if you have C99's lrint function. */
#cmakedefine01 HAVE_LRINT
/* Define if you have C99's lrintf function. */
#cmakedefine01 HAVE_LRINTF
/* Define to 1 if you have the `lround' function. */
#cmakedefine01 HAVE_LROUND
/* Define to 1 if you have the `lseek' function. */
#cmakedefine01 HAVE_LSEEK
/* Define to 1 if you have the `lseek64' function. */
#cmakedefine01 HAVE_LSEEK64
/* Define to 1 if you have the `malloc' function. */
#cmakedefine01 HAVE_MALLOC
/* Define to 1 if you have the <memory.h> header file. */
#cmakedefine01 HAVE_MEMORY_H
/* Define to 1 if you have the `mmap' function. */
#cmakedefine01 HAVE_MMAP
/* Define to 1 if you have the `open' function. */
#cmakedefine01 HAVE_OPEN
/* Define to 1 if you have the `pipe' function. */
#cmakedefine01 HAVE_PIPE
/* Define to 1 if you have the `read' function. */
#cmakedefine01 HAVE_READ
/* Define to 1 if you have the `realloc' function. */
#cmakedefine01 HAVE_REALLOC
/* Define to 1 if you have the `setlocale' function. */
#cmakedefine01 HAVE_SETLOCALE
/* Set to 1 if <sndio.h> is available. */
#cmakedefine01 HAVE_SNDIO_H
/* Define to 1 if you have the `snprintf' function. */
#cmakedefine01 HAVE_SNPRINTF
/* Set to 1 if you have libsqlite3. */
#cmakedefine01 HAVE_SQLITE3
/* Define to 1 if the system has the type `ssize_t'. */
#cmakedefine01 HAVE_SSIZE_T
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine01 HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#cmakedefine01 HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#cmakedefine01 HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#cmakedefine01 HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#cmakedefine01 HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/time.h> header file. */
#cmakedefine01 HAVE_SYS_TIME_H
/* Define to 1 if you have the <sys/types.h> header file. */
#cmakedefine01 HAVE_SYS_TYPES_H
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
#cmakedefine01 HAVE_SYS_WAIT_H
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine01 HAVE_UNISTD_H
/* Define to 1 if you have the `vsnprintf' function. */
#cmakedefine01 HAVE_VSNPRINTF
/* Define to 1 if you have the `waitpid' function. */
#cmakedefine01 HAVE_WAITPID
/* Define to 1 if you have the `write' function. */
#cmakedefine01 HAVE_WRITE
/* The darwin version, no-zero is valid */
#cmakedefine01 OSX_DARWIN_VERSION
/* Set to 1 if compiling for OpenBSD */
#cmakedefine01 OS_IS_OPENBSD
/* Set to 1 if compiling for Win32 */
#cmakedefine01 OS_IS_WIN32
/* Name of package */
#define PACKAGE "@CPACK_PACKAGE_NAME@"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
/* Define to the full name of this package. */
#define PACKAGE_NAME "@CPACK_PACKAGE_NAME@"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "@CPACK_PACKAGE_NAME@ @CPACK_PACKAGE_VERSION@"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "@CPACK_PACKAGE_NAME@"
/* Define to the home page for this package. */
#define PACKAGE_URL "@PACKAGE_URL@"
/* Define to the version of this package. */
#define PACKAGE_VERSION "@CPACK_PACKAGE_VERSION@"
/* Set to maximum allowed value of sf_count_t type. */
#define SF_COUNT_MAX @SF_COUNT_MAX@
/* The size of `double', as computed by sizeof. */
@SIZEOF_DOUBLE_CODE@
/* The size of `float', as computed by sizeof. */
@SIZEOF_FLOAT_CODE@
/* The size of `int', as computed by sizeof. */
@SIZEOF_INT_CODE@
/* The size of `int64_t', as computed by sizeof. */
@SIZEOF_INT64_T_CODE@
/* The size of `loff_t', as computed by sizeof. */
@SIZEOF_LOFF_T_CODE@
/* The size of `long', as computed by sizeof. */
@SIZEOF_LONG_CODE@
/* The size of `long long', as computed by sizeof. */
@SIZEOF_LONG_LONG_CODE@
/* The size of `off64_t', as computed by sizeof. */
@SIZEOF_OFF64_T_CODE@
/* The size of `off_t', as computed by sizeof. */
@SIZEOF_OFF_T_CODE@
/* Set to sizeof (long) if unknown. */
@SIZEOF_SF_COUNT_T_CODE@
/* The size of `short', as computed by sizeof. */
@SIZEOF_SHORT_CODE@
/* The size of `size_t', as computed by sizeof. */
@SIZEOF_SIZE_T_CODE@
/* The size of `ssize_t', as computed by sizeof. */
@SIZEOF_SSIZE_T_CODE@
/* The size of `void*', as computed by sizeof. */
@SIZEOF_VOIDP_CODE@
/* The size of `wchar_t', as computed by sizeof. */
@SIZEOF_WCHAR_T_CODE@
/* Define to 1 if you have the ANSI C header files. */
#cmakedefine01 STDC_HEADERS
/* Set to long if unknown. */
#define TYPEOF_SF_COUNT_T @TYPEOF_SF_COUNT_T@
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Set to 1 to use the native windows API */
#cmakedefine01 USE_WINDOWS_API
/* Version number of package */
#define VERSION "@PROJECT_VERSION@"
/* Set to 1 if windows DLL is being built. */
#cmakedefine01 WIN32_TARGET_DLL
/* Target processor is big endian. */
#cmakedefine01 WORDS_BIGENDIAN
/* Enable large inode numbers on Mac OS X 10.5. */
#ifndef _DARWIN_USE_64_BIT_INODE
# define _DARWIN_USE_64_BIT_INODE 1
#endif
/* Define to 1 if on MINIX. */
#cmakedefine01 _MINIX
/* Set to 1 to use C99 printf/snprintf in MinGW. */
#cmakedefine01 __USE_MINGW_ANSI_STDIO
/* Define as `__inline' or '__inline__' if that's what the C compiler calls it, or to nothing if it is not supported. */
@INLINE_CODE@

View File

@ -0,0 +1,46 @@
; Auto-generated by cmake
LIBRARY ${PROJECT_NAME}-${PROJECT_VERSION_MAJOR}.dll
EXPORTS
sf_command @1
sf_open @2
sf_close @3
sf_seek @4
sf_error @7
sf_perror @8
sf_error_str @9
sf_error_number @10
sf_format_check @11
sf_read_raw @16
sf_readf_short @17
sf_readf_int @18
sf_readf_float @19
sf_readf_double @20
sf_read_short @21
sf_read_int @22
sf_read_float @23
sf_read_double @24
sf_write_raw @32
sf_writef_short @33
sf_writef_int @34
sf_writef_float @35
sf_writef_double @36
sf_write_short @37
sf_write_int @38
sf_write_float @39
sf_write_double @40
sf_strerror @50
sf_get_string @60
sf_set_string @61
sf_version_string @68
sf_open_fd @70
sf_wchar_open @71
sf_open_virtual @80
sf_write_sync @90
sf_set_chunk @100
sf_get_chunk_size @101
sf_get_chunk_data @102
sf_get_chunk_iterator @103
sf_next_chunk_iterator @104
sf_current_byterate @110

View File

@ -16,8 +16,34 @@
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Microsoft declares some 'unistd.h' functions in 'io.h'. */
#ifdef HAVE_IO_H
#include <io.h>
#endif
/* Some defines that microsoft 'forgot' to implement. */
#ifndef R_OK
#define R_OK 4 /* Test for read permission. */
#endif
#ifndef W_OK
#define W_OK 2 /* Test for write permission. */
#endif
#ifndef X_OK
#ifdef WIN32
#define X_OK 0
#else
#define X_OK 1 /* execute permission - unsupported in windows*/
#endif
#endif
#ifndef F_OK
#define F_OK 0 /* Test for existence. */
#endif
#ifndef S_IRWXU
#define S_IRWXU 0000700 /* rwx, owner */
#endif

View File

@ -116,4 +116,12 @@
#define CPU_IS_X86 (defined __i486__ || defined __i586__ || defined __i686__ || defined __x86_64__)
#define CPU_IS_X86_64 (defined __x86_64__)
#ifndef HAVE_SSIZE_T
#define HAVE_SSIZE_T 0
#endif
#if (HAVE_SSIZE_T == 0)
#define ssize_t intptr_t
#endif
#endif

View File

@ -0,0 +1,32 @@
#include <windows.h>
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_AUS
1 VERSIONINFO
FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0
PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,0
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE VFT2_UNKNOWN
FILEFLAGSMASK 0x00000000
FILEFLAGS 0x00000000
{
BLOCK "StringFileInfo"
{
BLOCK "040904e4"
{
VALUE "FileDescription", "A library for reading and writing audio files."
VALUE "FileVersion", "@PROJECT_VERSION@\0"
VALUE "Full Version", "@PROJECT_VERSION@"
VALUE "InternalName", "@PROJECT_NAME@"
VALUE "LegalCopyright", "Copyright (C) 1999-2012, Licensed LGPL"
VALUE "OriginalFilename", "@PROJECT_NAME@-@PROJECT_VERSION_MAJOR@.dll"
VALUE "ProductName", "@PROJECT_NAME@-@PROJECT_VERSION_MAJOR@ DLL"
VALUE "ProductVersion", "@PROJECT_VERSION@.0\0"
VALUE "Language", "Language Neutral"
}
}
BLOCK "VarFileInfo"
{
VALUE "Translation", 0x0409, 0x04E4
}
}