Skip to content
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

Fix build with FFmpeg 7, C++17, and external libresample and kissfft #53

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ matrix:
script:
- mkdir -p build
- cd build
- cmake -DBUILD_TEST=ON ..
- cmake ..
- make -j
- ctest -V

Expand All @@ -31,3 +31,5 @@ addons:
- libavcodec-dev
- libavformat-dev
- libavutil-dev
- libresample-dev
- libkissfft-dev
37 changes: 23 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
# (c) 2013-2014, Dominik Schnitzer <[email protected]>
# 2014, Jan Schlueter <[email protected]>

cmake_minimum_required(VERSION 2.8)
cmake_minimum_required(VERSION 3.17)

project(musly)
include(GNUInstallDirs)
include(CTest)
set(MUSLY_VERSION "0.2")
add_definitions(-DMUSLY_VERSION="${MUSLY_VERSION}")

Expand Down Expand Up @@ -36,8 +38,6 @@ else ()
set(BUILD_SHARED_LIBS ON)
endif ()

option(BUILD_TEST "Build selftest executable" OFF)

option(USE_OPENMP "Compile with OpenMP support (Parallelization)" OFF)
if (USE_OPENMP)
find_package(OpenMP)
Expand All @@ -54,26 +54,35 @@ if (USE_OPENMP)
endif()
endif ()

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

find_package(Eigen3 REQUIRED)
find_package(LibAV 0.8 COMPONENTS avcodec avformat avutil REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(EIGEN3 REQUIRED IMPORTED_TARGET eigen3)
pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET
libavcodec
libavformat
libavutil)
pkg_check_modules(LIBRESAMPLE REQUIRED IMPORTED_TARGET libresample)
pkg_search_module(KISSFFT REQUIRED IMPORTED_TARGET
kissfft-simd
kissfft-double
kissfft-float
kissfft-int32_t
kissfft-int16_t
kissfft-simd-openmp
kissfft-double-openmp
kissfft-float-openmp
kissfft-int32_t-openmp
kissfft-int16_t-openmp)

include_directories(
"${PROJECT_BINARY_DIR}"
"${PROJECT_SOURCE_DIR}/include")

add_subdirectory(libmusly)
add_subdirectory(musly)
add_subdirectory(include)
if (BUILD_TEST)
enable_testing()
if (BUILD_TESTING)
add_subdirectory(test)
endif ()

# Documentation
set(musly_DOC_FILES AUTHORS COPYING README.md)
set(musly_DOC_PATH "share/doc/musly")
install(FILES ${musly_DOC_FILES}
DESTINATION ${musly_DOC_PATH})

install(FILES ${musly_DOC_FILES} DESTINATION ${CMAKE_INSTALL_DOCDIR})
26 changes: 5 additions & 21 deletions libmusly/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# (c) 2013-2014, Dominik Schnitzer <[email protected]>
# 2014-2016, Jan Schlueter <[email protected]>

add_subdirectory(
libresample)

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external")
add_subdirectory(
external)
Expand All @@ -16,26 +13,11 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/external")
PROPERTIES COMPILE_FLAGS "-DLIBMUSLY_EXTERNAL ${LIBMUSLY_EXTERNAL_FLAGS}")
endif()

if(EXISTS "${LIBAV_INCLUDE_DIRS}/libavutil/channel_layout.h")
set_source_files_properties(decoders/libav.cpp
PROPERTIES COMPILE_FLAGS "-DHAVE_AVUTIL_CHANNEL_LAYOUT")
endif()

if(USE_OPENMP AND OPENMP_FOUND)
# disable OpenMP for kiss FFT, it slows things down terribly
set_source_files_properties(kissfft/kiss_fft.c
PROPERTIES COMPILE_FLAGS "-U_OPENMP")
endif()

include_directories(
${LIBMUSLY_INCLUDE}
${EIGEN3_INCLUDE_DIR}
${LIBAV_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR})

add_library(libmusly
kissfft/kiss_fft.c
kissfft/kiss_fftr.c
methods/mandelellis.cpp
methods/timbre.cpp
decoders/libav.cpp
Expand Down Expand Up @@ -65,7 +47,10 @@ set_target_properties(libmusly

target_link_libraries(libmusly
${LIBMUSLY_LIBS}
${LIBAV_LIBRARIES})
PkgConfig::EIGEN3
PkgConfig::FFMPEG
PkgConfig::LIBRESAMPLE
PkgConfig::KISSFFT)
if(WIN32 OR MINGW)
# link against winsock2 for ntohl() and htonl()
target_link_libraries(libmusly ws2_32)
Expand All @@ -74,5 +59,4 @@ endif()
set_target_properties(libmusly
PROPERTIES PREFIX "")

install(TARGETS libmusly
DESTINATION lib)
install(TARGETS libmusly)
Loading