Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ SpeexDSP.spec
config.h
config.log
config.status
include/speex/speexdsp_config_types.h
*.sw[lmnop]
testdenoise
testecho
Expand All @@ -35,3 +34,4 @@ speexdsp.pc
stamp-*
patches
/m4
build/
43 changes: 43 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
cmake_minimum_required(VERSION 3.10)

project(speexdsp LANGUAGES C CXX)
Copy link

@phreed phreed Nov 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand with VERSION and DESCRIPTION:

project(speexdsp
    VERSION 1.2.1
    DESCRIPTION "speexdsp audio processing library"
    LANGUAGES C CXX
)


set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
option(USE_FIXED_POINT "Use fixed-point arithmetic" ON)

# Define compile-time options
if(USE_FIXED_POINT)
add_compile_definitions(FIXED_POINT=1)
else()
add_compile_definitions(FLOATING_POINT=1)
endif()

# 'M_PI': undeclared identifier
if(WIN32)
add_compile_definitions(_USE_MATH_DEFINES=1)
endif()

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorporate support for *.in files:

# Check for standard integer types and set size variables
include(CheckIncludeFile)
include(CheckTypeSize)

check_include_file(stdint.h HAVE_STDINT_H)
if(HAVE_STDINT_H)
    set(INCLUDE_STDINT 1)
endif()

# Check sizes of integer types
check_type_size("short" SIZEOF_SHORT)
check_type_size("int" SIZEOF_INT)
check_type_size("long" SIZEOF_LONG)

# Set type definitions based on size checks
if(SIZEOF_SHORT EQUAL 2)
    set(SIZE16 "short")
    set(USIZE16 "unsigned short")
elseif(SIZEOF_INT EQUAL 2)
    set(SIZE16 "int")
    set(USIZE16 "unsigned int")
else()
    set(SIZE16 "int16_t")
    set(USIZE16 "uint16_t")
endif()

if(SIZEOF_INT EQUAL 4)
    set(SIZE32 "int")
    set(USIZE32 "unsigned int")
elseif(SIZEOF_LONG EQUAL 4)
    set(SIZE32 "long")
    set(USIZE32 "unsigned long")
else()
    set(SIZE32 "int32_t")
    set(USIZE32 "uint32_t")
endif()

# Configure speexdsp_config_types.h
# Ensure the target directory exists
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/speex")
configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/speexdsp_config_types.h.in"
    "${CMAKE_BINARY_DIR}/include/speex/speexdsp_config_types.h"
    @ONLY
    


add_compile_definitions(EXPORT= USE_KISS_FFT=1)

# Include directories
include_directories(
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/libspeexdsp
)

# Source files
file(GLOB SPEEXDSP_SOURCES libspeexdsp/*.c)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we may want to include the generation of shared libraries.
In that case the test files should be excluded:

list(REMOVE_ITEM speexdsp_SOURCES
    ${CMAKE_SOURCE_DIR}/libspeexdsp/testdenoise.c
    ${CMAKE_SOURCE_DIR}/libspeexdsp/testecho.c
    ${CMAKE_SOURCE_DIR}/libspeexdsp/testjitter.c
    ${CMAKE_SOURCE_DIR}/libspeexdsp/testresample.c
    ${CMAKE_SOURCE_DIR}/libspeexdsp/testresample2.c
)

add_library(speexdsp ${SPEEXDSP_SOURCES})

# Installation rules
install(TARGETS speexdsp
EXPORT speexdspConfig
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(DIRECTORY include/ DESTINATION include)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section generates the cmake support files, from the *.in files.

install(DIRECTORY include/ DESTINATION include)
# Create and install pkg-config file
configure_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/speexdsp.pc.in"
    "${CMAKE_BINARY_DIR}/speexdsp.pc"
    @ONLY
)
install(FILES "${CMAKE_BINARY_DIR}/speexdsp.pc"
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
)

# Create config file
include(CMakePackageConfigHelpers)

configure_package_config_file(
    "${CMAKE_CURRENT_SOURCE_DIR}/cmake/speexdspConfig.cmake.in"
    "${CMAKE_BINARY_DIR}/speexdspConfig.cmake"
    INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/speexdsp
)

write_basic_package_version_file(
    "${CMAKE_BINARY_DIR}/speexdspConfigVersion.cmake"
    VERSION ${PROJECT_VERSION}
    COMPATIBILITY SameMajorVersion
)

install(FILES
    "${CMAKE_BINARY_DIR}/speexdspConfig.cmake"
    "${CMAKE_BINARY_DIR}/speexdspConfigVersion.cmake"
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/speexdsp
)

11 changes: 11 additions & 0 deletions include/speex/speexdsp_config_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef SPEEX_CONFIG_TYPES_H
#define SPEEX_CONFIG_TYPES_H

#include <stdint.h>

typedef int16_t spx_int16_t;
typedef uint16_t spx_uint16_t;
typedef int32_t spx_int32_t;
typedef uint32_t spx_uint32_t;

#endif
12 changes: 0 additions & 12 deletions include/speex/speexdsp_config_types.h.in

This file was deleted.