Browse Source

CMake: replace Conan with find_package and add find modules

Also, necessarily coupled with this:
* add CMakeLists.txt for vendored libnyquist
* fix SoundTouch header include paths
* move nyq_reformat_aud_do_response function
* handle portSMF headers installed to portsmf or portSMF

Signed-off-by: Be <be@mixxx.org>
pull/228/head
Be 6 months ago
parent
commit
b1549dd13e
No known key found for this signature in database GPG Key ID: F4D83691462F656E
  1. 183
      CMakeLists.txt
  2. 183
      cmake-modules/FindFFMPEG.cmake
  3. 88
      cmake-modules/FindFLAC++.cmake
  4. 85
      cmake-modules/FindFLAC.cmake
  5. 124
      cmake-modules/FindGLIB.cmake
  6. 150
      cmake-modules/FindGTK.cmake
  7. 68
      cmake-modules/FindLV2.cmake
  8. 86
      cmake-modules/FindMAD.cmake
  9. 77
      cmake-modules/FindOgg.cmake
  10. 57
      cmake-modules/FindPortAudio.cmake
  11. 73
      cmake-modules/FindPortMidi.cmake
  12. 83
      cmake-modules/FindPortSMF.cmake
  13. 62
      cmake-modules/FindPortTime.cmake
  14. 86
      cmake-modules/FindSQLite3.cmake
  15. 63
      cmake-modules/FindSndFile.cmake
  16. 85
      cmake-modules/FindSoundTouch.cmake
  17. 81
      cmake-modules/FindSoxr.cmake
  18. 81
      cmake-modules/FindVampHostSDK.cmake
  19. 102
      cmake-modules/FindVorbis.cmake
  20. 76
      cmake-modules/Findid3tag.cmake
  21. 81
      cmake-modules/Findlibtwolame.cmake
  22. 97
      cmake-modules/Findlilv.cmake
  23. 74
      cmake-modules/Findmp3lame.cmake
  24. 77
      cmake-modules/Findsbsms.cmake
  25. 85
      cmake-modules/Findsuil.cmake
  26. 27
      lib-src/header-substitutes/allegro.h
  27. 292
      lib-src/libnyquist/CMakeLists.txt
  28. 4
      libraries/lib-string-utils/CMakeLists.txt
  29. 2
      libraries/lib-strings/CMakeLists.txt
  30. 76
      src/CMakeLists.txt
  31. 14
      src/commands/ScriptCommandRelay.cpp
  32. 1
      src/commands/ScriptCommandRelay.h
  33. 2
      src/effects/ChangePitch.cpp
  34. 2
      src/effects/ChangeTempo.cpp
  35. 2
      src/effects/SoundTouchEffect.cpp
  36. 12
      src/effects/nyquist/Nyquist.cpp

183
CMakeLists.txt

