-
Notifications
You must be signed in to change notification settings - Fork 216
feat: add cmake #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: add cmake #53
Conversation
|
I think the PR should include the cmake support files:
Is there a reason you replaced the |
phreed
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The library products should include cmake support files:
- lib/pkgconfig/speexdsp.pc
- lib/cmake/speexdsp/speexdspConfig.cmake
- lib/cmake/speexdsp/speexdspConfigVersion.cmake
| @@ -0,0 +1,43 @@ | |||
| cmake_minimum_required(VERSION 3.10) | |||
|
|
|||
| project(speexdsp LANGUAGES C CXX) | |||
There was a problem hiding this comment.
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
)| if(WIN32) | ||
| add_compile_definitions(_USE_MATH_DEFINES=1) | ||
| endif() | ||
|
|
There was a problem hiding this comment.
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
| ) | ||
|
|
||
| # Source files | ||
| file(GLOB SPEEXDSP_SOURCES libspeexdsp/*.c) |
There was a problem hiding this comment.
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
)| LIBRARY DESTINATION lib | ||
| ARCHIVE DESTINATION lib | ||
| ) | ||
| install(DIRECTORY include/ DESTINATION include) |
There was a problem hiding this comment.
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
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the *.in files should be preferred, such as speexdsp_config_types.h.in over the speexdsp_config_types.h.
speexdsp-cmake-support.zip
|
FYI I can’t work on this PR anymore since it’s from about a year ago. I assume you can take it from here. Thanks! |
I just noticed that this is not the source repository but only a mirror. |
Resolve #52 and maybe https://gitlab.xiph.org/xiph/speex/-/issues/2051