Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS static build support #4163

Merged
merged 18 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 5 additions & 38 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
63 changes: 0 additions & 63 deletions cmake/modules/FindCelt.cmake

This file was deleted.

13 changes: 13 additions & 0 deletions cmake/modules/FindChromaprint.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
8 changes: 8 additions & 0 deletions cmake/modules/FindFLAC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
7 changes: 7 additions & 0 deletions cmake/modules/FindKeyFinder.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
37 changes: 13 additions & 24 deletions cmake/modules/FindOpus.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
90 changes: 90 additions & 0 deletions cmake/modules/FindOpusFile.cmake
Original file line number Diff line number Diff line change
@@ -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()
Loading