@ -91,6 +91,7 @@ set( CMAKE_MODULE_PATH
${AUDACITY_MODULE_PATH}
${CMAKE_BINARY_DIR}
${CMAKE_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake-modules"
)
set( CMAKE_PREFIX_PATH
@ -128,11 +129,6 @@ endif()
include( CMakeDependentOption )
# Test if conan is installed
find_program(CONAN_CMD_TEST conan NO_CACHE)
cmake_dependent_option(USE_CONAN "Build without conan" ON "NOT CONAN_CMD_TEST STREQUAL CONAN_CMD_TEST-NOTFOUND" OFF)
message("Using conan: ${USE_CONAN}")
# Our very own project
project( Tenacity )
@ -141,21 +137,6 @@ include( AudacityFunctions )
set_from_env(AUDACITY_ARCH_LABEL) # e.g. x86_64
# Allow user to globally set the library preference
cmd_option( ${_OPT}lib_preference
"Library preference [system (if available), local]"
"local"
STRINGS "system" "local"
)
# Special mode, that will force dependencies to the packages provided by system unless they were set to local explicitly.
cmd_option( ${_OPT}obey_system_dependencies
"Use system packages to satisfy dependencies"
Off
)
include( AudacityDependencies )
# Pull all the modules we'll need
include( CheckCXXCompilerFlag )
include( CheckIncludeFile )
@ -511,11 +492,165 @@ endif()
# Do this before consistency checks for added third-party libraries
include( "src/Experimental.cmake" )
# Add our children
add_subdirectory( "cmake-proxies" )
find_package(Threads REQUIRED)
find_package(ZLIB REQUIRED)
find_package(EXPAT REQUIRED)
find_package(mp3lame REQUIRED)
find_package(SndFile REQUIRED)
find_package(Soxr REQUIRED)
find_package(SQLite3 REQUIRED)
find_package(PortAudio REQUIRED)
find_package(PortMidi)
find_package(PortSMF)
cmake_dependent_option(MIDI "MIDI support requires PortMidi and PortSMF." ON "PortMidi_FOUND;PortSMF_FOUND" OFF)
if(MIDI)
set(USE_MIDI ON)
message(STATUS "MIDI support enabled.")
else()
message(STATUS "MIDI support disabled. Requires both PortMidi and PortSMF.")
endif()
find_package(id3tag)
cmake_dependent_option(ID3TAG "ID3 Tag support for MP3s." ON "id3tag_FOUND" OFF)
if(ID3TAG)
set(USE_LIBID3TAG ON)
message(STATUS "ID3 tag support for MP3s enabled.")
else()
message(STATUS "ID3 tag support for MP3s disabled. Requires libid3tag.")
endif()
find_package(MAD)
cmake_dependent_option(MP3_DECODING "MP3 decoding support with libmad" ON "MAD_FOUND" OFF)
if(MP3_DECODING)
set(USE_LIBMAD ON)
message(STATUS "MP3 decoding support enabled.")
else()
message(STATUS "MP3 decoding support disabled. Requires libmad.")
endif()
find_package(libtwolame)
cmake_dependent_option(MP2 "MP2 support with Twolame" ON "libtwolame_FOUND" OFF)
if(MP2)
set(USE_LIBTWOLAME ON)
message(STATUS "MP2 encoding support enabled.")
else()
message(STATUS "MP2 encoding support disabled. Requires Twolame library.")
endif()
find_package(Ogg)
cmake_dependent_option(OGG "OGG container format support" ON "Ogg_FOUND" OFF)
if(OGG)
set(USE_LIBOGG ON)
message(STATUS "OGG container format support enabled.")
else()
message(STATUS "OGG container format support disabled. Requires libogg.")
endif()
find_package(Vorbis)
cmake_dependent_option(VORBIS "Vorbis codec support" ON "Vorbis_FOUND" OFF)
if(VORBIS)
set(USE_LIBVORBIS ON)
message(STATUS "Vorbis codec support enabled.")
else()
message(STATUS "Voribs codec support disabled. Requires libvorbis.")
endif()
find_package(FLAC++)
cmake_dependent_option(FLAC "FLAC codec support" ON "FLAC++_FOUND" OFF)
if(FLAC)
set(USE_LIBFLAC ON)
message(STATUS "FLAC codec support enabled.")
else()
message(STATUS "FLAC codec support disabled. Requires libflac and libflac++ C++ bindings.")
endif()
# FIXME: requires vendored fork of PortMixer which requires vendored fork of PortAudio
# https://github.com/audacity/audacity/issues/840#issuecomment-837795388
#find_package(PortMixer)
#cmake_dependent_option(PORTMIXER "PortMixer support" ON "PortMixer_FOUND" OFF)
#if(PORTMIXER)
#set(USE_PORTMIXER ON)
#message(STATUS "PortMixer support enabled.")
#else()
#message(STATUS "PortMixer support disabled.")
#endif()
find_package(sbsms)
cmake_dependent_option(SBSMS "SBSMS timestretching" ON "sbsms_FOUND" OFF)
if(SBSMS)
set(USE_SBSMS ON)
message(STATUS "SBSMS timestretching support enabled.")
else()
message(STATUS "SBSMS timestretching support disabled. Requires libsbsms.")
endif()
find_package(SoundTouch)
cmake_dependent_option(SOUNDTOUCH "SoundTouch timestretching" ON "SoundTouch_FOUND" OFF)
if(SOUNDTOUCH)
set(USE_SOUNDTOUCH ON)
message(STATUS "SoundTouch timestretching support enabled.")
else()
message(STATUS "SoundTouch timestretching support disabled. Requires SoundTouch library.")
endif()
find_package(FFMPEG)
cmake_dependent_option(FFMPEG "FFMPEG codecs support." ON "FFMPEG_FOUND" OFF)
if(FFMPEG)
set(USE_FFMPEG ON)
message(STATUS "FFMPEG codecs support enabled.")
else()
message(STATUS "FFMPEG codecs support disabled. Requires FFMPEG libraries.")
endif()
find_package(VampHostSDK)
cmake_dependent_option(VAMP "VAMP plugin hosting." ON "VampHostSDK_FOUND" OFF)
if(VAMP)
set(USE_VAMP ON)
message(STATUS "VAMP plugin hosting enabled.")
else()
message(STATUS "VAMP plugin hosting disabled. Requires VAMP host SDK.")
endif()
find_package(LV2)
find_package(lilv)
find_package(suil)
cmake_dependent_option(LV2 "LV2 plugin host support" ON "LV2_FOUND;lilv_FOUND;suil_FOUND" OFF)
if(LV2)
message(STATUS "LV2 plugin hosting enabled.")
set(USE_LV2 ON)
else()
message(STATUS "LV2 plugin hosting disabled. Requires LV2, lilv, and suil libraries.")
endif()
option(VST2 "VST2 plugin host support" ON)
if(VST2)
message(STATUS "VST2 plugin host support enabled.")
else()
message(STATUS "VST2 plugin host support disabled.")
endif()
if(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin|Windows")
find_package(GLIB REQUIRED)
find_package(GTK 3.0 REQUIRED)
endif()
set(wxWidgets_CONFIG_OPTIONS --version=3.1)
find_package(wxWidgets 3.1 REQUIRED COMPONENTS adv base core html qa xml net)
include(${wxWidgets_USE_FILE})
# The FindwxWidgets.cmake module does not create an IMPORT target, so hack one together.
# This makes it easy to add the compile definitions to the lib-strings and lib-strings-utils targets.
if(NOT TARGET wxWidgets::wxWidgets)
add_library(wxWidgets::wxWidgets INTERFACE IMPORTED)
target_link_libraries(wxWidgets::wxWidgets INTERFACE ${wxWidgets_LIBRARIES})
target_compile_definitions(wxWidgets::wxWidgets INTERFACE ${wxWidgets_DEFINITIONS} ${wxWidgets_DEFINITIONS_DEBUG})
if(WIN32)
target_compile_definitions(wxWidgets::wxWidgets INTERFACE WXUSINGDLL)
endif()
endif()
# Conan uses find_package and does not set GLOBAL flag
resolve_conan_dependencies()
add_subdirectory(lib-src/libnyquist)
set(USE_NYQUIST ON)
add_subdirectory( "help" )
add_subdirectory( "images" )

183
cmake-modules/FindFFMPEG.cmake

@ -0,0 +1,183 @@
#.rst:
# FindFFMPEG
# ----------
#
# Try to find the required ffmpeg components (default: libavformat, libavutil, libavcodec)
#
# Next variables can be used to hint FFMPEG libs search:
#
# ::
#
# PC_<component>_LIBRARY_DIRS
# PC_FFMPEG_LIBRARY_DIRS
# PC_<component>_INCLUDE_DIRS
# PC_FFMPEG_INCLUDE_DIRS
#
# Once done this will define
#
# ::
#
# FFMPEG_FOUND - System has the all required components.
# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers.
# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components.
# FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components.
#
# For each of the components it will additionally set.
#
# ::
#
# libavcodec
# libavdevice
# libavformat
# libavfilter
# libavutil
# libpostproc
# libswscale
# libswresample
#
# the following variables will be defined
#
# ::
#
# <component>_FOUND - System has <component>
# <component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers
# <component>_LIBRARIES - Link these to use <component>
# <component>_DEFINITIONS - Compiler switches required for using <component>
# <component>_VERSION - The components version
#
# the following import targets is created
#
# ::
#
# FFMPEG::FFMPEG - for all components
# FFMPEG::<component> - where <component> in lower case (FFMPEG::avcodec) for each components
#
# Copyright (c) 2006, Matthias Kretz, <kretz@kde.org>
# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz>
# Copyright (c) 2017, Alexander Drozdov, <adrozdoff@gmail.com>
# Copyright (c) 2019, Jan Holthuis, <holthuis.jan@googlemail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(FindPackageHandleStandardArgs)
# The default components were taken from a survey over other FindFFMPEG.cmake files
if (NOT FFMPEG_FIND_COMPONENTS)
set(FFMPEG_FIND_COMPONENTS libavcodec libavformat libavutil)
endif ()
#
### Macro: find_component
#
# Checks for the given component by invoking pkgconfig and then looking up the libraries and
# include directories.
#
macro(find_component _component _pkgconfig _library _header)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
find_package(PkgConfig QUIET)
if (PkgConfig_FOUND)
pkg_check_modules(PC_FFMPEG_${_component} QUIET ${_pkgconfig})
endif ()
find_path(FFMPEG_${_component}_INCLUDE_DIRS ${_header}
HINTS
${PC_FFMPEG_${_component}_INCLUDEDIR}
${PC_FFMPEG_${_component}_INCLUDE_DIRS}
${PC_FFMPEG_INCLUDE_DIRS}
PATH_SUFFIXES
ffmpeg
)
find_library(FFMPEG_${_component}_LIBRARIES NAMES ${PC_FFMPEG_${_component}_LIBRARIES} ${_library}
HINTS
${PC_FFMPEG_${_component}_LIBDIR}
${PC_FFMPEG_${_component}_LIBRARY_DIRS}
${PC_FFMPEG_LIBRARY_DIRS}
)
message(STATUS ${FFMPEG_${_component}_LIBRARIES})
message(STATUS ${PC_FFMPEG_${_component}_LIBRARIES})
set(FFMPEG_${_component}_DEFINITIONS ${PC_FFMPEG_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.")
set(FFMPEG_${_component}_VERSION ${PC_FFMPEG_${_component}_VERSION} CACHE STRING "The ${_component} version number.")
if (FFMPEG_${_component}_LIBRARIES AND FFMPEG_${_component}_INCLUDE_DIRS)
message(STATUS " - ${_component} ${FFMPEG_${_component}_VERSION} found.")
set(FFMPEG_${_component}_FOUND TRUE)
else ()
message(STATUS " - ${_component} not found.")
endif ()
mark_as_advanced(
FFMPEG_${_component}_INCLUDE_DIRS
FFMPEG_${_component}_LIBRARIES
FFMPEG_${_component}_DEFINITIONS
FFMPEG_${_component}_VERSION)
endmacro()
message(STATUS "Searching for FFMPEG components")
# Check for all possible component.
find_component(libavcodec libavcodec avcodec libavcodec/avcodec.h)
find_component(libavformat libavformat avformat libavformat/avformat.h)
find_component(libavdevice libavdevice avdevice libavdevice/avdevice.h)
find_component(libavutil libavutil avutil libavutil/avutil.h)
find_component(libavfilter libavfilter avfilter libavfilter/avfilter.h)
find_component(libswscale libswscale swscale libswscale/swscale.h)
find_component(libpostproc libpostproc postproc libpostproc/postprocess.h)
find_component(libswresample libswresample swresample libswresample/swresample.h)
set(FFMPEG_LIBRARIES "")
set(FFMPEG_DEFINITIONS "")
# Check if the required components were found and add their stuff to the FFMPEG_* vars.
foreach (_component ${FFMPEG_FIND_COMPONENTS})
if (FFMPEG_${_component}_FOUND)
#message(STATUS "Required component ${_component} present.")
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${FFMPEG_${_component}_LIBRARIES})
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${FFMPEG_${_component}_DEFINITIONS})
list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_${_component}_INCLUDE_DIRS})
string(TOLOWER ${_component} _lowerComponent)
if (NOT TARGET FFMPEG::${_lowerComponent})
add_library(FFMPEG::${_lowerComponent} INTERFACE IMPORTED)
set_target_properties(FFMPEG::${_lowerComponent} PROPERTIES
INTERFACE_COMPILE_OPTIONS "${${_component}_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${${_component}_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${${_component}_LIBRARIES}")
endif()
endif()
endforeach ()
# Build the include path with duplicates removed.
if (FFMPEG_INCLUDE_DIRS)
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
endif ()
# cache the vars.
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFMPEG include directories." FORCE)
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFMPEG libraries." FORCE)
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFMPEG cflags." FORCE)
mark_as_advanced(FFMPEG_INCLUDE_DIRS
FFMPEG_LIBRARIES
FFMPEG_DEFINITIONS)
if (NOT TARGET FFMPEG::FFMPEG)
add_library(FFMPEG::FFMPEG INTERFACE IMPORTED)
set_target_properties(FFMPEG::FFMPEG PROPERTIES
INTERFACE_COMPILE_OPTIONS "${FFMPEG_DEFINITIONS}"
INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FFMPEG_LIBRARIES}")
endif()
# Compile the list of required vars
set(_FFMPEG_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS)
foreach (_component ${FFMPEG_FIND_COMPONENTS})
list(APPEND _FFMPEG_REQUIRED_VARS FFMPEG_${_component}_LIBRARIES FFMPEG_${_component}_INCLUDE_DIRS)
endforeach ()
# Give a nice error message if some of the required vars are missing.
find_package_handle_standard_args(FFMPEG DEFAULT_MSG ${_FFMPEG_REQUIRED_VARS})

88
cmake-modules/FindFLAC++.cmake

@ -0,0 +1,88 @@
# 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.txt file for details.
#[=======================================================================[.rst:
FindFLAC++
--------
Finds the FLAC++ library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``FLAC++::FLAC++``
The FLAC++ library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``FLAC++_FOUND``
True if the system has the FLAC++ library.
``FLAC++_INCLUDE_DIRS``
Include directories needed to use FLAC++.
``FLAC++_LIBRARIES``
Libraries needed to link to FLAC++.
``FLAC++_DEFINITIONS``
Compile definitions needed to use FLAC++.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``FLAC++_INCLUDE_DIR``
The directory containing ``FLAC++/all.h``.
``FLAC++_LIBRARY``
The path to the FLAC++ library.
#]=======================================================================]
find_package(FLAC REQUIRED)
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_FLAC++ QUIET flac++)
endif()
find_path(FLAC++_INCLUDE_DIR
NAMES FLAC++/all.h
PATHS ${PC_FLAC++_INCLUDE_DIRS}
DOC "FLAC++ include directory")
mark_as_advanced(FLAC++_INCLUDE_DIR)
find_library(FLAC++_LIBRARY
NAMES FLAC++
PATHS ${PC_FLAC++_LIBRARY_DIRS}
DOC "FLAC++ library"
)
mark_as_advanced(FLAC++_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
FLAC++
DEFAULT_MSG
FLAC++_LIBRARY
FLAC++_INCLUDE_DIR
)
if(FLAC++_FOUND)
set(FLAC++_LIBRARIES "${FLAC++_LIBRARY}")
set(FLAC++_INCLUDE_DIRS "${FLAC++_INCLUDE_DIR}")
set(FLAC++_DEFINITIONS ${PC_FLAC++_CFLAGS_OTHER})
if(NOT TARGET FLAC++::FLAC++)
add_library(FLAC++::FLAC++ UNKNOWN IMPORTED)
set_target_properties(FLAC++::FLAC++
PROPERTIES
IMPORTED_LOCATION "${FLAC++_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_FLAC++_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${FLAC++_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES FLAC::FLAC
)
endif()
endif()

