This commit adds a new CMake-based build system. The build time configuration should match the one by autoconf. Then this build system gets tested on Travis (Linux) and AppVeyor (Windows; MSVC and MinGW). Additionally on AppVeyor, a build artifact is produced for easier distribution to Windows. Some minor changes are introduced to fix compilation on Windows. This commit is based on previous attempts at a CMake-based build by Jean-Michaël Celerier (jcelerier) and Matthew Sitton (mdsitton).
Unified · Split
| @@ -1,4 +1,4 @@ | ||
| 1 | −*.cm* | |
| 1 | +# *.cm* # This line is broken it matches all files. | |
| 2 | 2 | *.dat |
| 3 | 3 | *.gz |
| 4 | 4 | *.la |
| @@ -29,6 +29,7 @@ autom4te.cache · 24 unmodified lines | ||
| 29 | 29 | libsamplerate-*.tar.bz2 |
| 30 | 30 | compile |
| 31 | 31 | config.* |
| 32 | +!/config.h.in | |
| 32 | 33 | configure |
| 33 | 34 | depcomp |
| 34 | 35 | doc/ChangeLog |
| @@ -53,3 +54,4 @@ tests/benchmark · 18 unmodified lines | ||
| 53 | 54 | tests/src-evaluate |
| 54 | 55 | *.log |
| 55 | 56 | *.trs |
| 57 | +build/ | |
| @@ -9,7 +9,15 @@ before_install: · 8 unmodified lines | ||
| 9 | 9 | - sudo apt-get update |
| 10 | 10 | - sudo apt-get install -y autoconf automake-1.15 pkg-config m4 libsndfile-dev libfftw3-dev libasound2-dev |
| 11 | 11 | |
| 12 | +env: | |
| 13 | + - AUTOGEN=true CMAKE_SHARED=OFF | |
| 14 | + - AUTOGEN=false CMAKE_SHARED=ON | |
| 15 | + | |
| 12 | 16 | script: |
| 13 | − - ./autogen.sh | |
| 14 | − - ./configure | |
| 15 | − - make distcheck | |
| 17 | + - if $AUTOGEN; then ./autogen.sh && ./configure && make distcheck; fi | |
| 18 | + - mkdir build | |
| 19 | + - cd build | |
| 20 | + - cmake -DBUILD_SHARED_LIBS=$CMAKE_SHARED .. | |
| 21 | + - cat config.h | |
| 22 | + - make | |
| 23 | + - make test | |
| @@ -0,0 +1,141 @@ | ||
| 1 | +cmake_minimum_required(VERSION 3.1) | |
| 2 | +project(libsamplerate VERSION 0.1.9 LANGUAGES C) | |
| 3 | + | |
| 4 | +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake) | |
| 5 | + | |
| 6 | +include(TestBigEndian) | |
| 7 | +include(CheckFunctionExists) | |
| 8 | +include(CheckIncludeFiles) | |
| 9 | +include(CheckSymbolExists) | |
| 10 | +include(CheckTypeSize) | |
| 11 | +include(ClipMode) | |
| 12 | + | |
| 13 | +set(SAMPLERATE_SRC | |
| 14 | + ${PROJECT_SOURCE_DIR}/src/samplerate.c | |
| 15 | + ${PROJECT_SOURCE_DIR}/src/src_linear.c | |
| 16 | + ${PROJECT_SOURCE_DIR}/src/src_sinc.c | |
| 17 | + ${PROJECT_SOURCE_DIR}/src/src_zoh.c) | |
| 18 | + | |
| 19 | +if(WIN32) | |
| 20 | + set(OS_IS_WIN32 TRUE) | |
| 21 | + set(SAMPLERATE_SRC | |
| 22 | + ${SAMPLERATE_SRC} | |
| 23 | + ${PROJECT_SOURCE_DIR}/Win32/libsamplerate-0.def) | |
| 24 | + include_directories(Win32) | |
| 25 | +endif() | |
| 26 | + | |
| 27 | +test_big_endian(CPU_IS_BIG_ENDIAN) | |
| 28 | +if(CPU_IS_BIG_ENDIAN) | |
| 29 | + set(CPU_IS_LITTLE_ENDIAN 0) | |
| 30 | +else() | |
| 31 | + set(CPU_IS_LITTLE_ENDIAN 1) | |
| 32 | +endif() | |
| 33 | + | |
| 34 | +check_function_exists(pow RESULT) | |
| 35 | +if(NOT RESULT) | |
| 36 | + list(APPEND CMAKE_REQUIRED_LIBRARIES m) | |
| 37 | + set(NEED_MATH) | |
| 38 | +endif() | |
| 39 | +check_function_exists(alarm HAVE_ALARM) | |
| 40 | +check_function_exists(lrint HAVE_LRINT) | |
| 41 | +check_function_exists(lrintf HAVE_LRINTF) | |
| 42 | +check_function_exists(signal HAVE_SIGNAL) | |
| 43 | + | |
| 44 | +check_include_files(stdint.h HAVE_STDINT) | |
| 45 | +check_include_files(sys/times.h HAVE_SYS_TIMES_H) | |
| 46 | + | |
| 47 | +check_symbol_exists(SIGALRM signal.h HAVE_SIGALRM) | |
| 48 | + | |
| 49 | +check_type_size(int SIZEOF_INT) | |
| 50 | +check_type_size(long SIZEOF_LONG) | |
| 51 | + | |
| 52 | +# This will set CPU_CLIPS_NEGATIVE and CPU_CLIPS_POSITIVE | |
| 53 | +clip_mode() | |
| 54 | + | |
| 55 | +find_package(ALSA) | |
| 56 | +set(HAVE_ALSA ${ALSA_FOUND}) | |
| 57 | +if(ALSA_FOUND) | |
| 58 | + include_directories("${ALSA_INCLUDE_DIR}") | |
| 59 | +endif() | |
| 60 | + | |
| 61 | +find_package(Sndfile) | |
| 62 | +set(HAVE_SNDFILE ${SNDFILE_FOUND}) | |
| 63 | +if(SNDFILE_FOUND) | |
| 64 | + include_directories("${SNDFILE_INCLUDE_DIR}") | |
| 65 | +endif() | |
| 66 | + | |
| 67 | +find_package(FFTW) | |
| 68 | +set(HAVE_FFTW3 ${FFTW_FOUND}) | |
| 69 | +if(FFTW_FOUND) | |
| 70 | + include_directories("${FFTW_INCLUDE_DIR}") | |
| 71 | +endif() | |
| 72 | + | |
| 73 | +configure_file(${PROJECT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h) | |
| 74 | + | |
| 75 | +add_library(samplerate ${SAMPLERATE_SRC}) | |
| 76 | + | |
| 77 | +if(BUILD_SHARED_LIBS AND WIN32) | |
| 78 | + if (MSVC) | |
| 79 | + set_target_properties(samplerate PROPERTIES OUTPUT_NAME "libsamplerate-0") | |
| 80 | + else() | |
| 81 | + set_target_properties(samplerate PROPERTIES OUTPUT_NAME "samplerate-0") | |
| 82 | + endif() | |
| 83 | +endif() | |
| 84 | + | |
| 85 | +target_include_directories(samplerate PUBLIC | |
| 86 | + ${PROJECT_SOURCE_DIR}/src | |
| 87 | + ${CMAKE_CURRENT_BINARY_DIR}) | |
| 88 | + | |
| 89 | +enable_testing() | |
| 90 | + | |
| 91 | +file(GLOB TEST_SRCS ${PROJECT_SOURCE_DIR}/tests/*_test.c) | |
| 92 | + | |
| 93 | +foreach(testSrc ${TEST_SRCS}) | |
| 94 | + get_filename_component(testName ${testSrc} NAME_WE) | |
| 95 | + add_executable(${testName} | |
| 96 | + ${testSrc} | |
| 97 | + ${PROJECT_SOURCE_DIR}/tests/util.c | |
| 98 | + ${PROJECT_SOURCE_DIR}/tests/calc_snr.c) | |
| 99 | + target_link_libraries(${testName} PUBLIC samplerate ${CMAKE_REQUIRED_LIBRARIES}) | |
| 100 | + if(FFTW_FOUND) | |
| 101 | + target_link_libraries(${testName} PUBLIC ${FFTW_LIBRARY}) | |
| 102 | + endif() | |
| 103 | + add_test(NAME ${testName} COMMAND ${testName}) | |
| 104 | +endforeach(testSrc) | |
| 105 | + | |
| 106 | +set(EXAMPLE_SRCS | |
| 107 | + ${PROJECT_SOURCE_DIR}/examples/sndfile-resample.c | |
| 108 | + ${PROJECT_SOURCE_DIR}/examples/timewarp-file.c | |
| 109 | + ${PROJECT_SOURCE_DIR}/examples/varispeed-play.c) | |
| 110 | + | |
| 111 | +foreach(exampleSrc ${EXAMPLE_SRCS}) | |
| 112 | + get_filename_component(exampleName ${exampleSrc} NAME_WE) | |
| 113 | + add_executable(${exampleName} | |
| 114 | + ${exampleSrc} | |
| 115 | + ${PROJECT_SOURCE_DIR}/examples/audio_out.c) | |
| 116 | + target_link_libraries(${exampleName} PUBLIC samplerate ${CMAKE_REQUIRED_LIBRARIES}) | |
| 117 | + if(ALSA_FOUND) | |
| 118 | + target_link_libraries(${exampleName} PUBLIC ${ALSA_LIBRARY}) | |
| 119 | + endif() | |
| 120 | + if(SNDFILE_FOUND) | |
| 121 | + target_link_libraries(${exampleName} PUBLIC ${SNDFILE_LIBRARY}) | |
| 122 | + endif() | |
| 123 | + if(WIN32) | |
| 124 | + target_link_libraries(${exampleName} PUBLIC winmm) | |
| 125 | + endif() | |
| 126 | +endforeach(exampleSrc) | |
| 127 | + | |
| 128 | +set(prefix ${CMAKE_INSTALL_PREFIX}) | |
| 129 | +set(exec_prefix "\${prefix}") | |
| 130 | +set(includedir "\${prefix}/include") | |
| 131 | +set(libdir "\${exec_prefix}/lib") | |
| 132 | +set(VERSION "${PROJECT_VERSION}") | |
| 133 | +if(NEED_MATH) | |
| 134 | + set(LIBS "-lm") | |
| 135 | +endif() | |
| 136 | +configure_file(samplerate.pc.in samplerate.pc @ONLY) | |
| 137 | + | |
| 138 | +install(TARGETS samplerate DESTINATION lib) | |
| 139 | +install(FILES src/samplerate.h DESTINATION include) | |
| 140 | +install(DIRECTORY doc/ DESTINATION share/doc/libsamplerate) | |
| 141 | +install(FILES ${CMAKE_BINARY_DIR}/samplerate.pc DESTINATION lib/pkgconfig) | |
| @@ -40,6 +40,17 @@ the following three commands : · 39 unmodified lines | ||
| 40 | 40 | make |
| 41 | 41 | make install |
| 42 | 42 | |
| 43 | +CMake | |
| 44 | +----- | |
| 45 | +There is a new CMake-based build system available: | |
| 46 | + mkdir build | |
| 47 | + cd build | |
| 48 | + cmake .. | |
| 49 | + make | |
| 50 | + | |
| 51 | +Use `cmake -DCMAKE_BUILD_TYPE=Release ..` to make a release build. | |
| 52 | +Use `cmake -DBUILD_SHARED_LIBS=ON ..` to build a shared library. | |
| 53 | + | |
| 43 | 54 | CONTACTS |
| 44 | 55 | -------- |
| 45 | 56 | |
| @@ -1,197 +0,0 @@ | ||
| 1 | −/* | |
| 2 | −** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com> | |
| 3 | −** All rights reserved. | |
| 4 | −** | |
| 5 | −** This code is released under 2-clause BSD license. Please see the | |
| 6 | −** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING | |
| 7 | −*/ | |
| 8 | − | |
| 9 | −/* | |
| 10 | −** This is the Win32 specific config.h header file. | |
| 11 | −** | |
| 12 | −** On Unix (including MacOSX), this header file is automatically generated | |
| 13 | −** during the configure process while on Win32 this has to be hand edited | |
| 14 | −** to keep it up to date. | |
| 15 | −** | |
| 16 | −** This is also a good file to add Win32 specific things. | |
| 17 | −*/ | |
| 18 | − | |
| 19 | −/* | |
| 20 | −** MSVC++ assumes that all floating point constants without a trailing | |
| 21 | −** letter 'f' are double precision. | |
| 22 | −** | |
| 23 | −** If this assumption is incorrect and one of these floating point constants | |
| 24 | −** is assigned to a float variable MSVC++ generates a warning. | |
| 25 | −** | |
| 26 | −** Since there are currently about 25000 of these warnings generated in | |
| 27 | −** src/src_sinc.c this slows down compile times considerably. The | |
| 28 | −** following #pragma disables the warning. | |
| 29 | −*/ | |
| 30 | − | |
| 31 | −#pragma warning(disable: 4305) | |
| 32 | − | |
| 33 | −/*---------------------------------------------------------------------------- | |
| 34 | −** Normal #defines follow. | |
| 35 | −*/ | |
| 36 | − | |
| 37 | −/* Set to 1 if the compile is GNU GCC. */ | |
| 38 | −#define COMPILER_IS_GCC 0 | |
| 39 | − | |
| 40 | −/* Target processor clips on negative float to int conversion. */ | |
| 41 | −#define CPU_CLIPS_NEGATIVE 0 | |
| 42 | − | |
| 43 | −/* Target processor clips on positive float to int conversion. */ | |
| 44 | −#define CPU_CLIPS_POSITIVE 0 | |
| 45 | − | |
| 46 | −/* Host processor is big endian. */ | |
| 47 | −#define CPU_IS_BIG_ENDIAN 0 | |
| 48 | − | |
| 49 | −/* Host processor is little endian. */ | |
| 50 | −#define CPU_IS_LITTLE_ENDIAN 1 | |
| 51 | − | |
| 52 | −/* Set to 1 to enable debugging. */ | |
| 53 | −#define ENABLE_DEBUG 0 | |
| 54 | − | |
| 55 | −/* Major version of GCC or 3 otherwise. */ | |
| 56 | −/* #undef GCC_MAJOR_VERSION */ | |
| 57 | − | |
| 58 | −/* Define to 1 if you have the `alarm' function. */ | |
| 59 | −/* #undef HAVE_ALARM */ | |
| 60 | − | |
| 61 | −/* Define to 1 if you have the `calloc' function. */ | |
| 62 | −#define HAVE_CALLOC 1 | |
| 63 | − | |
| 64 | −/* Define to 1 if you have the `ceil' function. */ | |
| 65 | −#define HAVE_CEIL 1 | |
| 66 | − | |
| 67 | −/* Define to 1 if you have the <dlfcn.h> header file. */ | |
| 68 | −/* #undef HAVE_DLFCN_H */ | |
| 69 | − | |
| 70 | −/* Set to 1 if you have libfftw3. */ | |
| 71 | −/* #undef HAVE_FFTW3 */ | |
| 72 | − | |
| 73 | −/* Define to 1 if you have the `floor' function. */ | |
| 74 | −#define HAVE_FLOOR 1 | |
| 75 | − | |
| 76 | −/* Define to 1 if you have the `fmod' function. */ | |
| 77 | −#define HAVE_FMOD 1 | |
| 78 | − | |
| 79 | −/* Define to 1 if you have the `free' function. */ | |
| 80 | −#define HAVE_FREE 1 | |
| 81 | − | |
| 82 | −/* Define to 1 if you have the <inttypes.h> header file. */ | |
| 83 | −/* #undef HAVE_INTTYPES_H */ | |
| 84 | − | |
| 85 | −/* Define to 1 if you have the `m' library (-lm). */ | |
| 86 | −/* #undef HAVE_LIBM */ | |
| 87 | − | |
| 88 | −/* Define if you have C99's lrint function. */ | |
| 89 | −/* #undef HAVE_LRINT */ | |
| 90 | − | |
| 91 | −/* Define if you have C99's lrintf function. */ | |
| 92 | −/* #undef HAVE_LRINTF */ | |
| 93 | − | |
| 94 | −/* Define to 1 if you have the `malloc' function. */ | |
| 95 | −#define HAVE_MALLOC 1 | |
| 96 | − | |
| 97 | −/* Define to 1 if you have the `memcpy' function. */ | |
| 98 | −#define HAVE_MEMCPY 1 | |
| 99 | − | |
| 100 | −/* Define to 1 if you have the `memmove' function. */ | |
| 101 | −#define HAVE_MEMMOVE 1 | |
| 102 | − | |
| 103 | −/* Define to 1 if you have the <memory.h> header file. */ | |
| 104 | −#define HAVE_MEMORY_H 1 | |
| 105 | − | |
| 106 | −/* Define if you have signal SIGALRM. */ | |
| 107 | −/* #undef HAVE_SIGALRM */ | |
| 108 | − | |
| 109 | −/* Define to 1 if you have the `signal' function. */ | |
| 110 | −/* #undef HAVE_SIGNAL */ | |
| 111 | − | |
| 112 | −/* Set to 1 if you have libsndfile. */ | |
| 113 | −#define HAVE_SNDFILE 1 | |
| 114 | − | |
| 115 | −/* Define to 1 if you have the <stdint.h> header file. */ | |
| 116 | −/* #undef HAVE_STDINT_H */ | |
| 117 | − | |
| 118 | −/* Define to 1 if you have the <stdlib.h> header file. */ | |
| 119 | −#define HAVE_STDLIB_H 1 | |
| 120 | − | |
| 121 | −/* Define to 1 if you have the <strings.h> header file. */ | |
| 122 | −#define HAVE_STRINGS_H 1 | |
| 123 | − | |
| 124 | −/* Define to 1 if you have the <string.h> header file. */ | |
| 125 | −#define HAVE_STRING_H 1 | |
| 126 | − | |
| 127 | −/* Define to 1 if you have the <sys/stat.h> header file. */ | |
| 128 | −#define HAVE_SYS_STAT_H 1 | |
| 129 | − | |
| 130 | −/* Define to 1 if you have the <sys/times.h> header file. */ | |
| 131 | −/* #undef HAVE_SYS_TIMES_H */ | |
| 132 | − | |
| 133 | −/* Define to 1 if you have the <sys/types.h> header file. */ | |
| 134 | −#define HAVE_SYS_TYPES_H 1 | |
| 135 | − | |
| 136 | −/* Define to 1 if you have the <unistd.h> header file. */ | |
| 137 | −#define HAVE_UNISTD_H 1 | |
| 138 | − | |
| 139 | −/* Define to the sub-directory in which libtool stores uninstalled libraries. | |
| 140 | − */ | |
| 141 | −#define LT_OBJDIR ".libs/" | |
| 142 | − | |
| 143 | −/* Define to 1 if your C compiler doesn't accept -c and -o together. */ | |
| 144 | −/* #undef NO_MINUS_C_MINUS_O */ | |
| 145 | − | |
| 146 | −/* Set to 1 if compiling for Win32 */ | |
| 147 | −#define OS_IS_WIN32 1 | |
| 148 | − | |
| 149 | −/* Name of package */ | |
| 150 | −#define PACKAGE "libsamplerate" | |
| 151 | − | |
| 152 | −/* Define to the address where bug reports for this package should be sent. */ | |
| 153 | −#define PACKAGE_BUGREPORT "erikd@mega-nerd.com" | |
| 154 | − | |
| 155 | −/* Define to the full name of this package. */ | |
| 156 | −#define PACKAGE_NAME "libsamplerate" | |
| 157 | − | |
| 158 | −/* Define to the full name and version of this package. */ | |
| 159 | −#define PACKAGE_STRING "libsamplerate 0.1.8" | |
| 160 | − | |
| 161 | −/* Define to the one symbol short name of this package. */ | |
| 162 | −#define PACKAGE_TARNAME "libsamplerate" | |
| 163 | − | |
| 164 | −/* Define to the home page for this package. */ | |
| 165 | −#define PACKAGE_URL "http://www.mega-nerd.com/libsamplerate/" | |
| 166 | − | |
| 167 | −/* Define to the version of this package. */ | |
| 168 | −#define PACKAGE_VERSION "0.1.8" | |
| 169 | − | |
| 170 | −/* The size of `double', as computed by sizeof. */ | |
| 171 | −#define SIZEOF_DOUBLE 8 | |
| 172 | − | |
| 173 | −/* The size of `float', as computed by sizeof. */ | |
| 174 | −#define SIZEOF_FLOAT 4 | |
| 175 | − | |
| 176 | −/* The size of `int', as computed by sizeof. */ | |
| 177 | −#define SIZEOF_INT 4 | |
| 178 | − | |
| 179 | −/* The size of `long', as computed by sizeof. */ | |
| 180 | −#define SIZEOF_LONG 4 | |
| 181 | − | |
| 182 | −/* Define to 1 if you have the ANSI C header files. */ | |
| 183 | −#define STDC_HEADERS 1 | |
| 184 | − | |
| 185 | −/* Version number of package */ | |
| 186 | −#define VERSION "0.1.8" | |
| 187 | − | |
| 188 | − | |
| 189 | − | |
| 190 | −/* Extra Win32 hacks. */ | |
| 191 | − | |
| 192 | −/* | |
| 193 | −** Microsoft's compiler still does not support the 1999 ISO C Standard | |
| 194 | −** which includes 'inline'. | |
| 195 | −*/ | |
| 196 | − | |
| 197 | −#define inline __inline | |
| @@ -0,0 +1,47 @@ | ||
| 1 | +image: | |
| 2 | +- Visual Studio 2017 | |
| 3 | + | |
| 4 | +environment: | |
| 5 | + matrix: | |
| 6 | + - generator: "Visual Studio 15 2017" | |
| 7 | + artifact: "ON" | |
| 8 | + - generator: "MSYS Makefiles" | |
| 9 | + artifact: "ON" | |
| 10 | + - generator: "Visual Studio 15 2017" | |
| 11 | + shared: "OFF" | |
| 12 | + artifact: "OFF" | |
| 13 | + - generator: "Visual Studio 15 2017" | |
| 14 | + shared: "ON" | |
| 15 | + artifact: "OFF" | |
| 16 | + - generator: "MSYS Makefiles" | |
| 17 | + shared: "OFF" | |
| 18 | + artifact: "OFF" | |
| 19 | + - generator: "MSYS Makefiles" | |
| 20 | + shared: "ON" | |
| 21 | + artifact: "OFF" | |
| 22 | + | |
| 23 | +matrix: | |
| 24 | + fast_finish: true | |
| 25 | + | |
| 26 | +build_script: | |
| 27 | + - ps: | | |
| 28 | + $env:Path = "C:\msys64\mingw64\bin;C:\msys64\usr\bin;" + $env:Path | |
| 29 | + bash -lc "pacman -S --needed --noconfirm mingw-w64-x86_64-fftw mingw-w64-x86_64-libsndfile" | |
| 30 | + mkdir build | |
| 31 | + cd build | |
| 32 | + if ($env:artifact -eq 'OFF') | |
| 33 | + { | |
| 34 | + cmake -G "$env:generator" -DBUILD_SHARED_LIBS=$env:shared .. | |
| 35 | + cat config.h | |
| 36 | + cmake --build . | |
| 37 | + ctest -C "Debug" | |
| 38 | + } | |
| 39 | + else | |
| 40 | + { | |
| 41 | + cmake .. -G "$env:generator" -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=artifact | |
| 42 | + cmake --build . --config Release --target install | |
| 43 | + cmake .. -G "$env:generator" -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=artifact | |
| 44 | + cmake --build . --config Release --target install | |
| 45 | + Compress-Archive -Path artifact\* -Destination artifact | |
| 46 | + Push-AppveyorArtifact artifact.zip | |
| 47 | + } | |
| @@ -0,0 +1,92 @@ | ||
| 1 | +include (CheckCSourceRuns) | |
| 2 | +include (CMakePushCheckState) | |
| 3 | + | |
| 4 | +macro (CLIP_MODE) | |
| 5 | + | |
| 6 | + set (CLIP_MODE_POSITIVE_MESSAGE "Target processor clips on positive float to int conversion") | |
| 7 | + set (CLIP_MODE_NEGATIVE_MESSAGE "Target processor clips on negative float to int conversion") | |
| 8 | + | |
| 9 | + message (STATUS "Checking processor clipping capabilities...") | |
| 10 | + | |
| 11 | + if (CMAKE_CROSSCOMPILING) | |
| 12 | + | |
| 13 | + set (CLIP_MSG "disabled") | |
| 14 | + set (CPU_CLIPS_POSITIVE FALSE CACHE BOOL ${CLIP_MODE_POSITIVE_MESSAGE}) | |
| 15 | + set (CPU_CLIPS_NEGATIVE FALSE CACHE BOOL ${CLIP_MODE_NEGATIVE_MESSAGE}) | |
| 16 | + | |
| 17 | + else (NOT CMAKE_CROSSCOMPILING) | |
| 18 | + | |
| 19 | + cmake_push_check_state () | |
| 20 | + | |
| 21 | + set (CMAKE_REQUIRED_QUIET TRUE) | |
| 22 | + if (LIBM_REQUIRED) | |
| 23 | + set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY}) | |
| 24 | + endif () | |
| 25 | + | |
| 26 | + check_c_source_runs ( | |
| 27 | + " | |
| 28 | + #define _ISOC9X_SOURCE 1 | |
| 29 | + #define _ISOC99_SOURCE 1 | |
| 30 | + #define __USE_ISOC99 1 | |
| 31 | + #define __USE_ISOC9X 1 | |
| 32 | + #include <math.h> | |
| 33 | + int main (void) | |
| 34 | + { double fval ; | |
| 35 | + int k, ival ; | |
| 36 | + | |
| 37 | + fval = 1.0 * 0x7FFFFFFF ; | |
| 38 | + for (k = 0 ; k < 100 ; k++) | |
| 39 | + { ival = (lrint (fval)) >> 24 ; | |
| 40 | + if (ival != 127) | |
| 41 | + return 1 ; | |
| 42 | + | |
| 43 | + fval *= 1.2499999 ; | |
| 44 | + } ; | |
| 45 | + | |
| 46 | + return 0 ; | |
| 47 | + } | |
| 48 | + " | |
| 49 | + CPU_CLIPS_POSITIVE) | |
| 50 | + | |
| 51 | + check_c_source_runs ( | |
| 52 | + " | |
| 53 | + #define _ISOC9X_SOURCE 1 | |
| 54 | + #define _ISOC99_SOURCE 1 | |
| 55 | + #define __USE_ISOC99 1 | |
| 56 | + #define __USE_ISOC9X 1 | |
| 57 | + #include <math.h> | |
| 58 | + int main (void) | |
| 59 | + { double fval ; | |
| 60 | + int k, ival ; | |
| 61 | + | |
| 62 | + fval = -8.0 * 0x10000000 ; | |
| 63 | + for (k = 0 ; k < 100 ; k++) | |
| 64 | + { ival = (lrint (fval)) >> 24 ; | |
| 65 | + if (ival != -128) | |
| 66 | + return 1 ; | |
| 67 | + | |
| 68 | + fval *= 1.2499999 ; | |
| 69 | + } ; | |
| 70 | + | |
| 71 | + return 0 ; | |
| 72 | + } | |
| 73 | + " | |
| 74 | + CPU_CLIPS_NEGATIVE) | |
| 75 | + | |
| 76 | + cmake_pop_check_state () | |
| 77 | + | |
| 78 | + if (CPU_CLIPS_POSITIVE AND (NOT CPU_CLIPS_NEGATIVE)) | |
| 79 | + set (CLIP_MSG "positive") | |
| 80 | + elseif (CPU_CLIPS_NEGATIVE AND (NOT CPU_CLIPS_POSITIVE)) | |
| 81 | + set (CLIP_MSG "negative") | |
| 82 | + elseif (CPU_CLIPS_POSITIVE AND CPU_CLIPS_NEGATIVE) | |
| 83 | + set (CLIP_MSG "both") | |
| 84 | + else () | |
| 85 | + set (CLIP_MSG "none") | |
| 86 | + endif () | |
| 87 | + | |
| 88 | + endif (CMAKE_CROSSCOMPILING) | |
| 89 | + | |
| 90 | + message (STATUS "Checking processor clipping capabilities... ${CLIP_MSG}") | |
| 91 | + | |
| 92 | +endmacro (CLIP_MODE) | |
| @@ -0,0 +1,48 @@ | ||
| 1 | +# Adapted from: https://github.com/wjakob/layerlab/blob/master/cmake/FindFFTW.cmake | |
| 2 | + | |
| 3 | +# Copyright (c) 2015, Wenzel Jakob | |
| 4 | +# All rights reserved. | |
| 5 | +# | |
| 6 | +# Redistribution and use in source and binary forms, with or without | |
| 7 | +# modification, are permitted provided that the following conditions are met: | |
| 8 | +# | |
| 9 | +# * Redistributions of source code must retain the above copyright notice, this | |
| 10 | +# list of conditions and the following disclaimer. | |
| 11 | +# | |
| 12 | +# * Redistributions in binary form must reproduce the above copyright notice, | |
| 13 | +# this list of conditions and the following disclaimer in the documentation | |
| 14 | +# and/or other materials provided with the distribution. | |
| 15 | +# | |
| 16 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 17 | +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 18 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
| 19 | +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | |
| 20 | +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
| 21 | +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
| 22 | +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | |
| 23 | +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
| 24 | +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 25 | +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 26 | + | |
| 27 | +# - Find FFTW | |
| 28 | +# Find the native FFTW includes and library | |
| 29 | +# | |
| 30 | +# FFTW_INCLUDE_DIR - where to find fftw3.h | |
| 31 | +# FFTW_LIBRARY - List of libraries when using FFTW. | |
| 32 | +# FFTW_FOUND - True if FFTW found. | |
| 33 | + | |
| 34 | +if (FFTW_INCLUDE_DIR) | |
| 35 | + # Already in cache, be silent | |
| 36 | + set (FFTW_FIND_QUIETLY TRUE) | |
| 37 | +endif (FFTW_INCLUDE_DIR) | |
| 38 | + | |
| 39 | +find_path (FFTW_INCLUDE_DIR fftw3.h) | |
| 40 | + | |
| 41 | +find_library (FFTW_LIBRARY NAMES fftw3) | |
| 42 | + | |
| 43 | +# handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND to TRUE if | |
| 44 | +# all listed variables are TRUE | |
| 45 | +include (FindPackageHandleStandardArgs) | |
| 46 | +find_package_handle_standard_args (FFTW DEFAULT_MSG FFTW_LIBRARY FFTW_INCLUDE_DIR) | |
| 47 | + | |
| 48 | +mark_as_advanced (FFTW_LIBRARY FFTW_INCLUDE_DIR) | |
| @@ -0,0 +1,18 @@ | ||
| 1 | +# Variables defined: | |
| 2 | +# SNDFILE_FOUND | |
| 3 | +# SNDFILE_INCLUDE_DIR | |
| 4 | +# SNDFILE_LIBRARY | |
| 5 | +# | |
| 6 | +# Environment variables used: | |
| 7 | +# SNDFILE_ROOT | |
| 8 | + | |
| 9 | +find_path(SNDFILE_INCLUDE_DIR sndfile.h | |
| 10 | + HINTS $ENV{SNDFILE_ROOT}/include) | |
| 11 | + | |
| 12 | +find_library(SNDFILE_LIBRARY NAMES sndfile | |
| 13 | + HINTS $ENV{SNDFILE_ROOT}/lib) | |
| 14 | + | |
| 15 | +include(FindPackageHandleStandardArgs) | |
| 16 | +find_package_handle_standard_args(SNDFILE DEFAULT_MSG SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR) | |
| 17 | + | |
| 18 | +mark_as_advanced(SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR) | |
| @@ -0,0 +1,64 @@ | ||
| 1 | +/* | |
| 2 | +** Copyright (c) 2002-2016, Erik de Castro Lopo <erikd@mega-nerd.com> | |
| 3 | +** All rights reserved. | |
| 4 | +** | |
| 5 | +** This code is released under 2-clause BSD license. Please see the | |
| 6 | +** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING | |
| 7 | +*/ | |
| 8 | + | |
| 9 | +/* Name of package */ | |
| 10 | +#define PACKAGE "${PROJECT_NAME}" | |
| 11 | + | |
| 12 | +/* Version number of package */ | |
| 13 | +#define VERSION "${PROJECT_VERSION}" | |
| 14 | + | |
| 15 | +/* Target processor clips on negative float to int conversion. */ | |
| 16 | +#cmakedefine01 CPU_CLIPS_NEGATIVE | |
| 17 | + | |
| 18 | +/* Target processor clips on positive float to int conversion. */ | |
| 19 | +#cmakedefine01 CPU_CLIPS_POSITIVE | |
| 20 | + | |
| 21 | +/* Target processor is big endian. */ | |
| 22 | +#cmakedefine01 CPU_IS_BIG_ENDIAN | |
| 23 | + | |
| 24 | +/* Target processor is little endian. */ | |
| 25 | +#cmakedefine01 CPU_IS_LITTLE_ENDIAN | |
| 26 | + | |
| 27 | +/* Define to 1 if you have the `alarm' function. */ | |
| 28 | +#cmakedefine01 HAVE_ALARM | |
| 29 | + | |
| 30 | +/* Define to 1 if you have the <alsa/asoundlib.h> header file. */ | |
| 31 | +#cmakedefine01 HAVE_ALSA | |
| 32 | + | |
| 33 | +/* Set to 1 if you have libfftw3. */ | |
| 34 | +#cmakedefine01 HAVE_FFTW3 | |
| 35 | + | |
| 36 | +/* Define if you have C99's lrint function. */ | |
| 37 | +#cmakedefine01 HAVE_LRINT | |
| 38 | + | |
| 39 | +/* Define if you have C99's lrintf function. */ | |
| 40 | +#cmakedefine01 HAVE_LRINTF | |
| 41 | + | |
| 42 | +/* Define if you have signal SIGALRM. */ | |
| 43 | +#cmakedefine01 HAVE_SIGALRM | |
| 44 | + | |
| 45 | +/* Define to 1 if you have the `signal' function. */ | |
| 46 | +#cmakedefine01 HAVE_SIGNAL | |
| 47 | + | |
| 48 | +/* Set to 1 if you have libsndfile. */ | |
| 49 | +#cmakedefine01 HAVE_SNDFILE | |
| 50 | + | |
| 51 | +/* Define to 1 if you have the <stdint.h> header file. */ | |
| 52 | +#cmakedefine01 HAVE_STDINT_H | |
| 53 | + | |
| 54 | +/* Define to 1 if you have the <sys/times.h> header file. */ | |
| 55 | +#cmakedefine01 HAVE_SYS_TIMES_H | |
| 56 | + | |
| 57 | +/* Set to 1 if compiling for Win32 */ | |
| 58 | +#cmakedefine01 OS_IS_WIN32 | |
| 59 | + | |
| 60 | +/* The size of `int', as computed by sizeof. */ | |
| 61 | +#define SIZEOF_INT ${SIZEOF_INT} | |
| 62 | + | |
| 63 | +/* The size of `long', as computed by sizeof. */ | |
| 64 | +#define SIZEOF_LONG ${SIZEOF_LONG} | |
| @@ -48,7 +48,6 @@ typedef long int32_t ; · 47 unmodified lines | ||
| 48 | 48 | # define WARN_UNUSED |
| 49 | 49 | #endif |
| 50 | 50 | |
| 51 | − | |
| 52 | 51 | #include "samplerate.h" |
| 53 | 52 | |
| 54 | 53 | enum |
| @@ -6,11 +6,14 @@ · 5 unmodified lines | ||
| 6 | 6 | ** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | +#include <stdlib.h> | |
| 9 | 10 | #include <stdio.h> |
| 10 | 11 | #include <math.h> |
| 11 | 12 | |
| 12 | 13 | #include <samplerate.h> |
| 13 | 14 | |
| 15 | +#include "util.h" | |
| 16 | + | |
| 14 | 17 | #define BUFFER_LEN (1<<15) |
| 15 | 18 | |
| 16 | 19 | #define BLOCK_LEN 100 |
| @@ -66,7 +66,10 @@ main (void) · 65 unmodified lines | ||
| 66 | 66 | static void |
| 67 | 67 | simple_test (int converter) |
| 68 | 68 | { |
| 69 | − int ilen = 199030, olen = 1000, error ; | |
| 69 | + // MSVC doesn't support variable-length arrays | |
| 70 | + #define ilen 199030 | |
| 71 | + #define olen 1000 | |
| 72 | + int error ; | |
| 70 | 73 | |
| 71 | 74 | { |
| 72 | 75 | float in [ilen] ; |
| @@ -176,12 +176,10 @@ get_cpu_name (void) · 175 unmodified lines | ||
| 176 | 176 | search = "hw.model" ; |
| 177 | 177 | is_pipe = 1 ; |
| 178 | 178 | #else |
| 179 | − file = NULL ; | |
| 179 | + return name; | |
| 180 | 180 | #endif |
| 181 | 181 | |
| 182 | − if (file == NULL) | |
| 183 | − return name ; | |
| 184 | − | |
| 182 | +#if defined (__linux__) || defined (__APPLE__) || defined (__FreeBSD__) | |
| 185 | 183 | if (search == NULL) |
| 186 | 184 | { printf ("Error : search is NULL in function %s.\n", __func__) ; |
| 187 | 185 | return name ; |
| @@ -216,5 +214,6 @@ get_cpu_name (void) · 28 unmodified lines | ||
| 216 | 214 | fclose (file) ; |
| 217 | 215 | |
| 218 | 216 | return name ; |
| 217 | +#endif | |
| 219 | 218 | } /* get_cpu_name */ |
| 220 | 219 | |
| @@ -6,6 +6,8 @@ · 5 unmodified lines | ||
| 6 | 6 | ** file at : https://github.com/erikd/libsamplerate/blob/master/COPYING |
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | +#include "config.h" | |
| 10 | + | |
| 9 | 11 | #define ABS(a) (((a) < 0) ? - (a) : (a)) |
| 10 | 12 | #define MIN(a,b) (((a) < (b)) ? (a) : (b)) |
| 11 | 13 | #define MAX(a,b) (((a) >= (b)) ? (a) : (b)) |