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

Add spleeter (CLA demo) #17

Closed
wants to merge 3 commits into from
Closed
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
42 changes: 42 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,48 @@ if(ENGINEPRIME)
endif()
endif()

# Spleeter
option(SPLEETER "Spleeter stem separation" OFF)
if(SPLEETER)
find_package(Spleeter)
if(Spleeter_Found)
message(STATUS "Linking dynamically to existing installation of spleeter")
target_link_libraries(mixxx-lib PUBLIC spleeter::Split)
else()
# Fetch spleeter sources from GitHub and build them statically.
message(STATUS "Linking statically to spleeter fetched from GitHub")
set(Spleeter_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/spleeter-install")
ExternalProject_Add(spleeter
GIT_REPOSITORY git@github.com:gvne/spleeterpp.git
GIT_TAG tags/v0.2.1
GIT_SHALLOW TRUE
INSTALL_DIR "${Spleeter_INSTALL_DIR}"
CMAKE_ARGS
-Dspleeter_enable_tests=OFF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
EXCLUDE_FROM_ALL TRUE
)

# This is a bit of a hack to make sure that the include directory
# actually exists when configuring the build. ExternalProject_Add() will
# create it at compile time, but CMake already checks that all
# directories passed to target_include_directories() exist during
# configuration and will throw an error if not.
file(MAKE_DIRECTORY "${Spleeter_INSTALL_DIR}/include")

# Assemble a library based on the external project.
add_library(mixxx-spleeter STATIC IMPORTED)
add_dependencies(mixxx-spleeter spleeter)
set_target_properties(mixxx-spleeter
PROPERTIES
IMPORTED_LOCATION "${Spleeter_INSTALL_DIR}/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}spleeter${CMAKE_STATIC_LIBRARY_SUFFIX}"
INTERFACE_INCLUDE_DIRECTORIES "${Spleeter_INSTALL_DIR}/include"
)
target_link_libraries(mixxx-lib PUBLIC mixxx-spleeter)
endif()
endif()

# Ebur128
find_package(Ebur128)
cmake_dependent_option(EBUR128_STATIC "Link libebur128 statically" OFF "Ebur128_FOUND" ON)
Expand Down
63 changes: 63 additions & 0 deletions cmake/modules/FindSpleeter.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# This file is part of Mixxx, Digital DJ'ing software.
# Copyright (C) 2001-2020 Mixxx Development Team
# Distributed under the GNU General Public Licence (GPL) version 2 or any later
# later version. See the LICENSE file for details.

#[=======================================================================[.rst:
FindSpleeterpp
--------------

Finds the Spleeterpp library.

Imported Targets
^^^^^^^^^^^^^^^^

This module provides the following imported targets, if found:

``spleeter::Split`
The Spleeterpp library

#]=======================================================================]

find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_Spleeter QUIET spleeter)
endif()

find_path(Spleeter_INCLUDE_DIR
NAMES spleeter.h
PATHS ${PC_Spleeter_INCLUDE_DIRS}
PATH_SUFFIXES spleeter
DOC "Spleeter include directory")
mark_as_advanced(Spleeter_INCLUDE_DIR)

find_library(Spleeter_LIBRARY
NAMES spleeter
PATHS ${Spleeter_LIBRARY_DIRS}
DOC "Spleeter library"
)
mark_as_advanced(Spleeterpp_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Spleeter
DEFAULT_MSG
Spleeter_LIBRARY
Spleeter_INCLUDE_DIR
)

if(Spleeter_FOUND)
set(Spleeter_LIBRARIES "${Spleeter_LIBRARY}")
set(Spleeter_INCLUDE_DIRS "${Spleeter_INCLUDE_DIR}")
set(Spleeter_DEFINITIONS ${PC_Spleeter_CFLAGS_OTHER})

if(NOT TARGET spleeter::Split)
add_library(spleeter::Split UNKNOWN IMPORTED)
set_target_properties(spleeter::Split
PROPERTIES
IMPORTED_LOCATION "${Spleeter_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${Spleeter_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${Spleeter_INCLUDE_DIR}"
)
endif()
endif()
Loading