85
cmake-modules/FindFLAC.cmake

@ -0,0 +1,85 @@
# 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:
FindFLAC
--------
Finds the FLAC library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``FLAC::FLAC``
The FLAC library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``FLAC_FOUND``
True if the system has the FLAC library.
``FLAC_INCLUDE_DIRS``
Include directories needed to use FLAC.
``FLAC_LIBRARIES``
Libraries needed to link to FLAC.
``FLAC_DEFINITIONS``
Compile definitions needed to use FLAC.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``FLAC_INCLUDE_DIR``
The directory containing ``FLAC/all.h``.
``FLAC_LIBRARY``
The path to the FLAC library.
#]=======================================================================]
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_FLAC QUIET flac)
endif()
find_path(FLAC_INCLUDE_DIR
NAMES FLAC/all.h
PATHS ${PC_FLAC_INCLUDE_DIRS}
DOC "FLAC include directory")
mark_as_advanced(FLAC_INCLUDE_DIR)
find_library(FLAC_LIBRARY
NAMES FLAC
PATHS ${PC_FLAC_LIBRARY_DIRS}
DOC "FLAC library"
)
mark_as_advanced(FLAC_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
FLAC
DEFAULT_MSG
FLAC_LIBRARY
FLAC_INCLUDE_DIR
)
if(FLAC_FOUND)
set(FLAC_LIBRARIES "${FLAC_LIBRARY}")
set(FLAC_INCLUDE_DIRS "${FLAC_INCLUDE_DIR}")
set(FLAC_DEFINITIONS ${PC_FLAC_CFLAGS_OTHER})
if(NOT TARGET FLAC::FLAC)
add_library(FLAC::FLAC UNKNOWN IMPORTED)
set_target_properties(FLAC::FLAC
PROPERTIES
IMPORTED_LOCATION "${FLAC_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_FLAC_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}"
)
endif()
endif()

