Skip to content

Commit

Permalink
Merge pull request #2932 from xsco/enh/djinterop-external-project
Browse files Browse the repository at this point in the history
Add libdjinterop external project dependency
  • Loading branch information
uklotzde authored Jul 15, 2020
2 parents 25e92a3 + de24940 commit edb49dd
Show file tree
Hide file tree
Showing 4 changed files with 134 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
cache: ccache
# Ubuntu Bionic build prerequisites
# TODO for Ubuntu Focal: Replace "-DFAAD=ON" with "-DFFMPEG=ON"
env: CMAKEFLAGS_EXTRA="-DFAAD=ON -DLOCALECOMPARE=ON -DMAD=ON -DMODPLUG=ON -DWAVPACK=ON -DWARNINGS_FATAL=ON"
env: CMAKEFLAGS_EXTRA="-DENGINEPRIME=ON -DFAAD=ON -DLOCALECOMPARE=ON -DMAD=ON -DMODPLUG=ON -DWAVPACK=ON -DWARNINGS_FATAL=ON"
before_install:
- export CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)"
- export CTEST_PARALLEL_LEVEL="$(nproc)"
Expand Down
46 changes: 46 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1454,6 +1454,52 @@ if(WIN32)
target_link_libraries(mixxx-lib PUBLIC FFTW::FFTW)
endif()

# Denon Engine Prime library export support (using libdjinterop)
option(ENGINEPRIME "Support for library export to Denon Engine Prime" OFF)
if(ENGINEPRIME)
target_compile_definitions(mixxx-lib PUBLIC __ENGINEPRIME__)

# Look for an existing installation of libdjinterop and use that if available.
# Otherwise, download and build from GitHub.
find_package(DjInterop)
if(DjInterop_FOUND)
# An existing installation of djinterop is available.
message(STATUS "Linking dynamically to existing installation of libdjinterop")
target_include_directories(mixxx-lib PUBLIC ${DjInterop_INCLUDE_DIRS})
target_link_libraries(mixxx-lib PUBLIC DjInterop::DjInterop)
else()
# Fetch djinterop sources from GitHub and build them statically.
message(STATUS "Linking statically to libdjinterop fetched from GitHub")

set(DJINTEROP_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/libdjinterop-install")
ExternalProject_Add(libdjinterop
GIT_REPOSITORY https://github.com/xsco/libdjinterop.git
GIT_TAG tags/0.11.0
GIT_SHALLOW TRUE
INSTALL_DIR ${DJINTEROP_INSTALL_DIR}
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
EXCLUDE_FROM_ALL TRUE
)

# Assemble a library based on the external project.
add_library(mixxx-libdjinterop STATIC IMPORTED)
add_dependencies(mixxx-libdjinterop libdjinterop)
set(DJINTEROP_INCLUDE_DIR "${DJINTEROP_INSTALL_DIR}/include")
set(DJINTEROP_LIBRARY "${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}djinterop${CMAKE_STATIC_LIBRARY_SUFFIX}")
set(DJINTEROP_LIBRARY_DIR "${DJINTEROP_INSTALL_DIR}/${DJINTEROP_LIBRARY}")
set_target_properties(mixxx-libdjinterop PROPERTIES IMPORTED_LOCATION "${DJINTEROP_LIBRARY_DIR}")
target_include_directories(mixxx-lib PUBLIC ${DJINTEROP_INCLUDE_DIR})
target_link_libraries(mixxx-lib PUBLIC mixxx-libdjinterop)

# Since we have built libdjinterop from sources as a static library, its
# transitive dependencies are not automatically recognised. libdjinterop
# depends on zlib and sqlite3. Mixxx already has a dependency on sqlite3,
# but not zlib, so we explicitly add that here.
find_package(ZLIB 1.2.8 REQUIRED)
target_link_libraries(mixxx-lib PUBLIC ${ZLIB_LIBRARIES})
endif()
endif()

# Ebur128
find_package(Ebur128)
cmake_dependent_option(EBUR128_STATIC "Link libebur128 statically" OFF "Ebur128_FOUND" ON)
Expand Down
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ for:
-DBATTERY=ON
-DBROADCAST=ON
-DBULK=ON
-DENGINEPRIME=ON
-DFFMPEG=ON
-DHID=ON
-DLILV=ON
Expand Down
86 changes: 86 additions & 0 deletions cmake/modules/FindDjInterop.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# 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:
FindDjInterop
---------------
Finds the DjInterop library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``DjInterop::DjInterop``
The DjInterop library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``DjInterop_FOUND``
True if the system has the DjInterop library.
``DjInterop_INCLUDE_DIRS``
Include directories needed to use DjInterop.
``DjInterop_LIBRARIES``
Libraries needed to link to DjInterop.
``DjInterop_DEFINITIONS``
Compile definitions needed to use DjInterop.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``DjInterop_INCLUDE_DIR``
The directory containing ``djinterop/djinterop.hpp``.
``DjInterop_LIBRARY``
The path to the DjInterop library.
#]=======================================================================]

find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_DjInterop QUIET libdjinterop)
endif()

find_path(DjInterop_INCLUDE_DIR
NAMES djinterop/djinterop.hpp
PATHS ${PC_DjInterop_INCLUDE_DIRS}
DOC "DjInterop include directory")
mark_as_advanced(DjInterop_INCLUDE_DIR)

find_library(DjInterop_LIBRARY
NAMES djinterop
PATHS ${PC_DjInterop_LIBRARY_DIRS}
DOC "DjInterop library"
)
mark_as_advanced(DjInterop_LIBRARY)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
DjInterop
DEFAULT_MSG
DjInterop_LIBRARY
DjInterop_INCLUDE_DIR
)

if(DjInterop_FOUND)
set(DjInterop_LIBRARIES "${DjInterop_LIBRARY}")
set(DjInterop_INCLUDE_DIRS "${DjInterop_INCLUDE_DIR}")
set(DjInterop_DEFINITIONS ${PC_DjInterop_CFLAGS_OTHER})

if(NOT TARGET DjInterop::DjInterop)
add_library(DjInterop::DjInterop UNKNOWN IMPORTED)
set_target_properties(DjInterop::DjInterop
PROPERTIES
IMPORTED_LOCATION "${DjInterop_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_DjInterop_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${DjInterop_INCLUDE_DIR}"
)
endif()
endif()

0 comments on commit edb49dd

Please sign in to comment.