From 6dec4fc35eaed3eab5aa66ecfdd6d39f301a0268 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 30 Jul 2021 23:41:26 +0200 Subject: [PATCH 01/18] Move Apple extra linking to the block where extra linking is defined for the other targets as well --- CMakeLists.txt | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fbe4b8f1b9..6d3c7f78bcd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2139,7 +2139,25 @@ if(QT5_TYPE STREQUAL "STATIC_LIBRARY") endif() -if(UNIX AND NOT APPLE) + +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}) +elseif(UNIX) find_package(X11 REQUIRED) find_package(Qt5 COMPONENTS X11Extras DBus REQUIRED) target_include_directories(mixxx-lib SYSTEM PUBLIC "${X11_INCLUDE_DIR}") @@ -2339,26 +2357,6 @@ 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 # From 39df2895fac66ab819ad007b219779fac4f1b373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 30 Jul 2021 23:52:11 +0200 Subject: [PATCH 02/18] Added additional libraries required for static linking on macOs --- CMakeLists.txt | 55 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d3c7f78bcd..80cf717d32e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2141,22 +2141,53 @@ endif() if(APPLE) - find_library(COREFOUNDATION_LIBRARY CoreFoundation REQUIRED) - target_link_libraries(mixxx-lib PRIVATE ${COREFOUNDATION_LIBRARY}) + if(QT5_TYPE STREQUAL "STATIC_LIBRARY") + find_package(FFTW REQUIRED) + find_package(SndFile REQUIRED) + find_package(sord CONFIG REQUIRED) + find_package(SQLite3 REQUIRED) + find_library(SAMPLERATE_LIBRARY samplerate REQUIRED) + target_link_libraries(mixxx-lib PRIVATE + FFTW::FFTW + SndFile::sndfile + sord::sord + ${SQLite3_LIBRARIES} + ${SAMPLERATE_LIBRARY} + ) + 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() + 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}) + # 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(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}) + 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}) + # 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() elseif(UNIX) find_package(X11 REQUIRED) find_package(Qt5 COMPONENTS X11Extras DBus REQUIRED) From e911ba8b387bde6c118ca69c5aa974828c42d494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 30 Jul 2021 23:54:23 +0200 Subject: [PATCH 03/18] Remove unneded extra Apple link dependencies for the non static case --- CMakeLists.txt | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 80cf717d32e..ce1f46b1e9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2169,24 +2169,12 @@ if(APPLE) "-weak_framework CoreVideo" "-weak_framework IOSurface" "-weak_framework VideoToolbox" - ) + ) else() - 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}) + target_link_libraries(mixxx-lib PRIVATE + "-weak_framework IOKit" + ) endif() elseif(UNIX) find_package(X11 REQUIRED) From 4ba416e18877faf64b17fb52519fd123fb9d06b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 31 Jul 2021 02:21:04 +0200 Subject: [PATCH 04/18] Added Qt5::PrintSupport needed for MacOS linking --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce1f46b1e9d..30748a4b83b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2075,6 +2075,7 @@ find_package(Qt5 Gui Network OpenGL + PrintSupport Qml QuickWidgets Sql @@ -2084,12 +2085,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 From 03969842338119adf549368c13cdda7b792b2320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 31 Jul 2021 02:24:47 +0200 Subject: [PATCH 05/18] Add Support for VCPKG_OVERLAY_TRIPLETS --- CMakeLists.txt | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 30748a4b83b..424b940b72c 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 From 8ee51e33d44ed37fbfe62dcc8eaa427bb432d716 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 17 Jul 2021 18:24:24 +0200 Subject: [PATCH 06/18] Improve find cmake files for the static case --- CMakeLists.txt | 43 ++--------- cmake/modules/FindCelt.cmake | 63 ---------------- cmake/modules/FindChromaprint.cmake | 13 ++++ cmake/modules/FindFLAC.cmake | 8 ++ cmake/modules/FindKeyFinder.cmake | 7 ++ cmake/modules/FindOpus.cmake | 37 ++++------ cmake/modules/FindOpusFile.cmake | 90 ++++++++++++++++++++++ cmake/modules/FindSilk.cmake | 111 ---------------------------- cmake/modules/FindTagLib.cmake | 8 ++ cmake/modules/Findlilv.cmake | 10 +++ 10 files changed, 154 insertions(+), 236 deletions(-) delete mode 100644 cmake/modules/FindCelt.cmake create mode 100644 cmake/modules/FindOpusFile.cmake delete mode 100644 cmake/modules/FindSilk.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 424b940b72c..2d0cb84a72a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1186,9 +1186,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) @@ -1792,14 +1789,6 @@ 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) - endif() - # Chromaprint is always built statically and needs fftw. - find_package(FFTW REQUIRED) - target_link_libraries(mixxx-lib PRIVATE FFTW::FFTW) -endif() # Denon Engine Prime library export support (using libdjinterop) option(ENGINEPRIME "Support for library export to Denon Engine Prime" ON) @@ -1988,9 +1977,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 @@ -2340,10 +2326,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) @@ -2376,9 +2358,6 @@ 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) @@ -2660,10 +2639,11 @@ if(LOCALECOMPARE) 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 @@ -2672,21 +2652,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 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..868ee49f8f7 100644 --- a/cmake/modules/FindChromaprint.cmake +++ b/cmake/modules/FindChromaprint.cmake @@ -83,5 +83,18 @@ if(Chromaprint_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_Chromaprint_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${Chromaprint_INCLUDE_DIR}" ) + get_target_property(CHROMAPRINT_TYPE Chromaprint::Chromaprint TYPE) + if(CHROMAPRINT_TYPE STREQUAL "STATIC_LIBRARY") + 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..d5929a2a305 100644 --- a/cmake/modules/FindFLAC.cmake +++ b/cmake/modules/FindFLAC.cmake @@ -82,5 +82,13 @@ if(FLAC_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_FLAC_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}" ) + get_target_property(FLAC_TYPE FLAC::FLAC TYPE) + if(FLAC_TYPE STREQUAL "STATIC_LIBRARY") + 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..89f08a31979 100644 --- a/cmake/modules/FindKeyFinder.cmake +++ b/cmake/modules/FindKeyFinder.cmake @@ -82,5 +82,12 @@ if(KeyFinder_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_KeyFinder_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${KeyFinder_INCLUDE_DIR}" ) + get_target_property(KEYFINDER_TYPE KeyFinder::KeyFinder TYPE) + if(KEYFINDER_TYPE STREQUAL "STATIC_LIBRARY") + find_package(FFTW REQUIRED) + set_property(TARGET Chromaprint::Chromaprint 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..7fe2fcce900 --- /dev/null +++ b/cmake/modules/FindOpusFile.cmake @@ -0,0 +1,90 @@ +# 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. + +#]=======================================================================] + +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}" + ) + get_target_property(OPUSFILE_TYPE OpusFile::OpusFile TYPE) + if(PUSFILE_TYPE STREQUAL "STATIC_LIBRARY") + find_package(Opus REQUIRED) + set_property(TARGET Chromaprint::Chromaprint APPEND PROPERTY INTERFACE_LINK_LIBRARIES + Opus::Opus + ) + endif() + 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..19b47b9b61f 100644 --- a/cmake/modules/FindTagLib.cmake +++ b/cmake/modules/FindTagLib.cmake @@ -83,5 +83,13 @@ if(TagLib_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_TagLib_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${TagLib_INCLUDE_DIR}" ) + get_target_property(TAGLIB_TYPE TagLib::TagLib TYPE) + if(TAGLIB_TYPE STREQUAL "STATIC_LIBRARY") + 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..403cb5632fa 100644 --- a/cmake/modules/Findlilv.cmake +++ b/cmake/modules/Findlilv.cmake @@ -84,5 +84,15 @@ if(lilv_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_lilv_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${lilv_INCLUDE_DIR}" ) + get_target_property(LILV_TYPE lilv::lilv TYPE) + if(LILV_TYPE STREQUAL "STATIC_LIBRARY") + find_package(lv2 CONFIG REQUIRED) + find_package(serd CONFIG REQUIRED) + find_package(sord CONFIG REQUIRED) + find_package(sratom CONFIG REQUIRED) + set_property(TARGET lilv::lilv APPEND PROPERTY INTERFACE_LINK_LIBRARIES + lv2::lv2 serd::serd sord::sord sratom::sratom + ) + endif() endif() endif() From bd8d72f108c32bcc8e6e37a5b79412880a7199d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 31 Jul 2021 02:47:20 +0200 Subject: [PATCH 07/18] Remove obsolete STATIC_DEPS parameter --- CMakeLists.txt | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d0cb84a72a..5081bef3085 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1781,11 +1781,6 @@ 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) @@ -1806,7 +1801,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 DEFINED ENV{VCPKG_ROOT}) message(STATUS "Building libdjinterop sources (with embedded SQLite) fetched from GitHub") set(DJINTEROP_SYSTEM_SQLITE OFF) else() @@ -2048,7 +2043,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() From 70c5d73786a12e306b066bdfafdbcdecaaa36b0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 31 Jul 2021 15:09:46 +0200 Subject: [PATCH 08/18] Enable LOCALECOMPARE option for the static MacOs case, and fix ENGINEPRIME relationship --- CMakeLists.txt | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5081bef3085..71157d936d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1785,6 +1785,36 @@ endif() find_package(Chromaprint REQUIRED) target_link_libraries(mixxx-lib PRIVATE Chromaprint::Chromaprint) +# Locale Aware Compare for SQLite +find_package(SQLite3) +# For LOCALECOMPAREwe 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 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() + get_target_property(SQLITE3_TYPE SQLite3::SQLite3 TYPE) + if(SQLITE3_TYPE STREQUAL "STATIC_LIBRARY" 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() + target_compile_definitions(mixxx-lib PUBLIC __SQLITE3__) + target_link_libraries(mixxx-lib PRIVATE SQLite3::SQLite3) +elseif(CHROMAPRINT_TYPE STREQUAL "STATIC_LIBRARY") + # 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) option(ENGINEPRIME "Support for library export to Denon Engine Prime" ON) if(ENGINEPRIME) @@ -1801,7 +1831,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 AND NOT DEFINED ENV{VCPKG_ROOT}) + if (APPLE AND NOT SQLITE3_TYPE STREQUAL "STATIC_LIBRARY") message(STATUS "Building libdjinterop sources (with embedded SQLite) fetched from GitHub") set(DJINTEROP_SYSTEM_SQLITE OFF) else() @@ -2135,13 +2165,11 @@ if(APPLE) find_package(FFTW REQUIRED) find_package(SndFile REQUIRED) find_package(sord CONFIG REQUIRED) - find_package(SQLite3 REQUIRED) find_library(SAMPLERATE_LIBRARY samplerate REQUIRED) target_link_libraries(mixxx-lib PRIVATE FFTW::FFTW SndFile::sndfile sord::sord - ${SQLite3_LIBRARIES} ${SAMPLERATE_LIBRARY} ) target_link_libraries(mixxx-lib PRIVATE @@ -2617,22 +2645,6 @@ 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) From 1a47d2b7aaf0437c93ba0d9057942c4ebc2899a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sat, 31 Jul 2021 18:05:12 +0200 Subject: [PATCH 09/18] Fix spelling of Windows and other typos Co-authored-by: Be --- CMakeLists.txt | 2 +- cmake/modules/FindChromaprint.cmake | 2 +- cmake/modules/FindOpusFile.cmake | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71157d936d5..6b672a9701d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1810,7 +1810,7 @@ if(LOCALECOMPARE) endif() target_compile_definitions(mixxx-lib PUBLIC __SQLITE3__) target_link_libraries(mixxx-lib PRIVATE SQLite3::SQLite3) -elseif(CHROMAPRINT_TYPE STREQUAL "STATIC_LIBRARY") +elseif(SQLITE3_TYPE STREQUAL "STATIC_LIBRARY") # in the static case we need to link SQlite3 uncoditionally target_link_libraries(mixxx-lib PRIVATE SQLite3::SQLite3) endif() diff --git a/cmake/modules/FindChromaprint.cmake b/cmake/modules/FindChromaprint.cmake index 868ee49f8f7..d9f28ae0428 100644 --- a/cmake/modules/FindChromaprint.cmake +++ b/cmake/modules/FindChromaprint.cmake @@ -86,7 +86,7 @@ if(Chromaprint_FOUND) get_target_property(CHROMAPRINT_TYPE Chromaprint::Chromaprint TYPE) if(CHROMAPRINT_TYPE STREQUAL "STATIC_LIBRARY") if(WIN32) - # used in chomaprint.h to set dllexport for windows + # used in chomaprint.h to set dllexport for Windows set_property(TARGET Chromaprint::Chromaprint APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS CHROMAPRINT_NODLL ) diff --git a/cmake/modules/FindOpusFile.cmake b/cmake/modules/FindOpusFile.cmake index 7fe2fcce900..f6b692d1bf1 100644 --- a/cmake/modules/FindOpusFile.cmake +++ b/cmake/modules/FindOpusFile.cmake @@ -80,9 +80,9 @@ if(OpusFile_FOUND) INTERFACE_INCLUDE_DIRECTORIES "${OpusFile_INCLUDE_DIRS}" ) get_target_property(OPUSFILE_TYPE OpusFile::OpusFile TYPE) - if(PUSFILE_TYPE STREQUAL "STATIC_LIBRARY") + if(OPUSFILE_TYPE STREQUAL "STATIC_LIBRARY") find_package(Opus REQUIRED) - set_property(TARGET Chromaprint::Chromaprint APPEND PROPERTY INTERFACE_LINK_LIBRARIES + set_property(TARGET OpusFile::OpusFile APPEND PROPERTY INTERFACE_LINK_LIBRARIES Opus::Opus ) endif() From ab81f73b3742946792c09a7c5230b1d076bd72ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 1 Aug 2021 02:04:49 +0200 Subject: [PATCH 10/18] Introduce an IsLibraryStatic cmake module --- CMakeLists.txt | 29 +++++++------------- cmake/modules/FindChromaprint.cmake | 6 +++-- cmake/modules/FindFLAC.cmake | 6 +++-- cmake/modules/FindKeyFinder.cmake | 6 +++-- cmake/modules/FindOpusFile.cmake | 16 ++++++----- cmake/modules/FindTagLib.cmake | 6 +++-- cmake/modules/Findlilv.cmake | 11 ++++---- cmake/modules/Findrubberband.cmake | 9 +++++++ cmake/modules/IsStaticLibrary.cmake | 41 +++++++++++++++++++++++++++++ 9 files changed, 90 insertions(+), 40 deletions(-) create mode 100644 cmake/modules/IsStaticLibrary.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b672a9701d..1e1429cd313 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,7 @@ include(CheckSymbolExists) include(ExternalProject) include(GNUInstallDirs) include(DefaultOption) +include(IsStaticLibrary) ####################################################################### # Compilers and toolchains @@ -1796,8 +1797,8 @@ find_package(SQLite3) if(NOT SQLite3_FOUND) set(LOCALECOMPARE_DEFAULT OFF) else() - get_target_property(SQLITE3_TYPE SQLite3::SQLite3 TYPE) - if(SQLITE3_TYPE STREQUAL "STATIC_LIBRARY" OR NOT APPLE) + is_static_library(SQLite3_IS_STATIC SQLite3::SQLite3) + if(SQLite3_IS_STATIC OR NOT APPLE) set(LOCALECOMPARE_DEFAULT ON) else() set(LOCALECOMPARE_DEFAULT OFF) @@ -1810,7 +1811,7 @@ if(LOCALECOMPARE) endif() target_compile_definitions(mixxx-lib PUBLIC __SQLITE3__) target_link_libraries(mixxx-lib PRIVATE SQLite3::SQLite3) -elseif(SQLITE3_TYPE STREQUAL "STATIC_LIBRARY") +elseif(SQLite3_IS_STATIC) # in the static case we need to link SQlite3 uncoditionally target_link_libraries(mixxx-lib PRIVATE SQLite3::SQLite3) endif() @@ -1831,7 +1832,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 AND NOT SQLITE3_TYPE STREQUAL "STATIC_LIBRARY") + if (APPLE AND NOT SQLite3_IS_STATIC) message(STATUS "Building libdjinterop sources (with embedded SQLite) fetched from GitHub") set(DJINTEROP_SYSTEM_SQLITE OFF) else() @@ -2118,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 @@ -2161,17 +2162,7 @@ endif() if(APPLE) - if(QT5_TYPE STREQUAL "STATIC_LIBRARY") - find_package(FFTW REQUIRED) - find_package(SndFile REQUIRED) - find_package(sord CONFIG REQUIRED) - find_library(SAMPLERATE_LIBRARY samplerate REQUIRED) - target_link_libraries(mixxx-lib PRIVATE - FFTW::FFTW - SndFile::sndfile - sord::sord - ${SAMPLERATE_LIBRARY} - ) + if(Qt5_IS_STATIC) target_link_libraries(mixxx-lib PRIVATE "-weak_framework Accelerate" "-weak_framework AppKit" @@ -2204,7 +2195,7 @@ elseif(UNIX) 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 @@ -2918,7 +2909,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/FindChromaprint.cmake b/cmake/modules/FindChromaprint.cmake index d9f28ae0428..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,8 +85,8 @@ if(Chromaprint_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_Chromaprint_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${Chromaprint_INCLUDE_DIR}" ) - get_target_property(CHROMAPRINT_TYPE Chromaprint::Chromaprint TYPE) - if(CHROMAPRINT_TYPE STREQUAL "STATIC_LIBRARY") + 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 diff --git a/cmake/modules/FindFLAC.cmake b/cmake/modules/FindFLAC.cmake index d5929a2a305..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,8 +84,8 @@ if(FLAC_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_FLAC_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${FLAC_INCLUDE_DIR}" ) - get_target_property(FLAC_TYPE FLAC::FLAC TYPE) - if(FLAC_TYPE STREQUAL "STATIC_LIBRARY") + 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 diff --git a/cmake/modules/FindKeyFinder.cmake b/cmake/modules/FindKeyFinder.cmake index 89f08a31979..bde3668ab88 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,8 +84,8 @@ if(KeyFinder_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_KeyFinder_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${KeyFinder_INCLUDE_DIR}" ) - get_target_property(KEYFINDER_TYPE KeyFinder::KeyFinder TYPE) - if(KEYFINDER_TYPE STREQUAL "STATIC_LIBRARY") + is_static_library(KeyFinder_IS_STATIC KeyFinder::KeyFinder) + if(KeyFinder_IS_STATIC) find_package(FFTW REQUIRED) set_property(TARGET Chromaprint::Chromaprint APPEND PROPERTY INTERFACE_LINK_LIBRARIES FFTW::FFTW diff --git a/cmake/modules/FindOpusFile.cmake b/cmake/modules/FindOpusFile.cmake index f6b692d1bf1..9d1fc40c27e 100644 --- a/cmake/modules/FindOpusFile.cmake +++ b/cmake/modules/FindOpusFile.cmake @@ -39,6 +39,8 @@ The following cache variables may also be set: #]=======================================================================] +include(IsStaticLibrary) + find_package(PkgConfig QUIET) if(PkgConfig_FOUND) pkg_check_modules(PC_OpusFile QUIET opusfile) @@ -79,12 +81,12 @@ if(OpusFile_FOUND) INTERFACE_COMPILE_OPTIONS "${OpusFile_DEFINITIONS}" INTERFACE_INCLUDE_DIRECTORIES "${OpusFile_INCLUDE_DIRS}" ) - get_target_property(OPUSFILE_TYPE OpusFile::OpusFile TYPE) - if(OPUSFILE_TYPE STREQUAL "STATIC_LIBRARY") - find_package(Opus REQUIRED) - set_property(TARGET OpusFile::OpusFile APPEND PROPERTY INTERFACE_LINK_LIBRARIES - Opus::Opus - ) - endif() + is_static_library(OpusFile_IS_STATIC OpusFile::OpusFile) + #if(OpusFile_IS_STATIC) + # find_package(Opus REQUIRED) + # set_property(TARGET OpusFile::OpusFile APPEND PROPERTY INTERFACE_LINK_LIBRARIES + # Opus::Opus + # ) + #endif() endif() endif() diff --git a/cmake/modules/FindTagLib.cmake b/cmake/modules/FindTagLib.cmake index 19b47b9b61f..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,8 +85,8 @@ if(TagLib_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_TagLib_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${TagLib_INCLUDE_DIR}" ) - get_target_property(TAGLIB_TYPE TagLib::TagLib TYPE) - if(TAGLIB_TYPE STREQUAL "STATIC_LIBRARY") + 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 diff --git a/cmake/modules/Findlilv.cmake b/cmake/modules/Findlilv.cmake index 403cb5632fa..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,14 +86,11 @@ if(lilv_FOUND) INTERFACE_COMPILE_OPTIONS "${PC_lilv_CFLAGS_OTHER}" INTERFACE_INCLUDE_DIRECTORIES "${lilv_INCLUDE_DIR}" ) - get_target_property(LILV_TYPE lilv::lilv TYPE) - if(LILV_TYPE STREQUAL "STATIC_LIBRARY") - find_package(lv2 CONFIG REQUIRED) - find_package(serd CONFIG REQUIRED) + is_static_library(lilv_IS_STATIC lilv::lilv) + if(lilv_IS_STATIC) find_package(sord CONFIG REQUIRED) - find_package(sratom CONFIG REQUIRED) set_property(TARGET lilv::lilv APPEND PROPERTY INTERFACE_LINK_LIBRARIES - lv2::lv2 serd::serd sord::sord sratom::sratom + sord::sord ) 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() From 8b448019cbb1cdaf166f1318171465421e952fde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 1 Aug 2021 22:59:50 +0200 Subject: [PATCH 11/18] Remove iOS from the comments. Co-authored-by: Be --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e1429cd313..970d279be4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2180,7 +2180,7 @@ if(APPLE) "-weak_framework VideoToolbox" ) else() - # Used for battery measurements and controlling the screensaver on OS X and iOS. + # Used for battery measurements and controlling the screensaver on macOS. target_link_libraries(mixxx-lib PRIVATE "-weak_framework IOKit" ) From 264370e4ca571bb214d7675d6b16c2c5dbcd0063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 2 Aug 2021 01:41:53 +0200 Subject: [PATCH 12/18] Fix typo Co-authored-by: Be --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 970d279be4a..84f0a158f09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1812,7 +1812,7 @@ if(LOCALECOMPARE) 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 + # in the static case we need to link SQLite3 uncoditionally target_link_libraries(mixxx-lib PRIVATE SQLite3::SQLite3) endif() From 252152cbec1157ebad810aa17355c1543641dcf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 2 Aug 2021 01:47:20 +0200 Subject: [PATCH 13/18] Remove commented code --- cmake/modules/FindOpusFile.cmake | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cmake/modules/FindOpusFile.cmake b/cmake/modules/FindOpusFile.cmake index 9d1fc40c27e..f537f48837e 100644 --- a/cmake/modules/FindOpusFile.cmake +++ b/cmake/modules/FindOpusFile.cmake @@ -81,12 +81,6 @@ if(OpusFile_FOUND) INTERFACE_COMPILE_OPTIONS "${OpusFile_DEFINITIONS}" INTERFACE_INCLUDE_DIRECTORIES "${OpusFile_INCLUDE_DIRS}" ) - is_static_library(OpusFile_IS_STATIC OpusFile::OpusFile) - #if(OpusFile_IS_STATIC) - # find_package(Opus REQUIRED) - # set_property(TARGET OpusFile::OpusFile APPEND PROPERTY INTERFACE_LINK_LIBRARIES - # Opus::Opus - # ) #endif() endif() endif() From 82f58de15c727ead114aa79b4a3fb894643c042b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 2 Aug 2021 07:04:24 +0200 Subject: [PATCH 14/18] fix typo Co-authored-by: Be --- cmake/modules/FindKeyFinder.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/FindKeyFinder.cmake b/cmake/modules/FindKeyFinder.cmake index bde3668ab88..b4af4ea49e8 100644 --- a/cmake/modules/FindKeyFinder.cmake +++ b/cmake/modules/FindKeyFinder.cmake @@ -87,7 +87,7 @@ if(KeyFinder_FOUND) is_static_library(KeyFinder_IS_STATIC KeyFinder::KeyFinder) if(KeyFinder_IS_STATIC) find_package(FFTW REQUIRED) - set_property(TARGET Chromaprint::Chromaprint APPEND PROPERTY INTERFACE_LINK_LIBRARIES + set_property(TARGET KeyFinder::KeyFinder APPEND PROPERTY INTERFACE_LINK_LIBRARIES FFTW::FFTW ) endif() From 5f87ce6c46934a0d6fd2e8c6881ad6e0066c4765 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 4 Aug 2021 23:20:23 +0200 Subject: [PATCH 15/18] added FOLLOW_SYMLINK_CHAIN to install fdk-aac --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84f0a158f09..671f7a9f19b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2493,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. From b333ea2cf0243b40fdf8dfb7e0fdeef7e363ec4f Mon Sep 17 00:00:00 2001 From: Be Date: Thu, 5 Aug 2021 06:09:30 -0700 Subject: [PATCH 16/18] add missing space --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 671f7a9f19b..c81d49777f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1788,7 +1788,7 @@ target_link_libraries(mixxx-lib PRIVATE Chromaprint::Chromaprint) # Locale Aware Compare for SQLite find_package(SQLite3) -# For LOCALECOMPAREwe call directly sqlite functions to the database opened by +# 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 SQLite, can be installed and linked From ee94ec55241acd065966f18352b4a822e3705956 Mon Sep 17 00:00:00 2001 From: Be Date: Thu, 5 Aug 2021 06:10:14 -0700 Subject: [PATCH 17/18] typos --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c81d49777f5..a6dc5ee4722 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1791,7 +1791,7 @@ 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 SQLite, can be installed and linked +# 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) From 2af3fef7ccda37011c2f618111ae47a303c0d7ba Mon Sep 17 00:00:00 2001 From: Be Date: Thu, 5 Aug 2021 06:15:16 -0700 Subject: [PATCH 18/18] delete commented code --- cmake/modules/FindOpusFile.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/modules/FindOpusFile.cmake b/cmake/modules/FindOpusFile.cmake index f537f48837e..65f00e63430 100644 --- a/cmake/modules/FindOpusFile.cmake +++ b/cmake/modules/FindOpusFile.cmake @@ -81,6 +81,5 @@ if(OpusFile_FOUND) INTERFACE_COMPILE_OPTIONS "${OpusFile_DEFINITIONS}" INTERFACE_INCLUDE_DIRECTORIES "${OpusFile_INCLUDE_DIRS}" ) - #endif() endif() endif()