124
cmake-modules/FindGLIB.cmake

@ -0,0 +1,124 @@
# - Try to find Glib and its components (gio, gobject etc)
# Once done, this will define
#
# GLIB_FOUND - system has Glib
# GLIB_INCLUDE_DIRS - the Glib include directories
# GLIB_LIBRARIES - link these to use Glib
#
# Optionally, the COMPONENTS keyword can be passed to find_package()
# and Glib components can be looked for. Currently, the following
# components can be used, and they define the following variables if
# found:
#
# gio: GLIB_GIO_LIBRARIES
# gobject: GLIB_GOBJECT_LIBRARIES
# gmodule: GLIB_GMODULE_LIBRARIES
# gthread: GLIB_GTHREAD_LIBRARIES
#
# Note that the respective _INCLUDE_DIR variables are not set, since
# all headers are in the same directory as GLIB_INCLUDE_DIRS.
#
# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_GLIB QUIET glib-2.0)
endif()
find_library(GLIB_LIBRARIES
NAMES glib-2.0
HINTS ${PC_GLIB_LIBDIR}
${PC_GLIB_LIBRARY_DIRS}
)
# Files in glib's main include path may include glibconfig.h, which,
# for some odd reason, is normally in $LIBDIR/glib-2.0/include.
get_filename_component(_GLIB_LIBRARY_DIR ${GLIB_LIBRARIES} PATH)
find_path(GLIBCONFIG_INCLUDE_DIR
NAMES glibconfig.h
HINTS ${PC_LIBDIR} ${PC_LIBRARY_DIRS} ${_GLIB_LIBRARY_DIR}
${PC_GLIB_INCLUDEDIR} ${PC_GLIB_INCLUDE_DIRS}
PATH_SUFFIXES glib-2.0/include
)
find_path(GLIB_INCLUDE_DIR
NAMES glib.h
HINTS ${PC_GLIB_INCLUDEDIR}
${PC_GLIB_INCLUDE_DIRS}
PATH_SUFFIXES glib-2.0
)
set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIBCONFIG_INCLUDE_DIR})
# Version detection
if (EXISTS "${GLIBCONFIG_INCLUDE_DIR}/glibconfig.h")
file(READ "${GLIBCONFIG_INCLUDE_DIR}/glibconfig.h" GLIBCONFIG_H_CONTENTS)
string(REGEX MATCH "#define GLIB_MAJOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
set(GLIB_VERSION_MAJOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define GLIB_MINOR_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
set(GLIB_VERSION_MINOR "${CMAKE_MATCH_1}")
string(REGEX MATCH "#define GLIB_MICRO_VERSION ([0-9]+)" _dummy "${GLIBCONFIG_H_CONTENTS}")
set(GLIB_VERSION_MICRO "${CMAKE_MATCH_1}")
set(GLIB_VERSION "${GLIB_VERSION_MAJOR}.${GLIB_VERSION_MINOR}.${GLIB_VERSION_MICRO}")
endif ()
# Additional Glib components. We only look for libraries, as not all of them
# have corresponding headers and all headers are installed alongside the main
# glib ones.
foreach (_component ${GLIB_FIND_COMPONENTS})
if (${_component} STREQUAL "gio")
find_library(GLIB_GIO_LIBRARIES NAMES gio-2.0 HINTS ${_GLIB_LIBRARY_DIR})
set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GIO_LIBRARIES)
elseif (${_component} STREQUAL "gobject")
find_library(GLIB_GOBJECT_LIBRARIES NAMES gobject-2.0 HINTS ${_GLIB_LIBRARY_DIR})
set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GOBJECT_LIBRARIES)
elseif (${_component} STREQUAL "gmodule")
find_library(GLIB_GMODULE_LIBRARIES NAMES gmodule-2.0 HINTS ${_GLIB_LIBRARY_DIR})
set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GMODULE_LIBRARIES)
elseif (${_component} STREQUAL "gthread")
find_library(GLIB_GTHREAD_LIBRARIES NAMES gthread-2.0 HINTS ${_GLIB_LIBRARY_DIR})
set(ADDITIONAL_REQUIRED_VARS ${ADDITIONAL_REQUIRED_VARS} GLIB_GTHREAD_LIBRARIES)
elseif (${_component} STREQUAL "gio-unix")
# gio-unix is compiled as part of the gio library, but the include paths
# are separate from the shared glib ones. Since this is currently only used
# by WebKitGTK we don't go to extraordinary measures beyond pkg-config.
pkg_check_modules(GIO_UNIX QUIET gio-unix-2.0)
endif ()
endforeach ()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLIB REQUIRED_VARS GLIB_INCLUDE_DIRS GLIB_LIBRARIES ${ADDITIONAL_REQUIRED_VARS}
VERSION_VAR GLIB_VERSION)
mark_as_advanced(
GLIBCONFIG_INCLUDE_DIR
GLIB_GIO_LIBRARIES
GLIB_GIO_UNIX_LIBRARIES
GLIB_GMODULE_LIBRARIES
GLIB_GOBJECT_LIBRARIES
GLIB_GTHREAD_LIBRARIES
GLIB_INCLUDE_DIR
GLIB_INCLUDE_DIRS
GLIB_LIBRARIES
)

