[Speex-dev] [PATCH] Add CMake build script

evpobr evpobr at gmail.com
Mon May 29 13:18:34 UTC 2017


Description
===========

This patch adds support of CMake meta build system, so you can generate
Unix makefiles, VS 6.0-2017 projects and many more.

Features
========

* Win32 and Linux tested
* Travis CI test added
* Generates working Visual Studio 6.0-2017 solutions
* Generates working Unix Makefile
* Supported options (<option> - <default value>):
  * `ENABLE_FLOATING_POINT` - on
  * `ENABLE_FIXED_POINT` - off
  * `ENABLE_FIXED_POINT_DEBUG` - off
  * `USE_GPL_FFTW3` - off
  * `DISABLE_FLOAT_API` - off
  * `DISABLE_VBR` - off
  * `ENABLE_VORBIS_PSY` - off
  * `ENABLE_SSE` - on if supported
  * `ENABLE_ARM4_ASM` - off
  * `ENABLE_ARM5E_ASM` - off
  * `ENABLE_BLACKFIN_ASM` - off
  * `ENABLE_TI_C55X` - off
  * `USE_SPEEXDSP` - on if library found
  * `DISABLE_BINARIES` - off
  * `ENABLE_PACKAGE_CONFIG` - on, [CMake specific](https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#package-configuration-file)
* Configured conditionals (`config.h`):
  * `WORDS_BIGENDIAN`
  * `FLOATING_POINT`
  * `FIXED_POINT`
  * `FIXED_POINT_DEBUG`
  * `DISABLE_FLOAT_API`
  * `_USE_SSE`
  * `ARM4_ASM`
  * `ARM5E_ASM`
  * `BFIN_ASM`
  * `TI_C55X`
  * `DISABLE_VBR`
  * `USE_SPEEXDSP`
  * `VORBIS_PSYCHO`
  * `HAVE_GETOPT_H`
  * `HAVE_GETOPT_LONG`
  * `VAR_ARRAYS`
  * `USE_ALLOCA`
  * `HAVE_ALLOCA_H`
  * `USE_SMALLFT`
  * `USE_KISS_FFT`
  * `USE_GPL_FFTW3`
  * `EXPORT`
* Installation supported
* Package config mode supported

How to use
==========

Required tools and libraries:

* CMake >= 3.1
* Ogg, SpeexDSP packages (headers and import libraries), recommended
* FFTW3 package, optional

Type commands:

```
mkdir cmake-build
cd cmake-build
cmake ..
cmake . --build
```

or use CMake GUI.
---
 .gitignore                |  10 ++
 .travis.yml               |  34 +++-
 CMakeLists.txt            | 439 ++++++++++++++++++++++++++++++++++++++++++++++
 Makefile.am               |   7 +-
 cmake/FindFFTW.cmake      |  28 +++
 cmake/FindOgg.cmake       |  30 ++++
 cmake/FindSpeexDsp.cmake  |  28 +++
 cmake/SpeexConfig.cmake   |   1 +
 cmake/TestVarArrays.cmake |  22 +++
 config.h.cmake            |  23 +++
 10 files changed, 613 insertions(+), 9 deletions(-)
 create mode 100644 CMakeLists.txt
 create mode 100644 cmake/FindFFTW.cmake
 create mode 100644 cmake/FindOgg.cmake
 create mode 100644 cmake/FindSpeexDsp.cmake
 create mode 100644 cmake/SpeexConfig.cmake
 create mode 100644 cmake/TestVarArrays.cmake
 create mode 100644 config.h.cmake

diff --git a/.gitignore b/.gitignore
index 7c30999..99a35e5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -43,3 +43,13 @@ src/speexdec
 src/speexenc
 stamp-*
 patches
+
+CMakeCache.txt
+CMakeFiles
+CMakeScripts
+Testing
+Makefile
+cmake_install.cmake
+install_manifest.txt
+compile_commands.json
+CTestTestfile.cmake
diff --git a/.travis.yml b/.travis.yml
index ff85bc3..2bc028b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,11 +1,25 @@
 language: c
+sudo: false
+dist: trusty
+addons:
+  apt:
+    packages:
+      - libogg-dev
+      - libspeexdsp-dev
+      - libfftw3-dev
 
 env:
-  - CONFIG=""
-  - CONFIG="--enable-fixed-point"
-  - CONFIG="--enable-fixed-point --disable-float-api"
-  - CONFIG="--enable-vorbis-psy"
-  - CONFIG="--disable-binaries"
+  matrix:
+    - CMAKE=1 CONFIG=""
+    - CMAKE=1 CONFIG="-DENABLE_FIXED_POINT:BOOL=TRUE -DENABLE_FLOATING_POINT:BOOL=FALSE"
+    - CMAKE=1 CONFIG="-DENABLE_FIXED_POINT:BOOL=TRUE -DENABLE_FLOATING_POINT:BOOL=FALSE -DDISABLE_FLOAT_API:BOOL=TRUE"
+    - CMAKE=1 CONFIG="-DENABLE_VORBIS_PSY:BOOL=TRUE"
+    - CMAKE=1 CONFIG="-DDISABLE_BINARIES:BOOL=TRUE"
+    - AUTOTOOLS=1 CONFIG=""
+    - AUTOTOOLS=1 CONFIG="--enable-fixed-point"
+    - AUTOTOOLS=1 CONFIG="--enable-fixed-point --disable-float-api"
+    - AUTOTOOLS=1 CONFIG="--enable-vorbis-psy"
+    - AUTOTOOLS=1 CONFIG="--disable-binaries"
 
 os:
   - linux
@@ -15,7 +29,11 @@ compiler:
   - gcc
   - clang
 
+before_install:
+  - if [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
+      brew install libogg speexdsp fftw;
+    fi
+
 script:
-  - ./autogen.sh
-  - ./configure $CONFIG
-  - make distcheck
+  - if [ "$CMAKE" == "1" ]; then mkdir cmake-build; cd cmake-build; cmake .. $CONFIG -DBUILD_SHARED_LIBS:BOOL=TRUE -DCMAKE_INSTALL_PREFIX:PATH=$HOME/cmake-check; make install; fi
+  - if [ "$AUTOTOOLS" == "1" ]; then ./autogen.sh; ./configure $CONFIG; make distcheck; fi
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..06a38a2
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,439 @@
+cmake_minimum_required(VERSION 3.1)
+
+project(speex VERSION 1.2.0 LANGUAGES C)
+
+set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
+
+include(CheckIncludeFile)
+include(CheckSymbolExists)
+include(CheckLibraryExists)
+include(CMakeDependentOption)
+include(FeatureSummary)
+include(TestVarArrays)
+include(CheckCCompilerFlag)
+include(GNUInstallDirs)
+include(TestBigEndian)
+
+test_big_endian(WORDS_BIGENDIAN)
+
+check_include_file(inttypes.h HAVE_INTTYPES_H)
+if(HAVE_INTTYPES_H)
+	set(INCLUDE_STDINT "#include <inttypes.h>")
+else()
+	check_include_file(stdint.h HAVE_STDINT_H)
+	if(HAVE_STDINT_H)
+		set(INCLUDE_STDINT "#include <stdint.h>")
+	else()
+		check_include_file(sys/types.h INCLUDE_SYS_TYPES_H)
+		if(HAVE_SYS_TYPES_H)
+			set(INCLUDE_STDINT "#include <sys/types.h>")
+		endif()
+	endif()
+endif()
+set(SIZE16 int16_t)
+set(USIZE16 uint16_t)
+set(SIZE32 int32_t)
+set(USIZE32 uint32_t)
+set(SIZE64 int64_t)
+configure_file(include/speex/speex_config_types.h.in include/speex/speex_config_types.h @ONLY)
+
+test_vararrays(VAR_ARRAYS)
+if(NOT VAR_ARRAYS)
+	check_include_file(alloca.h HAVE_ALLOCA_H)
+	if(WIN32)
+		set(USE_ALLOCA 1)
+	else()
+		check_symbol_exists(alloca "stdlib.h;alloca.h"  USE_ALLOCA)
+	endif()
+endif()
+
+option(ENABLE_FLOATING_POINT "Compile as floating-point" ON)
+option(ENABLE_FIXED_POINT "Compile as fixed-point" OFF)
+
+
+if(ENABLE_FLOATING_POINT AND ENABLE_FIXED_POINT)
+	message(FATAL_ERROR "Select one of ENABLE_FLOATING_POINT of ENABLE_FIXED_POINT.")
+endif()
+if((NOT ENABLE_FLOATING_POINT) AND (NOT ENABLE_FIXED_POINT))
+	message(FATAL_ERROR "Select one of ENABLE_FLOATING_POINT of ENABLE_FIXED_POINT.")
+endif()
+
+find_package(FFTW)
+
+cmake_dependent_option(USE_GPL_FFTW3 "Use FFTW3 for FFT" OFF "FFTW_FOUND; ENABLE_FLOATING_POINT" OFF)
+
+if(ENABLE_FLOATING_POINT)
+	set(FLOATING_POINT 1)
+	set(FIXED_POINT 0)
+	set(USE_KISS_FFT 0)
+	if(NOT USE_GPL_FFTW3)
+		set(USE_SMALLFT 1)
+	endif()
+else()
+	set(FLOATING_POINT 0)
+	set(FIXED_POINT 1)
+	set(USE_KISS_FFT 1)
+	set(USE_SMALLFT 0)
+	set(USE_GPL_FFTW3 0)
+endif()
+
+cmake_dependent_option(ENABLE_FIXED_POINT_DEBUG "Debug fixed-point implementation" OFF "ENABLE_FIXED_POINT" OFF)
+set(FIXED_POINT_DEBUG ${ENABLE_FIXED_POINT_DEBUG})
+
+option(DISABLE_FLOAT_API "Disable all parts of the API that are using floats" OFF)
+option(DISABLE_VBR "Disable VBR and VAD from the codec" OFF)
+cmake_dependent_option(ENABLE_VORBIS_PSY "Enable the Vorbis psy model" OFF "NOT ENABLE_FIXED_POINT;VAR_ARRAYS" OFF)
+set(VORBIS_PSYCHO ${ENABLE_VORBIS_PSY})
+
+if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)")
+    set(CPU_IS_X86 TRUE)
+else()
+    set(CPU_IS_X86 FALSE)
+endif()
+if(CPU_IS_X86)
+	check_include_file(xmmintrin.h HAVE_XMMINTRIN_H)
+endif()
+cmake_dependent_option(ENABLE_SSE "Enable SSE support" ON "CPU_IS_X86;HAVE_XMMINTRIN_H;ENABLE_FLOATING_POINT" OFF)
+if(ENABLE_SSE)
+	set(_USE_SSE 1)
+	check_c_compiler_flag("/arch:SSE" ARCH_SSE_FLAG)
+	if(ARCH_SSE_FLAG)
+		set(SSE_FLAGS "/arch:SSE")
+	else()
+		check_c_compiler_flag("-msse" MSSE_FLAG)
+		if(MSSE_FLAG)
+			set(SSE_FLAGS "-msse")
+		endif()
+	endif()
+endif()
+
+if (CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
+	set(CPU_IS_ARM 1)
+endif ()
+cmake_dependent_option(ENABLE_ARM4_ASM "Make use of ARM4 assembly optimizations" OFF "CPU_IS_ARM;ENABLE_FIXED_POINT" OFF)
+set(ARM4_ASM ${ENABLE_ARM4_ASM})
+cmake_dependent_option(ENABLE_ARM5E_ASM "Make use of ARM5E assembly optimizations" OFF "CPU_IS_ARM;ENABLE_FIXED_POINT" OFF)
+set(ARM5E_ASM ${ENABLE_ARM5E_ASM})
+cmake_dependent_option(ENABLE_BLACKFIN_ASM "Make use of Blackfin assembly optimizations" OFF "NOT CPU_IS_X86;ENABLE_FIXED_POINT" OFF)
+set(BFIN_ASM ${ENABLE_BLACKFIN_ASM})
+cmake_dependent_option(ENABLE_TI_C55X "Enable support for TI C55X DSP" OFF "NOT CPU_IS_X86" OFF)
+set(TI_C55X ${ENABLE_TI_C55X})
+
+if(NOT WIN32)
+	check_library_exists(m cos "" HAVE_LIBM)
+	if(HAVE_LIBM)
+		find_library(LIBM m)
+	endif()
+endif()
+
+if(MSVC)
+	add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
+endif(MSVC)
+
+find_package(Ogg)
+find_package(SpeexDsp)
+
+cmake_dependent_option(USE_SPEEXDSP "Enable SpeexDSP library" ON "SpeexDsp_FOUND" OFF)
+cmake_dependent_option(DISABLE_BINARIES "Do not build the encoder and decoder programs, only the library" OFF "Ogg_FOUND" OFF)
+
+check_c_compiler_flag("-fvisibility=hidden" HAS_VISIBILITY)
+if(HAS_VISIBILITY)
+	SET(EXPORT "__attribute__((visibility(\"default\")))")
+endif()
+
+check_include_file(getopt.h HAVE_GETOPT_H)
+if(HAVE_GETOPT_H)
+	check_symbol_exists(getopt_long getopt.h HAVE_GETOPT_LONG)
+endif()
+
+option (ENABLE_PACKAGE_CONFIG "Generate and install package config file" ON)
+
+set_package_properties(Ogg PROPERTIES TYPE RECOMMENDED
+	URL "www.xiph.org/ogg/"
+	DESCRIPTION "library for manipulating ogg bitstreams"
+	PURPOSE "Required to build speexenc and speexdec tools")
+set_package_properties(SpeexDsp PROPERTIES TYPE RECOMMENDED
+	URL "https://speex.org/"
+	DESCRIPTION "speech processing library that goes along with the Speex codec"
+	PURPOSE "Enables speexenc tool preprocessing options")
+set_package_properties(FFTW PROPERTIES TYPE OPTIONAL
+	URL "http://www.fftw.org/"
+	DESCRIPTION "fast Fourier transform library"
+	PURPOSE "Enables use of FFTW for fast Fourier transforms")
+add_feature_info(ENABLE_ALLOCA USE_ALLOCA "Make use of alloca function.")
+add_feature_info(ENABLE_VAR_ARRAYS VAR_ARRAYS "Make use of variable-length arrays.")
+add_feature_info(ENABLE_FLOATING_POINT ENABLE_FLOATING_POINT "compile as floating-point.")
+add_feature_info(ENABLE_FIXED_POINT ENABLE_FIXED_POINT "compile as fixed-point.")
+add_feature_info(ENABLE_FIXED_POINT_DEBUG ENABLE_FIXED_POINT_DEBUG "debug fixed-point implementation.")
+add_feature_info(ENABLE_SSE ENABLE_SSE "enable SSE support.")
+add_feature_info(ENABLE_ARM4_ASM ENABLE_ARM4_ASM "make use of ARM4 assembly optimizations.")
+add_feature_info(ENABLE_ARM5E_ASM ENABLE_ARM5E_ASM "make use of ARM5E assembly optimizations.")
+add_feature_info(ENABLE_BLACKFIN_ASM ENABLE_BLACKFIN_ASM "make use of Blackfin assembly optimizations.")
+add_feature_info(ENABLE_TI_C55X ENABLE_TI_C55X "enable support for TI C55X DSP.")
+add_feature_info(DISABLE_FLOAT_API DISABLE_FLOAT_API "disable all parts of the API that are using floats.")
+add_feature_info(DISABLE_VBR DISABLE_VBR "disable VBR and VAD from the codec.")
+add_feature_info(ENABLE_VORBIS_PSY ENABLE_VORBIS_PSY "enable the Vorbis psy model.")
+add_feature_info(ENABLE_SPEEXDSP USE_SPEEXDSP "enable speexenc preprocessing options.")
+add_feature_info(DISABLE_BINARIES DISABLE_BINARIES "do not build the encoder and decoder programs, only the library.")
+add_feature_info(ENABLE_PACKAGE_CONFIG ENABLE_PACKAGE_CONFIG "generate and install package config file")
+add_feature_info(USE_GPL_FFTW3 USE_GPL_FFTW3 "Use FFTW3 library for fast Fourier transforms")
+feature_summary(WHAT ALL)
+
+configure_file(config.h.cmake config.h)
+
+set(speex_PUBLIC_HEADERS
+	include/speex/speex.h
+	include/speex/speex_bits.h
+	include/speex/speex_callbacks.h
+	include/speex/speex_header.h
+	include/speex/speex_stereo.h
+	include/speex/speex_types.h
+	${CMAKE_CURRENT_BINARY_DIR}/include/speex/speex_config_types.h)
+
+set(speex_SOURCES
+	libspeex/cb_search.c
+	libspeex/exc_10_32_table.c
+	libspeex/exc_8_128_table.c
+	libspeex/filters.c
+	libspeex/gain_table.c
+	libspeex/hexc_table.c
+	libspeex/high_lsp_tables.c
+	libspeex/lsp.c
+	libspeex/ltp.c
+	libspeex/speex.c
+	libspeex/stereo.c
+	libspeex/vbr.c
+	libspeex/vq.c
+	libspeex/bits.c
+	libspeex/exc_10_16_table.c
+	libspeex/exc_20_32_table.c
+	libspeex/exc_5_256_table.c
+	libspeex/exc_5_64_table.c
+	libspeex/gain_table_lbr.c
+	libspeex/hexc_10_32_table.c
+	libspeex/lpc.c
+	libspeex/lsp_tables_nb.c
+	libspeex/modes.c
+	libspeex/modes_wb.c
+	libspeex/nb_celp.c
+	libspeex/quant_lsp.c
+	libspeex/sb_celp.c
+	libspeex/speex_callbacks.c
+	libspeex/speex_header.c
+	libspeex/window.c
+	libspeex/arch.h
+	libspeex/bfin.h
+	libspeex/cb_search_arm4.h
+	libspeex/cb_search_bfin.h
+	libspeex/cb_search_sse.h
+	libspeex/filters.h
+	libspeex/filters_arm4.h
+	libspeex/filters_bfin.h
+	libspeex/filters_sse.h
+	libspeex/fixed_arm4.h
+	libspeex/fixed_arm5e.h
+	libspeex/fixed_bfin.h
+	libspeex/fixed_debug.h
+	libspeex/lpc.h
+	libspeex/lpc_bfin.h
+	libspeex/ltp.h
+	libspeex/ltp_arm4.h
+	libspeex/ltp_sse.h
+	libspeex/math_approx.h
+	libspeex/misc_bfin.h
+	libspeex/nb_celp.h
+	libspeex/quant_lsp.h
+	libspeex/sb_celp.h
+	libspeex/stack_alloc.h
+	libspeex/vbr.h
+	libspeex/vq.h
+	libspeex/vq_arm4.h
+	libspeex/vq_bfin.h
+	libspeex/vq_sse.h
+	libspeex/cb_search.h
+	libspeex/fftwrap.h
+	libspeex/fftwrap.c
+	libspeex/fixed_generic.h
+	libspeex/lsp.h
+	libspeex/lsp_bfin.h
+	libspeex/ltp_bfin.h
+	libspeex/modes.h
+	libspeex/os_support.h
+	libspeex/quant_lsp_bfin.h
+	libspeex/smallft.h)
+
+add_library(speex ${speex_PUBLIC_HEADERS} ${speex_SOURCES})
+target_compile_definitions(speex
+	PRIVATE -DHAVE_CONFIG_H)
+target_include_directories(speex
+	PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+	PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include/speex>
+	PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+	PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
+if(USE_GPL_FFTW3)
+	target_include_directories(speex
+		PRIVATE $<BUILD_INTERFACE:${FFTW_INCLUDE_DIRS}>)
+	if(BUILD_SHARED_LIBS)
+		target_link_libraries(speex PRIVATE ${FFTW_LIBRARIES})
+	else()
+		target_link_libraries(speex PUBLIC ${FFTW_LIBRARIES})
+	endif()
+endif()
+if(HAVE_LIBM)
+	if(BUILD_SHARED_LIBS)
+		target_link_libraries(speex PRIVATE ${LIBM})
+	else()
+		target_link_libraries(speex PUBLIC ${LIBM})
+	endif()
+endif()
+target_compile_options(speex PRIVATE ${SSE_FLAGS})
+if(WIN32 AND BUILD_SHARED_LIBS)
+	target_sources(speex PRIVATE win32/libspeex.def)
+	set_target_properties (speex PROPERTIES OUTPUT_NAME "libspeex")
+endif()
+set_target_properties (speex PROPERTIES
+		PUBLIC_HEADER "${speex_PUBLIC_HEADERS}"
+		SOVERSION 1.5.1
+		VERSION 1)
+if(EXPORT AND BUILD_SHARED_LIBS)
+	set_target_properties (speex PROPERTIES
+			C_VISIBILITY_PRESET hidden)
+endif()
+if(USE_SMALLFT)
+	target_sources(speex PRIVATE
+		libspeex/smallft.c)
+elseif(USE_KISS_FFT)
+	target_sources(speex PRIVATE
+		libspeex/kiss_fft.c
+		libspeex/_kiss_fft_guts.h
+		libspeex/kiss_fft.h
+		libspeex/kiss_fftr.c
+		libspeex/kiss_fftr.h)
+endif()
+if(VORBIS_PSYCHO)
+	target_sources(speex PRIVATE
+		libspeex/vorbis_psy.h
+		libspeex/vorbis_psy.c)
+endif()
+
+# Programs
+
+if(NOT DISABLE_BINARIES)
+
+SET(speexenc_SOURCES
+	src/speexenc.c
+	src/wav_io.c
+	src/skeleton.c)
+add_executable(speexenc ${speexenc_SOURCES})
+target_include_directories(speexenc
+	PRIVATE
+		$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+		$<BUILD_INTERFACE:${OGG_INCLUDE_DIRS}>
+		$<BUILD_INTERFACE:${SPEEXDSP_INCLUDE_DIRS}>)
+target_link_libraries(speexenc
+	PUBLIC speex ${OGG_LIBRARIES} ${SPEEXDSP_LIBRARIES})
+if(WIN32)
+	target_link_libraries(speexenc PRIVATE winmm.lib)
+endif()
+target_compile_definitions(speexenc
+	PRIVATE -DHAVE_CONFIG_H)
+if(NOT HAVE_GETOPT_LONG)
+	target_sources(speexenc PRIVATE
+		src/getopt.c
+		src/getopt1.c
+		src/wave_out.c)
+endif()
+
+SET(speexdec_SOURCES
+	src/speexdec.c
+	src/wav_io.c)
+add_executable(speexdec ${speexdec_SOURCES})
+target_include_directories(speexdec
+	PRIVATE
+		$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
+		$<BUILD_INTERFACE:${OGG_INCLUDE_DIRS}>)
+target_link_libraries(speexdec PUBLIC speex ${OGG_LIBRARIES})
+if(WIN32)
+	target_link_libraries(speexdec PRIVATE winmm.lib)
+endif()
+target_compile_definitions(speexdec
+	PRIVATE -DHAVE_CONFIG_H)
+if(NOT HAVE_GETOPT_LONG)
+	target_sources(speexdec PRIVATE
+		src/getopt.c
+		src/getopt1.c
+		src/wave_out.c)
+endif()
+
+# Tests (no automatic checking supported)
+
+add_executable(testenc libspeex/testenc.c)
+target_include_directories(testenc
+	PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
+target_link_libraries(testenc
+	PRIVATE ${LIBM}
+	PUBLIC speex)
+target_compile_definitions(testenc
+	PRIVATE -DHAVE_CONFIG_H)
+add_executable(testenc_wb libspeex/testenc_wb.c)
+target_include_directories(testenc_wb
+	PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
+target_link_libraries(testenc_wb
+	PRIVATE ${LIBM}
+	PUBLIC speex)
+target_compile_definitions(testenc_wb
+	PRIVATE -DHAVE_CONFIG_H)
+add_executable(testenc_uwb libspeex/testenc_uwb.c)
+target_include_directories(testenc_uwb
+	PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
+target_link_libraries(testenc_uwb
+	PRIVATE ${LIBM}
+	PUBLIC speex)
+target_compile_definitions(testenc_uwb
+	PRIVATE -DHAVE_CONFIG_H)
+
+endif()
+
+# Installation
+
+set(INSTALL_TARGETS speex)
+if(NOT DISABLE_BINARIES)
+	list(APPEND INSTALL_TARGETS speexenc speexdec)
+endif()
+install(TARGETS ${INSTALL_TARGETS}
+	EXPORT SpeexTargets
+	RUNTIME	DESTINATION			${CMAKE_INSTALL_BINDIR}
+	ARCHIVE DESTINATION			${CMAKE_INSTALL_LIBDIR}
+	LIBRARY DESTINATION			${CMAKE_INSTALL_LIBDIR}
+	PUBLIC_HEADER DESTINATION	${CMAKE_INSTALL_INCLUDEDIR}/speex)
+install(FILES doc/manual.pdf DESTINATION ${CMAKE_INSTALL_DOCDIR})
+install(FILES src/speexenc.1 src/speexdec.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+install(FILES speex.m4 DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/aclocal)
+
+set(prefix ${CMAKE_INSTALL_PREFIX})
+set(exec_prefix $\{prefix\})
+set(libdir $\{exec_prefix\}/${CMAKE_INSTALL_LIBDIR})
+set(includedir $\{prefix\}/${CMAKE_INSTALL_INCLUDEDIR})
+set(SPEEX_VERSION ${PROJECT_VERSION})
+if(HAVE_LIBM)
+	set(LIBM -lm)
+endif()
+configure_file(speex.pc.in speex.pc @ONLY)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/speex.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+
+set(PACKAGE ${PROJECT_NAME})
+set(VERSION ${PROJECT_VERSION})
+configure_file(Speex.spec.in Speex.spec @ONLY)
+
+if (ENABLE_PACKAGE_CONFIG)
+	include (CMakePackageConfigHelpers)
+	write_basic_package_version_file (SpeexConfigVersion.cmake COMPATIBILITY SameMajorVersion)
+	if (UNIX)
+		set(CMAKE_INSTALL_PACKAGEDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
+	elseif(WIN32)
+		set(CMAKE_INSTALL_PACKAGEDIR cmake)
+	endif()
+	install(EXPORT SpeexTargets DESTINATION ${CMAKE_INSTALL_PACKAGEDIR})
+	install(FILES ${CMAKE_CURRENT_BINARY_DIR}/SpeexConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_PACKAGEDIR})
+	install(FILES cmake/SpeexConfig.cmake DESTINATION ${CMAKE_INSTALL_PACKAGEDIR})
+endif()
diff --git a/Makefile.am b/Makefile.am
index dc90415..155f0a9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,7 +11,12 @@ m4data_DATA = speex.m4
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = speex.pc
 
-EXTRA_DIST = Speex.spec Speex.spec.in Speex.kdevelop speex.m4 speex.pc.in README.blackfin README.symbian README.TI-DSP
+EXTRA_DIST = Speex.spec Speex.spec.in Speex.kdevelop speex.m4 speex.pc.in \
+	README.blackfin README.symbian README.TI-DSP CMakeLists.txt config.h.cmake \
+	$(cmake_files)
+
+cmake_files = cmake/FindOgg.cmake cmake/FindSpeexDsp.cmake \
+	cmake/FindSpeexDsp.cmake cmake/SpeexConfig.cmake cmake/TestVarArrays.cmake
 
 #Fools KDevelop into including all files
 SUBDIRS = libspeex include doc win32 symbian ti
diff --git a/cmake/FindFFTW.cmake b/cmake/FindFFTW.cmake
new file mode 100644
index 0000000..57e13e4
--- /dev/null
+++ b/cmake/FindFFTW.cmake
@@ -0,0 +1,28 @@
+# - Find fftw
+# Find the native fftw includes and libraries
+#
+#  FFTW_INCLUDE_DIRS - where to find fftw.h, etc.
+#  FFTW_LIBRARIES    - List of libraries when using fftw.
+#  FFTW_FOUND        - True if fftw found.
+
+if(FFTW_INCLUDE_DIR)
+    # Already in cache, be silent
+    set(FFTW_FIND_QUIETLY TRUE)
+endif(FFTW_INCLUDE_DIR)
+
+find_package (PkgConfig QUIET)
+pkg_check_modules(PC_FFTW QUIET fftw3f)
+
+find_path(FFTW_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW_INCLUDEDIR} ${PC_FFTW_INCLUDE_DIRS} ${FFTW_ROOT} PATH_SUFFIXES include)
+find_library(FFTW_LIBRARY NAMES fftw3f HINTS ${PC_FFTW_LIBDIR} ${PC_FFTW_LIBRARY_DIRS} ${FFTW_ROOT} PATH_SUFFIXES lib)
+# Handle the QUIETLY and REQUIRED arguments and set FFTW_FOUND
+# to TRUE if all listed variables are TRUE.
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(FFTW DEFAULT_MSG FFTW_INCLUDE_DIR FFTW_LIBRARY)
+
+if (FFTW_FOUND)
+	set (FFTW_LIBRARIES ${FFTW_LIBRARY})
+	set (FFTW_INCLUDE_DIRS ${FFTW_INCLUDE_DIR})
+endif (FFTW_FOUND)
+
+mark_as_advanced(FFTW_INCLUDE_DIR FFTW_LIBRARY)
diff --git a/cmake/FindOgg.cmake b/cmake/FindOgg.cmake
new file mode 100644
index 0000000..a710518
--- /dev/null
+++ b/cmake/FindOgg.cmake
@@ -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)
diff --git a/cmake/FindSpeexDsp.cmake b/cmake/FindSpeexDsp.cmake
new file mode 100644
index 0000000..d4a332f
--- /dev/null
+++ b/cmake/FindSpeexDsp.cmake
@@ -0,0 +1,28 @@
+# - Find speexdsp
+# Find the native speexdsp includes and libraries
+#
+#  SPEEXDSP_INCLUDE_DIRS - where to find speex_preprocess.h, etc.
+#  SPEEXDSP_LIBRARIES    - List of libraries when using speexdsp.
+#  SpeexDsp_FOUND        - True if speexdsp found.
+
+if(SPEEXDSP_INCLUDE_DIR)
+    # Already in cache, be silent
+    set(SPEEXDSP_FIND_QUIETLY TRUE)
+endif(SPEEXDSP_INCLUDE_DIR)
+
+find_package (PkgConfig QUIET)
+pkg_check_modules(PC_SPEEXDSP QUIET speexdsp)
+
+find_path(SPEEXDSP_INCLUDE_DIR speex/speex_preprocess.h HINTS ${PC_SPEEXDSP_INCLUDEDIR} ${PC_SPEEXDSP_INCLUDE_DIRS} ${SPEEXDSP_ROOT} PATH_SUFFIXES include)
+find_library(SPEEXDSP_LIBRARY NAMES speexdsp HINTS ${PC_SPEEXDSP_LIBDIR} ${PC_SPEEXDSP_LIBRARY_DIRS} ${SPEEXDSP_ROOT} PATH_SUFFIXES lib)
+# Handle the QUIETLY and REQUIRED arguments and set SPEEXDSP_FOUND
+# to TRUE if all listed variables are TRUE.
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(SpeexDsp DEFAULT_MSG SPEEXDSP_INCLUDE_DIR SPEEXDSP_LIBRARY)
+
+if (SPEEXDSP_FOUND)
+	set (SPEEXDSP_LIBRARIES ${SPEEXDSP_LIBRARY})
+	set (SPEEXDSP_INCLUDE_DIRS ${SPEEXDSP_INCLUDE_DIR})
+endif (SPEEXDSP_FOUND)
+
+mark_as_advanced(SPEEXDSP_INCLUDE_DIR SPEEXDSP_LIBRARY)
diff --git a/cmake/SpeexConfig.cmake b/cmake/SpeexConfig.cmake
new file mode 100644
index 0000000..dbc99e8
--- /dev/null
+++ b/cmake/SpeexConfig.cmake
@@ -0,0 +1 @@
+include (${CMAKE_CURRENT_LIST_DIR}/SpeexTargets.cmake)
diff --git a/cmake/TestVarArrays.cmake b/cmake/TestVarArrays.cmake
new file mode 100644
index 0000000..11f413f
--- /dev/null
+++ b/cmake/TestVarArrays.cmake
@@ -0,0 +1,22 @@
+include(CheckCSourceCompiles)
+
+macro(TEST_VARARRAYS VARIABLE)
+	if(NOT DEFINED ${VARIABLE})
+		check_c_source_compiles(
+			"
+			void main(void)
+			{
+				int foo;
+				foo = 10;
+				int array[foo];
+			};
+			"
+			VARARRAYS_SUPPORT)
+		set(${VARIABLE} ${VARARRAYS_SUPPORT} CACHE INTERNAL "C99 variable-size arrays support" FORCE)
+		if(${VARIABLE})
+			set(RESULT_TEXT "success")
+		else()
+			set(RESULT_TEXT "failed")
+		endif()
+	endif()
+endmacro(TEST_VARARRAYS VARIABLE)
diff --git a/config.h.cmake b/config.h.cmake
new file mode 100644
index 0000000..cbf88b1
--- /dev/null
+++ b/config.h.cmake
@@ -0,0 +1,23 @@
+#cmakedefine WORDS_BIGENDIAN
+#cmakedefine FLOATING_POINT
+#cmakedefine FIXED_POINT
+#cmakedefine FIXED_POINT_DEBUG
+#cmakedefine DISABLE_FLOAT_API
+#cmakedefine _USE_SSE
+#cmakedefine ARM4_ASM
+#cmakedefine ARM5E_ASM
+#cmakedefine BFIN_ASM
+#cmakedefine TI_C55X
+#cmakedefine DISABLE_VBR
+#cmakedefine USE_SPEEXDSP
+#cmakedefine VORBIS_PSYCHO
+#cmakedefine HAVE_GETOPT_H
+#cmakedefine HAVE_GETOPT_LONG
+#cmakedefine VAR_ARRAYS
+#cmakedefine USE_ALLOCA
+#cmakedefine HAVE_ALLOCA_H
+#cmakedefine USE_SMALLFT
+#cmakedefine USE_KISS_FFT
+#cmakedefine USE_GPL_FFTW3
+
+#define EXPORT @EXPORT@
-- 
2.12.0.windows.1



More information about the Speex-dev mailing list