diff --git a/CMakeLists.txt b/CMakeLists.txt index d60a1a9b8ba..3f9e9846955 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,16 +26,22 @@ if(POLICY CMP0071) endif() # Check if any relevant env vars were set from the build env scripts -if(DEFINED ENV{X_VCPKG_APPLOCAL_DEPS_INSTALL} AND NOT DEFINED X_VCPKG_APPLOCAL_DEPS_INSTALL) - set(X_VCPKG_APPLOCAL_DEPS_INSTALL "$ENV{X_VCPKG_APPLOCAL_DEPS_INSTALL}" CACHE BOOL "") -endif() +if(DEFINED ENV{VCPKG_ROOT}) + if(DEFINED ENV{X_VCPKG_APPLOCAL_DEPS_INSTALL} AND NOT DEFINED X_VCPKG_APPLOCAL_DEPS_INSTALL) + set(X_VCPKG_APPLOCAL_DEPS_INSTALL "$ENV{X_VCPKG_APPLOCAL_DEPS_INSTALL}" CACHE BOOL "") + endif() -if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) - set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") -endif() + if(DEFINED ENV{VCPKG_OVERLAY_TRIPLETS} AND NOT DEFINED VCPKG_OVERLAY_TRIPLETS) + set(VCPKG_OVERLAY_TRIPLETS "$ENV{VCPKG_OVERLAY_TRIPLETS}" CACHE STRING "") + endif() -if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) - set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") + if(DEFINED ENV{VCPKG_DEFAULT_TRIPLET} AND NOT DEFINED VCPKG_TARGET_TRIPLET) + set(VCPKG_TARGET_TRIPLET "$ENV{VCPKG_DEFAULT_TRIPLET}" CACHE STRING "") + endif() + + if(NOT DEFINED CMAKE_TOOLCHAIN_FILE) + set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "") + endif() endif() # Set a default build type if none was specified @@ -76,6 +82,7 @@ include(CheckSymbolExists) include(ExternalProject) include(GNUInstallDirs) include(DefaultOption) +include(IsStaticLibrary) ####################################################################### # Compilers and toolchains @@ -1180,9 +1187,6 @@ if(WIN32) target_link_libraries(mixxx-lib PRIVATE shell32) if(MSVC) - if(NOT STATIC_DEPS OR CMAKE_BUILD_TYPE STREQUAL "Debug") - target_link_options(mixxx-lib PUBLIC /nodefaultlib:LIBCMT.lib /nodefaultlib:LIBCMTd.lib) - endif() target_link_options(mixxx-lib PUBLIC /entry:mainCRTStartup) # Force MSVS to generate a manifest (MSVC2010) target_link_options(mixxx-lib PUBLIC /manifest) @@ -1779,21 +1783,38 @@ if(WIN32) target_include_directories(mixxx PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}") endif() -# -# Dependencies -# -option(STATIC_DEPS "Link dependencies statically" OFF) - # Chromaprint find_package(Chromaprint REQUIRED) target_link_libraries(mixxx-lib PRIVATE Chromaprint::Chromaprint) -if(WIN32) - if(STATIC_DEPS) - target_compile_definitions(mixxx-lib PUBLIC CHROMAPRINT_NODLL) + +# Locale Aware Compare for SQLite +find_package(SQLite3) +# For LOCALECOMPARE we call directly sqlite functions to the database opened by +# Qt. It only works without crashing when Mixxx links to the same sqlite +# library as Qt. +# This is difficult on macOS where system the SQLite can be installed and linked +# dynamically from various locations. There is no issue in case of static +# linking which would result in a duplicate symbol error. +if(NOT SQLite3_FOUND) + set(LOCALECOMPARE_DEFAULT OFF) +else() + is_static_library(SQLite3_IS_STATIC SQLite3::SQLite3) + if(SQLite3_IS_STATIC OR NOT APPLE) + set(LOCALECOMPARE_DEFAULT ON) + else() + set(LOCALECOMPARE_DEFAULT OFF) + endif() +endif() +cmake_dependent_option(LOCALECOMPARE "Locale Aware Compare support for SQLite" ON "LOCALECOMPARE_DEFAULT" OFF) +if(LOCALECOMPARE) + if(NOT SQLite3_FOUND) + message(FATAL_ERROR "Locale Aware Compare for SQLite requires libsqlite and its development headers.") endif() - # Chromaprint is always built statically and needs fftw. - find_package(FFTW REQUIRED) - target_link_libraries(mixxx-lib PRIVATE FFTW::FFTW) + target_compile_definitions(mixxx-lib PUBLIC __SQLITE3__) + target_link_libraries(mixxx-lib PRIVATE SQLite3::SQLite3) +elseif(SQLite3_IS_STATIC) + # in the static case we need to link SQLite3 uncoditionally + target_link_libraries(mixxx-lib PRIVATE SQLite3::SQLite3) endif() # Denon Engine Prime library export support (using libdjinterop) @@ -1812,7 +1833,7 @@ if(ENGINEPRIME) # On MacOS, Mixxx does not use system SQLite, so we will use libdjinterop's # embedded SQLite in such a case. - if (APPLE) + if (APPLE AND NOT SQLite3_IS_STATIC) message(STATUS "Building libdjinterop sources (with embedded SQLite) fetched from GitHub") set(DJINTEROP_SYSTEM_SQLITE OFF) else() @@ -1983,9 +2004,6 @@ endif() # FLAC find_package(FLAC REQUIRED) target_link_libraries(mixxx-lib PRIVATE FLAC::FLAC) -if(WIN32 AND STATIC_DEPS) - target_compile_definitions(mixxx-lib PUBLIC FLAC__NO_DLL) -endif() # FpClassify This is a wrapper around the fpclassify function that prevents # inlining It is compiled without optimization and allows to use these function @@ -2056,7 +2074,7 @@ target_include_directories(mixxx-lib SYSTEM PUBLIC ${PortMidi_INCLUDE_DIRS}) target_link_libraries(mixxx-lib PRIVATE ${PortMidi_LIBRARIES}) # Protobuf -if(STATIC_DEPS) +if(NOT BUILD_SHARED_LIBS) set(Protobuf_USE_STATIC_LIBS ON) mark_as_advanced(Protobuf_USE_STATIC_LIBS) endif() @@ -2075,6 +2093,7 @@ find_package(Qt5 Gui Network OpenGL + PrintSupport Qml QuickWidgets Sql @@ -2084,12 +2103,14 @@ find_package(Qt5 Xml REQUIRED ) +# PUBLIC is required below to find included headers target_link_libraries(mixxx-lib PUBLIC Qt5::Concurrent Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL + Qt5::PrintSupport Qt5::Qml Qt5::QuickWidgets Qt5::Sql @@ -2098,8 +2119,8 @@ target_link_libraries(mixxx-lib PUBLIC Qt5::Widgets Qt5::Xml) target_compile_definitions(mixxx-lib PUBLIC QT_TABLET_SUPPORT QT_USE_QSTRINGBUILDER) -get_target_property(QT5_TYPE Qt5::Core TYPE) -if(QT5_TYPE STREQUAL "STATIC_LIBRARY") +is_static_library(Qt5_IS_STATIC Qt5::Core) +if(Qt5_IS_STATIC) # NOTE(rryan): If you are adding a plugin here, you must also # update src/mixxxapplication.cpp to define a Q_IMPORT_PLUGIN @@ -2139,7 +2160,32 @@ if(QT5_TYPE STREQUAL "STATIC_LIBRARY") endif() -if(UNIX AND NOT APPLE) + +if(APPLE) + if(Qt5_IS_STATIC) + target_link_libraries(mixxx-lib PRIVATE + "-weak_framework Accelerate" + "-weak_framework AppKit" + "-weak_framework AudioToolbox" + "-weak_framework AudioUnit" + "-weak_framework AVFoundation" + "-weak_framework CoreAudio" + "-weak_framework CoreFoundation" + "-weak_framework CoreImage" + "-weak_framework CoreMedia" + "-weak_framework CoreMidi" + "-weak_framework CoreServices" + "-weak_framework CoreVideo" + "-weak_framework IOSurface" + "-weak_framework VideoToolbox" + ) + else() + # Used for battery measurements and controlling the screensaver on macOS. + target_link_libraries(mixxx-lib PRIVATE + "-weak_framework IOKit" + ) + endif() +elseif(UNIX) find_package(X11 REQUIRED) find_package(Qt5 COMPONENTS X11Extras DBus REQUIRED) target_include_directories(mixxx-lib SYSTEM PUBLIC "${X11_INCLUDE_DIR}") @@ -2149,7 +2195,7 @@ if(UNIX AND NOT APPLE) Qt5::DBus ) elseif(WIN32) - if(QT5_TYPE STREQUAL "STATIC_LIBRARY") + if(Qt5_IS_STATIC) target_link_libraries(mixxx-lib PRIVATE # Pulled from qt-4.8.2-source\mkspecs\win32-msvc2010\qmake.conf # QtCore @@ -2294,10 +2340,6 @@ target_compile_definitions(mixxx-lib PUBLIC __SNDFILE__) if(SndFile_SUPPORTS_SET_COMPRESSION_LEVEL) target_compile_definitions(mixxx-lib PUBLIC SFC_SUPPORTS_SET_COMPRESSION_LEVEL) endif() -if(WIN32 AND STATIC_DEPS) - find_package(G72X REQUIRED) - target_link_libraries(mixxx-lib PRIVATE G72X::G72X) -endif() # SoundTouch find_package(SoundTouch) @@ -2330,35 +2372,12 @@ endif() # TagLib find_package(TagLib REQUIRED) target_link_libraries(mixxx-lib PRIVATE TagLib::TagLib) -if(WIN32 AND STATIC_DEPS) - target_compile_definitions(mixxx-lib PUBLIC TAGLIB_STATIC) -endif() # Threads set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) target_link_libraries(mixxx-lib PRIVATE Threads::Threads) -# iOS/OS X Frameworks -if(APPLE) - find_library(COREFOUNDATION_LIBRARY CoreFoundation REQUIRED) - target_link_libraries(mixxx-lib PRIVATE ${COREFOUNDATION_LIBRARY}) - - # The iOS/OS X security framework is used to implement sandboxing. - find_library(SECURITY_LIBRARY Security REQUIRED) - target_link_libraries(mixxx-lib PRIVATE ${SECURITY_LIBRARY}) - - find_library(CORESERVICES_LIBRARY CoreServices REQUIRED) - target_link_libraries(mixxx-lib PRIVATE ${CORESERVICES_LIBRARY}) - - find_library(FOUNDATION_LIBRARY Foundation REQUIRED) - target_link_libraries(mixxx-lib PRIVATE ${FOUNDATION_LIBRARY}) - - # Used for battery measurements and controlling the screensaver on OS X and iOS. - find_library(IOKIT_LIBRARY IOKit REQUIRED) - target_link_libraries(mixxx-lib PRIVATE ${IOKIT_LIBRARY}) -endif() - # # Features # @@ -2474,12 +2493,13 @@ endif() # FDK-AAC is loaded dynamically at runtime by EncoderFdkAac using QLibrary, # so copy it into the Windows and macOS packages, but do not link to it. if(APPLE AND MACOS_BUNDLE) - find_library(FDK_AAC_LIBRARY fdk-aac.2) + find_library(FDK_AAC_LIBRARY fdk-aac) if(FDK_AAC_LIBRARY) message(STATUS "Found fdk-aac: ${FDK_AAC_LIBRARY}") - install(FILES ${FDK_AAC_LIBRARY} DESTINATION ${MIXXX_INSTALL_PREFIX}/Contents/Frameworks) + file(COPY ${FDK_AAC_LIBRARY} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/lib/fdk-aac-install" FOLLOW_SYMLINK_CHAIN) + install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib/fdk-aac-install/" DESTINATION "${MIXXX_INSTALL_PREFIX}/Contents/Frameworks") else() - message(STATUS "Could NOT find libfdk-aac.2.dylib") + message(STATUS "Could NOT find libfdk-aac.dylib") endif() elseif(WIN32) # On Windows find_library finds the .lib file, but the installer needs the .dll file. @@ -2617,27 +2637,12 @@ if(BROADCAST) target_compile_definitions(mixxx-lib PUBLIC __BROADCAST__) endif() -# Locale Aware Compare for SQLite -find_package(SQLite3) -# FIXME: It is difficult to get qmake to link Qt to a custom built SQLite on -# macOS instead of the system SQLite, which results in a crash on startup when -# LOCALECOMPARE is enabled, therefore this option is forcibly set to OFF on -# macOS. -cmake_dependent_option(LOCALECOMPARE "Locale Aware Compare support for SQLite" "${SQLite3_FOUND}" "NOT APPLE" OFF) -if(LOCALECOMPARE) - if(NOT SQLite3_FOUND) - message(FATAL_ERROR "Locale Aware Compare for SQLite requires libsqlite and its development headers.") - endif() - target_compile_definitions(mixxx-lib PUBLIC __SQLITE3__) - target_include_directories(mixxx-lib SYSTEM PRIVATE ${SQLite3_INCLUDE_DIRS}) - target_link_libraries(mixxx-lib PRIVATE ${SQLite3_LIBRARIES}) -endif() - # Opus (RFC 6716) +find_package(OpusFile) find_package(Opus) -default_option(OPUS "Opus (RFC 6716) support" "Opus_FOUND") +default_option(OPUS "Opus (RFC 6716) support" "OpusFile_FOUND") if(OPUS) - if(NOT Opus_FOUND) + if(NOT OpusFile_FOUND OR NOT Opus_FOUND) message(FATAL_ERROR "Opus support requires libopus and libopusfile with development headers.") endif() target_sources(mixxx-lib PRIVATE @@ -2646,21 +2651,8 @@ if(OPUS) src/encoder/encoderopussettings.cpp ) target_compile_definitions(mixxx-lib PUBLIC __OPUS__) - target_include_directories(mixxx-lib SYSTEM PUBLIC ${Opus_INCLUDE_DIRS}) - target_link_libraries(mixxx-lib PRIVATE ${Opus_LIBRARIES}) - if(WIN32 AND STATIC_DEPS) - find_package(Celt) - if(NOT Celt_FOUND) - message(FATAL_ERROR "Opus support with static dependencies requires the celt library.") - endif() - target_link_libraries(mixxx-lib PRIVATE Celt::Celt) - - find_package(Silk) - if(NOT Silk_FOUND) - message(FATAL_ERROR "Opus support with static dependencies requires the silk library.") - endif() - target_link_libraries(mixxx-lib PRIVATE Silk::Float) - endif() + target_link_libraries(mixxx-lib PRIVATE OpusFile::OpusFile) + target_link_libraries(mixxx-lib PRIVATE Opus::Opus) endif() # MAD MP3 Decoder @@ -2918,7 +2910,7 @@ set(CPACK_PROJECT_CONFIG_FILE "${CMAKE_SOURCE_DIR}/packaging/CPackConfig.cmake" include(CPack) if(APPLE AND MACOS_BUNDLE) - if(NOT QT5_TYPE STREQUAL "STATIC_LIBRARY") + if(NOT Qt5_IS_STATIC) macro(install_qt5_plugin _qt_plugin_name _qt_plugins_var _prefix) get_target_property(_qt_plugin_path "${_qt_plugin_name}" LOCATION) if(EXISTS "${_qt_plugin_path}") diff --git a/cmake/modules/FindCelt.cmake b/cmake/modules/FindCelt.cmake deleted file mode 100644 index 03c731a3edb..00000000000 --- a/cmake/modules/FindCelt.cmake +++ /dev/null @@ -1,63 +0,0 @@ -# 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: -FindCelt --------- - -Finds the Celt library. - -Imported Targets -^^^^^^^^^^^^^^^^ - -This module provides the following imported targets, if found: - -``Celt::Celt`` - The Celt library - -Result Variables -^^^^^^^^^^^^^^^^ - -This will define the following variables: - -``Celt_FOUND`` - True if the system has the Celt library. -``Celt_LIBRARIES`` - Libraries needed to link to Celt. - -Cache Variables -^^^^^^^^^^^^^^^ - -The following cache variables may also be set: - -``Celt_LIBRARY`` - The path to the Celt library. - -#]=======================================================================] - -find_library(Celt_LIBRARY - NAMES fftw fftw3 fftw-3.3 - DOC "Celt library" -) -mark_as_advanced(Celt_LIBRARY) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - Celt - DEFAULT_MSG - Celt_LIBRARY -) - -if(Celt_FOUND) - set(Celt_LIBRARIES "${Celt_LIBRARY}") - - if(NOT TARGET Celt::Celt) - add_library(Celt::Celt UNKNOWN IMPORTED) - set_target_properties(Celt::Celt - PROPERTIES - IMPORTED_LOCATION "${Celt_LIBRARY}" - ) - endif() -endif() diff --git a/cmake/modules/FindChromaprint.cmake b/cmake/modules/FindChromaprint.cmake index a85c58068f1..350861f1bbb 100644 --- a/cmake/modules/FindChromaprint.cmake +++ b/cmake/modules/FindChromaprint.cmake @@ -43,6 +43,8 @@ The following cache variables may also be set: #]=======================================================================] +include(IsStaticLibrary) + find_package(PkgConfig QUIET) if(PkgConfig_FOUND) pkg_check_modules(PC_Chromaprint QUIET libchromaprint) @@ -83,5 +85,18 @@ if(Chromaprint_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_Chromaprint_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${Chromaprint_INCLUDE_DIR}" ) + is_static_library(Chromaprint_IS_STATIC Chromaprint::Chromaprint) + if(Chromaprint_IS_STATIC) + if(WIN32) + # used in chomaprint.h to set dllexport for Windows + set_property(TARGET Chromaprint::Chromaprint APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS + CHROMAPRINT_NODLL + ) + endif() + find_package(FFTW REQUIRED) + set_property(TARGET Chromaprint::Chromaprint APPEND PROPERTY INTERFACE_LINK_LIBRARIES + FFTW::FFTW + ) + endif() endif() endif() diff --git a/cmake/modules/FindFLAC.cmake b/cmake/modules/FindFLAC.cmake index 30911b68871..2d2c07d60ae 100644 --- a/cmake/modules/FindFLAC.cmake +++ b/cmake/modules/FindFLAC.cmake @@ -43,6 +43,8 @@ The following cache variables may also be set: #]=======================================================================] +include(IsStaticLibrary) + find_package(PkgConfig QUIET) if(PkgConfig_FOUND) pkg_check_modules(PC_FLAC QUIET flac) @@ -82,5 +84,13 @@ if(FLAC_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_FLAC_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}" ) + is_static_library(FLAC_IS_STATIC FLAC::FLAC) + if(FLAC_IS_STATIC) + if(WIN32) + set_property(TARGET FLAC::FLAC APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS + FLAC__NO_DLL + ) + endif() + endif() endif() endif() diff --git a/cmake/modules/FindKeyFinder.cmake b/cmake/modules/FindKeyFinder.cmake index e620893879c..b4af4ea49e8 100644 --- a/cmake/modules/FindKeyFinder.cmake +++ b/cmake/modules/FindKeyFinder.cmake @@ -43,6 +43,8 @@ The following cache variables may also be set: #]=======================================================================] +include(IsStaticLibrary) + find_package(PkgConfig QUIET) if(PkgConfig_FOUND) pkg_check_modules(PC_KeyFinder QUIET libKeyFinder>=2.0) @@ -82,5 +84,12 @@ if(KeyFinder_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_KeyFinder_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${KeyFinder_INCLUDE_DIR}" ) + is_static_library(KeyFinder_IS_STATIC KeyFinder::KeyFinder) + if(KeyFinder_IS_STATIC) + find_package(FFTW REQUIRED) + set_property(TARGET KeyFinder::KeyFinder APPEND PROPERTY INTERFACE_LINK_LIBRARIES + FFTW::FFTW + ) + endif() endif() endif() diff --git a/cmake/modules/FindOpus.cmake b/cmake/modules/FindOpus.cmake index 18d4a447ec3..bcbd47aba25 100644 --- a/cmake/modules/FindOpus.cmake +++ b/cmake/modules/FindOpus.cmake @@ -32,17 +32,12 @@ The following cache variables may also be set: The directory containing ``opus.h``. ``Opus_LIBRARY`` The path to the Opus library. -``OpusFile_INCLUDE_DIR`` - The directory containing ``opusfile.h``. -``OpusFile_LIBRARY`` - The path to the Opus library. #]=======================================================================] find_package(PkgConfig QUIET) if(PkgConfig_FOUND) pkg_check_modules(PC_Opus QUIET opus) - pkg_check_modules(PC_OpusFile QUIET opusfile) endif() find_path(Opus_INCLUDE_DIR @@ -58,32 +53,26 @@ find_library(Opus_LIBRARY ) mark_as_advanced(Opus_LIBRARY) -find_path(OpusFile_INCLUDE_DIR - NAMES opusfile.h - PATH_SUFFIXES opus - PATHS ${PC_OpusFile_INCLUDE_DIRS} - DOC "Opusfile include directory") -mark_as_advanced(OpusFile_INCLUDE_DIR) - -find_library(OpusFile_LIBRARY - NAMES opusfile - PATHS ${PC_OpusFile_LIBRARY_DIRS} - DOC "Opusfile library" -) -mark_as_advanced(OpusFile_LIBRARY) - include(FindPackageHandleStandardArgs) find_package_handle_standard_args( Opus DEFAULT_MSG Opus_LIBRARY Opus_INCLUDE_DIR - OpusFile_LIBRARY - OpusFile_INCLUDE_DIR ) if(Opus_FOUND) - set(Opus_LIBRARIES ${Opus_LIBRARY} ${OpusFile_LIBRARY}) - set(Opus_INCLUDE_DIRS ${Opus_INCLUDE_DIR} ${OpusFile_INCLUDE_DIR}) - set(Opus_DEFINITIONS ${PC_Opus_CFLAGS_OTHER} ${PC_OpusFile_CFLAGS_OTHER}) + set(Opus_LIBRARIES ${Opus_LIBRARY}) + set(Opus_INCLUDE_DIRS ${Opus_INCLUDE_DIR}) + set(Opus_DEFINITIONS ${PC_Opus_CFLAGS_OTHER}) + + if(NOT TARGET Opus::Opus) + add_library(Opus::Opus UNKNOWN IMPORTED) + set_target_properties(Opus::Opus + PROPERTIES + IMPORTED_LOCATION "${Opus_LIBRARIES}" + INTERFACE_COMPILE_OPTIONS "${Opus_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${Opus_INCLUDE_DIRS}" + ) + endif() endif() diff --git a/cmake/modules/FindOpusFile.cmake b/cmake/modules/FindOpusFile.cmake new file mode 100644 index 00000000000..65f00e63430 --- /dev/null +++ b/cmake/modules/FindOpusFile.cmake @@ -0,0 +1,85 @@ +# 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: +FindOpus +-------- + +Finds the Opus library. + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``OpusFile_FOUND`` + True if the system has the Opus library. +``OpusFile_INCLUDE_DIRS`` + Include directories needed to use Opus. +``OpusFile_LIBRARIES`` + Libraries needed to link to Opus. +``OpusFile_DEFINITIONS`` + Compile definitions needed to use Opus. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``OpusFile_INCLUDE_DIR`` + The directory containing ``opus.h``. +``OpusFile_LIBRARY`` + The path to the Opus library. +``OpusFile_INCLUDE_DIR`` + The directory containing ``opusfile.h``. +``OpusFile_LIBRARY`` + The path to the Opus library. + +#]=======================================================================] + +include(IsStaticLibrary) + +find_package(PkgConfig QUIET) +if(PkgConfig_FOUND) + pkg_check_modules(PC_OpusFile QUIET opusfile) +endif() + +find_path(OpusFile_INCLUDE_DIR + NAMES opusfile.h + PATH_SUFFIXES opus + PATHS ${PC_OpusFile_INCLUDE_DIRS} + DOC "Opusfile include directory") +mark_as_advanced(OpusFile_INCLUDE_DIR) + +find_library(OpusFile_LIBRARY + NAMES opusfile + PATHS ${PC_OpusFile_LIBRARY_DIRS} + DOC "Opusfile library" +) +mark_as_advanced(OpusFile_LIBRARY) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + OpusFile + DEFAULT_MSG + OpusFile_LIBRARY + OpusFile_INCLUDE_DIR +) + +if(OpusFile_FOUND) + set(OpusFile_LIBRARIES ${OpusFile_LIBRARY}) + set(OpusFile_INCLUDE_DIRS ${OpusFile_INCLUDE_DIR}) + set(OpusFile_DEFINITIONS ${PC_OpusFile_CFLAGS_OTHER}) + + if(NOT TARGET OpusFile::OpusFile) + add_library(OpusFile::OpusFile UNKNOWN IMPORTED) + set_target_properties(OpusFile::OpusFile + PROPERTIES + IMPORTED_LOCATION "${OpusFile_LIBRARIES}" + INTERFACE_COMPILE_OPTIONS "${OpusFile_DEFINITIONS}" + INTERFACE_INCLUDE_DIRECTORIES "${OpusFile_INCLUDE_DIRS}" + ) + endif() +endif() diff --git a/cmake/modules/FindSilk.cmake b/cmake/modules/FindSilk.cmake deleted file mode 100644 index 9ed746a5fdf..00000000000 --- a/cmake/modules/FindSilk.cmake +++ /dev/null @@ -1,111 +0,0 @@ -# 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: -FindSilk --------- - -Finds the Silk library. - -Imported Targets -^^^^^^^^^^^^^^^^ - -This module provides the following imported targets, if found: - -``Silk::Common`` - The Silk common library - -``Silk::Fixed`` - The Silk fixed library - -``Silk::Float`` - The Silk float library - -Result Variables -^^^^^^^^^^^^^^^^ - -This will define the following variables: - -``Silk_FOUND`` - True if the system has the Silk library. -``Silk_LIBRARIES`` - Libraries needed to link to Silk. - -Cache Variables -^^^^^^^^^^^^^^^ - -The following cache variables may also be set: - -``Silk_Common_LIBRARY`` - The path to the Silk common library. - -``Silk_Fixed_LIBRARY`` - The path to the Silk fixed library. - -``Silk_Float_LIBRARY`` - The path to the Silk float library. - -#]=======================================================================] - -find_library(Silk_Common_LIBRARY - NAMES silk_common - DOC "Silk common library" -) -mark_as_advanced(Silk_Common_LIBRARY) - -find_library(Silk_Fixed_LIBRARY - NAMES silk_fixed - DOC "Silk fixed library" -) -mark_as_advanced(Silk_Fixed_LIBRARY) - -find_library(Silk_Float_LIBRARY - NAMES silk_float - DOC "Silk float library" -) -mark_as_advanced(Silk_Float_LIBRARY) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args( - Silk - DEFAULT_MSG - Silk_Common_LIBRARY - Silk_Fixed_LIBRARY - Silk_Float_LIBRARY -) - -if(Silk_FOUND) - set(Silk_LIBRARIES - "${Silk_Common_LIBRARY}" - "${Silk_Fixed_LIBRARY}" - "${Silk_Float_LIBRARY}" - ) - - if(NOT TARGET Silk::Common) - add_library(Silk::Common UNKNOWN IMPORTED) - set_target_properties(Silk::Common - PROPERTIES - IMPORTED_LOCATION "${Silk_Common_LIBRARY}" - ) - endif() - - if(NOT TARGET Silk::Fixed) - add_library(Silk::Fixed UNKNOWN IMPORTED) - set_target_properties(Silk::Fixed - PROPERTIES - IMPORTED_LOCATION "${Silk_Fixed_LIBRARY}" - INTERFACE_LINK_LIBRARIES Silk::Common - ) - endif() - - if(NOT TARGET Silk::Float) - add_library(Silk::Float UNKNOWN IMPORTED) - set_target_properties(Silk::Float - PROPERTIES - IMPORTED_LOCATION "${Silk_Float_LIBRARY}" - INTERFACE_LINK_LIBRARIES Silk::Common - ) - endif() -endif() diff --git a/cmake/modules/FindTagLib.cmake b/cmake/modules/FindTagLib.cmake index 36da772b011..ce9e3687e00 100644 --- a/cmake/modules/FindTagLib.cmake +++ b/cmake/modules/FindTagLib.cmake @@ -43,6 +43,8 @@ The following cache variables may also be set: #]=======================================================================] +include(IsStaticLibrary) + find_package(PkgConfig QUIET) if(PkgConfig_FOUND) pkg_check_modules(PC_TagLib QUIET taglib) @@ -83,5 +85,13 @@ if(TagLib_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_TagLib_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${TagLib_INCLUDE_DIR}" ) + is_static_library(Taglib_IS_STATIC TagLib::TagLib) + if(Taglib_IS_STATIC) + if(WIN32) + set_property(TARGET TagLib::TagLib APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS + TAGLIB_STATIC + ) + endif() + endif() endif() endif() diff --git a/cmake/modules/Findlilv.cmake b/cmake/modules/Findlilv.cmake index 15cd4571cae..33effdd5d89 100644 --- a/cmake/modules/Findlilv.cmake +++ b/cmake/modules/Findlilv.cmake @@ -43,6 +43,8 @@ The following cache variables may also be set: #]=======================================================================] +include(IsStaticLibrary) + find_package(PkgConfig QUIET) if(PkgConfig_FOUND) pkg_check_modules(PC_lilv QUIET lilv-0) @@ -84,5 +86,12 @@ if(lilv_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_lilv_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${lilv_INCLUDE_DIR}" ) + is_static_library(lilv_IS_STATIC lilv::lilv) + if(lilv_IS_STATIC) + find_package(sord CONFIG REQUIRED) + set_property(TARGET lilv::lilv APPEND PROPERTY INTERFACE_LINK_LIBRARIES + sord::sord + ) + endif() endif() endif() diff --git a/cmake/modules/Findrubberband.cmake b/cmake/modules/Findrubberband.cmake index 7de7d2efd64..3fdf2470a8d 100644 --- a/cmake/modules/Findrubberband.cmake +++ b/cmake/modules/Findrubberband.cmake @@ -82,5 +82,14 @@ if(rubberband_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_rubberband_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${rubberband_INCLUDE_DIR}" ) + is_static_library(rubberband_IS_STATIC Chromaprint::Chromaprint) + if(rubberband_IS_STATIC) + find_package(FFTW REQUIRED) + find_library(SAMPLERATE_LIBRARY samplerate REQUIRED) + set_property(TARGET rubberband::rubberband APPEND PROPERTY INTERFACE_LINK_LIBRARIES + FFTW::FFTW + ${SAMPLERATE_LIBRARY} + ) + endif() endif() endif() diff --git a/cmake/modules/IsStaticLibrary.cmake b/cmake/modules/IsStaticLibrary.cmake new file mode 100644 index 00000000000..d6163a908fd --- /dev/null +++ b/cmake/modules/IsStaticLibrary.cmake @@ -0,0 +1,41 @@ +#[=======================================================================[.rst: +IsStaticLibrary +------------- + +Macros to set a given variable to true or false whether the library is static + +Usage: + +.. code-block:: cmake + + is_static_library( target) + +Where ```` is set to TRUE if the target is a static library + +Example invocation: + +.. code-block:: cmake + + is_static_library(LIB_IS_STATIC Lib::Lib) + +#]=======================================================================] + +macro(IS_STATIC_LIBRARY var target) + get_target_property(_target_type ${target} TYPE) + if(${_target_type} STREQUAL "STATIC_LIBRARY") + set(${var} TRUE) + elseif(${_target_type} STREQUAL "UNKNOWN_LIBRARY") + get_target_property(_target_location ${target} LOCATION) + get_filename_component(_target_extension ${_target_location} EXT) + if(${_target_extension} STREQUAL ${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(${var} TRUE) + else() + set(${var} FALSE) + endif() + unset(_target_location) + unset(_target_extension) + else() + set(${var} FALSE) + endif() + unset(_target_type) +endmacro()