150
cmake-modules/FindGTK.cmake

@ -0,0 +1,150 @@
# - Try to find GTK+ 3.x or 4.x
#
# Copyright (C) 2012 Raphael Kubo da Costa <rakuco@webkit.org>
# Copyright (C) 2013, 2015, 2020 Igalia S.L.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND ITS CONTRIBUTORS ``AS
# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#[=======================================================================[.rst:
FindGTK
-------
Find GTK headers and libraries.
Optional Components
^^^^^^^^^^^^^^^^^^^
The ``COMPONENTS`` (or ``OPTIONAL_COMPONENTS``) keyword can be passed to
``find_package()``, the following GTK components can be searched for:
- ``unix-print``
Imported Targets
^^^^^^^^^^^^^^^^
``GTK::GTK``
The GTK library, if found.
``GTK::UnixPrint``
The GTK unix-print library, if found.
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables in your project:
``GTK_FOUND``
true if (the requested version of) GTK is available.
``GTK_UNIX_PRINT_FOUND``
true if the ``unix-print`` component is available.
``GTK_4``
whether GTK 4 was detected
``GTK_3``
whether GTK 3 was detected
``GTK_VERSION``
the version of GTK.
``GTK_SUPPORTS_BROADWAY``
true if the Broadway target is built into GTK.
``GTK_SUPPORTS_QUARTZ``
true if the Quartz target is built into GTK.
``GTK_SUPPORTS_WAYLAND``
true if the Wayland target is built into GTK.
``GTK_SUPPORTS_WIN32``
true if the Windows target is built into GTK.
``GTK_SUPPORTS_X11``
true if the X11 target is built into GTK.
#]=======================================================================]
if (NOT DEFINED GTK_FIND_VERSION)
message(FATAL_ERROR "No GTK version specified")
endif ()
if (GTK_FIND_VERSION VERSION_LESS 3.90)
set(GTK_PC_MODULE "gtk+-3.0")
set(GTK_PC_UNIX_PRINT_MODULE "gtk+-unix-print-3.0")
set(GTK_4 FALSE)
set(GTK_3 TRUE)
else ()
set(GTK_PC_MODULE "gtk4")
set(GTK_PC_UNIX_PRINT_MODULE "gtk4-unix-print")
set(GTK_4 TRUE)
set(GTK_3 FALSE)
endif ()
find_package(PkgConfig QUIET)
pkg_check_modules(GTK IMPORTED_TARGET ${GTK_PC_MODULE})
set(GTK_VERSION_OK TRUE)
if (GTK_VERSION)
if (GTK_FIND_VERSION_EXACT)
if (NOT("${GTK_FIND_VERSION}" VERSION_EQUAL "${GTK_VERSION}"))
set(GTK_VERSION_OK FALSE)
endif ()
else ()
if ("${GTK_VERSION}" VERSION_LESS "${GTK_FIND_VERSION}")
set(GTK_VERSION_OK FALSE)
endif ()
endif ()
endif ()
# Set all the GTK_SUPPORTS_<target> variables to FALSE initially.
foreach (gtk_target broadway quartz wayland win32 x11)
string(TOUPPER "GTK_SUPPORTS_${gtk_target}" gtk_target)
set(${gtk_target} FALSE)
endforeach ()
if (GTK_VERSION AND GTK_VERSION_OK)
# Fetch the "targets" variable and set GTK_SUPPORTS_<target>.
pkg_get_variable(GTK_TARGETS ${GTK_PC_MODULE} targets)
separate_arguments(GTK_TARGETS)
foreach (gtk_target ${GTK_TARGETS})
string(TOUPPER "GTK_SUPPORTS_${gtk_target}" gtk_target)
set(${gtk_target} TRUE)
endforeach ()
endif ()
if (TARGET PkgConfig::GTK AND NOT TARGET GTK::GTK)
add_library(GTK::GTK INTERFACE IMPORTED GLOBAL)
set_property(TARGET GTK::GTK PROPERTY
INTERFACE_LINK_LIBRARIES PkgConfig::GTK
)
endif ()
# Try to find additional components
foreach (gtk_component ${GTK_FIND_COMPONENTS})
if (NOT "${gtk_component}" STREQUAL unix-print)
message(FATAL_ERROR "Invalid component name: ${gtk_component}")
endif ()
pkg_check_modules(GTK_UNIX_PRINT IMPORTED_TARGET "${GTK_PC_UNIX_PRINT_MODULE}")
if (GTK_FIND_REQUIRED_unix-print AND NOT GTK_UNIX_PRINT_FOUND)
message(FATAL_ERROR "Component unix-print not found")
endif ()
if (TARGET PkgConfig::GTK_UNIX_PRINT AND NOT TARGET GTK::UnixPrint)
add_library(GTK::UnixPrint INTERFACE IMPORTED GLOBAL)
set_property(TARGET GTK::UnixPrint PROPERTY
INTERFACE_LINK_LIBRARIES PkgConfig::GTK_UNIX_PRINT)
endif ()
endforeach ()
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK DEFAULT_MSG GTK_VERSION GTK_VERSION_OK)

