diff options
-rw-r--r-- | CMakeLists.txt | 37 | ||||
-rw-r--r-- | cmake/modules/FindEbur128.cmake | 85 |
2 files changed, 110 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2212920b4d..8184edd69d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -748,18 +748,31 @@ include(CPack) find_package(Chromaprint REQUIRED) target_link_libraries(mixxx-lib PUBLIC Chromaprint::Chromaprint) -# Ebur128Mit -ExternalProject_Add(libebur128 - SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/libebur128" - BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/libebur128" - INSTALL_COMMAND "" - CMAKE_ARGS "-DBUILD_STATIC_LIBS=ON" -) -add_dependencies(mixxx-lib libebur128) -target_include_directories(mixxx-lib PUBLIC - "${CMAKE_CURRENT_SOURCE_DIR}/lib/libebur128/ebur128" -) -target_link_libraries(mixxx-lib PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/lib/libebur128/${CMAKE_STATIC_LIBRARY_PREFIX}ebur128${CMAKE_STATIC_LIBRARY_SUFFIX}") +# Ebur128 +find_package(Ebur128) +if(Ebur128_FOUND) + set(EBUR128_STATIC_DEFAULT OFF) +else() + set(EBUR128_STATIC_DEFAULT ON) +endif() +option(EBUR128_STATIC "Link libebur128 statically" "${EBUR128_STATIC_DEFAULT}") +if(EBUR128_STATIC) + message(STATUS "Linking internal libebur128 statically") + ExternalProject_Add(libebur128 + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/libebur128" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib/libebur128" + INSTALL_COMMAND "" + CMAKE_ARGS "-DBUILD_STATIC_LIBS=ON" + ) + add_dependencies(mixxx-lib libebur128) + target_include_directories(mixxx-lib PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/lib/libebur128/ebur128" + ) + target_link_libraries(mixxx-lib PUBLIC "${CMAKE_CURRENT_BINARY_DIR}/lib/libebur128/${CMAKE_STATIC_LIBRARY_PREFIX}ebur128${CMAKE_STATIC_LIBRARY_SUFFIX}") +else() + message(STATUS "Linking libebur128 dynamically") + target_link_libraries(mixxx-lib PUBLIC Ebur128::Ebur128) +endif() # FidLib add_library(fidlib OBJECT lib/fidlib/fidlib.c) diff --git a/cmake/modules/FindEbur128.cmake b/cmake/modules/FindEbur128.cmake new file mode 100644 index 0000000000..0e1e9914d8 --- /dev/null +++ b/cmake/modules/FindEbur128.cmake @@ -0,0 +1,85 @@ +# This file is part of Mixxx, Digital DJ'ing software. +# Copyright (C) 2001-2019 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: +FindEbur128 +----------- + +Finds the Ebur128 library. + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``Ebur128::Ebur128`` + The Ebur128 library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``Ebur128_FOUND`` + True if the system has the Ebur128 library. +``Ebur128_INCLUDE_DIRS`` + Include directories needed to use Ebur128. +``Ebur128_LIBRARIES`` + Libraries needed to link to Ebur128. +``Ebur128_DEFINITIONS`` + Compile defitions needed to use Ebur128. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Ebur128_INCLUDE_DIR`` + The directory containing ``ebur128.h``. +``Ebur128_LIBRARY`` + The path to the Ebur128 library. + +#]=======================================================================] + +find_package(PkgConfig) +pkg_check_modules(PC_CHROMAPRINT QUIET libebur128) + +find_path(Ebur128_INCLUDE_DIR + NAMES ebur128.h + PATHS ${PC_Ebur128_INCLUDE_DIRS} + PATH_SUFFIXES ebur128 + DOC "Ebur128 include directory") +mark_as_advanced(Ebur128_INCLUDE_DIR) + +find_library(Ebur128_LIBRARY + NAMES ebur128 + PATHS ${PC_Ebur128_LIBRARY_DIRS} + DOC "Ebur128 library" +) +mark_as_advanced(Ebur128_LIBRARY) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + Ebur128 + DEFAULT_MSG + Ebur128_LIBRARY + Ebur128_INCLUDE_DIR +) + +if(Ebur128_FOUND) + set(Ebur128_LIBRARIES "${Ebur128_LIBRARY}") + set(Ebur128_INCLUDE_DIRS "${Ebur128_INCLUDE_DIR}") + set(Ebur128_DEFINITIONS ${PC_Ebur128_CFLAGS_OTHER}) + + if(NOT TARGET Ebur128::Ebur128) + add_library(Ebur128::Ebur128 UNKNOWN IMPORTED) + set_target_properties(Ebur128::Ebur128 + PROPERTIES + IMPORTED_LOCATION "${Ebur128_LIBRARY}" + INTERFACE_COMPILE_OPTIONS "${PC_Ebur128_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Ebur128_INCLUDE_DIR}" + ) + endif() +endif() |