68
cmake-modules/FindLV2.cmake

@ -0,0 +1,68 @@
#[=======================================================================[.rst:
FindLV2
-----------
Finds the LV2 library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``LV2::LV2``
The LV2 library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``LV2_FOUND``
True if the system has the LV2 library.
``LV2_INCLUDE_DIRS``
Include directories needed to use LV2.
``LV2_LIBRARIES``
Libraries needed to link to LV2.
``LV2_DEFINITIONS``
Compile definitions needed to use LV2.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``LV2_INCLUDE_DIR``
The directory containing ``lv2.h``.
#]=======================================================================]
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_LV2 QUIET lv2)
endif()
# There is no library; only a header.
find_path(LV2_INCLUDE_DIR
NAMES lv2.h
PATHS ${PC_LV2_INCLUDE_DIRS}
PATH_SUFFIXES LV2
DOC "LV2 include directory")
mark_as_advanced(LV2_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
LV2
DEFAULT_MSG
LV2_INCLUDE_DIR
)
if(LV2_FOUND)
if(NOT TARGET LV2::LV2)
add_library(LV2::LV2 INTERFACE IMPORTED)
set_target_properties(LV2::LV2
PROPERTIES
INTERFACE_COMPILE_OPTIONS "${PC_LV2_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${LV2_INCLUDE_DIR}"
)
endif()
endif()

86
cmake-modules/FindMAD.cmake

@ -0,0 +1,86 @@
# 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.txt file for details.
#[=======================================================================[.rst:
FindMAD
-------
Finds the MAD library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``MAD::MAD``
The MAD library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``MAD_FOUND``
True if the system has the MAD library.
``MAD_INCLUDE_DIRS``
Include directories needed to use MAD.
``MAD_LIBRARIES``
Libraries needed to link to MAD.
``MAD_DEFINITIONS``
Compile definitions needed to use MAD.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``MAD_INCLUDE_DIR``
The directory containing ``mad.h``.
``MAD_LIBRARY``
The path to the MAD library.
#]=======================================================================]
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_MAD QUIET mad)
endif()
find_path(MAD_INCLUDE_DIR
NAMES mad.h
PATHS ${PC_MAD_INCLUDE_DIRS}
PATH_SUFFIXES mad
DOC "MAD include directory")
mark_as_advanced(MAD_INCLUDE_DIR)
find_library(MAD_LIBRARY
NAMES mad
PATHS ${PC_MAD_LIBRARY_DIRS}
DOC "MAD library"
)
mark_as_advanced(MAD_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
MAD
DEFAULT_MSG
MAD_LIBRARY
MAD_INCLUDE_DIR
)
if(MAD_FOUND)
set(MAD_LIBRARIES "${MAD_LIBRARY}")
set(MAD_INCLUDE_DIRS "${MAD_INCLUDE_DIR}")
set(MAD_DEFINITIONS ${PC_MAD_CFLAGS_OTHER})
if(NOT TARGET MAD::MAD)
add_library(MAD::MAD UNKNOWN IMPORTED)
set_target_properties(MAD::MAD
PROPERTIES
IMPORTED_LOCATION "${MAD_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_MAD_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${MAD_INCLUDE_DIR}"
)
endif()
endif()

77
cmake-modules/FindOgg.cmake

@ -0,0 +1,77 @@
# 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.txt file for details.
#[=======================================================================[.rst:
FindOgg
-------
Finds the Ogg library.
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``Ogg_FOUND``
True if the system has the Ogg library.
``Ogg_INCLUDE_DIRS``
Include directories needed to use Ogg.
``Ogg_LIBRARIES``
Libraries needed to link to Ogg.
``Ogg_DEFINITIONS``
Compile definitions needed to use Ogg.
Cache Variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``Ogg_INCLUDE_DIR``
The directory containing ``ogg/ogg.h``.
``Ogg_LIBRARY``
The path to the Ogg library.
#]=======================================================================]
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PC_Ogg QUIET ogg)
endif()
find_path(Ogg_INCLUDE_DIR
NAMES ogg/ogg.h
PATHS ${PC_Ogg_INCLUDE_DIRS}
DOC "Ogg include directory"
)
mark_as_advanced(Ogg_INCLUDE_DIR)
find_library(Ogg_LIBRARY
NAMES ogg
PATHS ${PC_Ogg_LIBRARY_DIRS}
DOC "Ogg library"
)
mark_as_advanced(Ogg_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Ogg
REQUIRED_VARS
Ogg_INCLUDE_DIR
Ogg_LIBRARY
)
if(Ogg_FOUND)
set(Ogg_LIBRARIES ${Ogg_LIBRARY})
set(Ogg_INCLUDE_DIRS ${Ogg_INCLUDE_DIR})
set(Ogg_DEFINITIONS ${PC_Ogg_CFLAGS_OTHER})
if(NOT TARGET Ogg::ogg)
add_library(Ogg::ogg UNKNOWN IMPORTED)
set_target_properties(Ogg::ogg
PROPERTIES
IMPORTED_LOCATION "${Ogg_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_Ogg_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${Ogg_INCLUDE_DIR}"
)
endif()
endif()

57
cmake-modules/FindPortAudio.cmake

@ -0,0 +1,57 @@
# 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.txt file for details.
#[=======================================================================[.rst:
FindPortAudio
--------
Finds the PortAudio library.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``PortAudio::PortAudio``
The PortAudio library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``PortAudio_FOUND``
True if the system has the PortAudio library.
#]=======================================================================]
find_package(PkgConfig QUIET)
if(PkgConfig_FOUND)
pkg_check_modules(PortAudio portaudio-2.0)
else()
find_path(PortAudio_INCLUDEDIR
NAMES portaudio.h
DOC