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
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
50 changes: 31 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Be-ing marked this conversation as resolved.
Show resolved Hide resolved
# 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
Be-ing marked this conversation as resolved.
Show resolved Hide resolved
# 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")
Be-ing marked this conversation as resolved.
Show resolved Hide resolved
# in the static case we need to link SQlite3 uncoditionally
daschuer marked this conversation as resolved.
Show resolved Hide resolved
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)
Expand All @@ -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()
Expand Down Expand Up @@ -2135,13 +2165,11 @@ if(APPLE)
find_package(FFTW REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this needed for?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromaprint and Rubberband, unfortunately setting INTERFACE_LINK_LIBRARIES is not sufficient.

find_package(SndFile REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already linked below

find_package(sord CONFIG REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handled by Findlilv.cmake

find_package(SQLite3 REQUIRED)
find_library(SAMPLERATE_LIBRARY samplerate REQUIRED)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused... Mixxx doesn't use libsamplerate?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rubberband uses libsamplerate

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...and Rubberband also needs FFTW, depending on the build config. Rubberband 1.9.2 comes with its own, optimized FFT code that doesn't require external dependencies.

target_link_libraries(mixxx-lib PRIVATE
FFTW::FFTW
SndFile::sndfile
sord::sord
${SQLite3_LIBRARIES}
${SAMPLERATE_LIBRARY}
)
target_link_libraries(mixxx-lib PRIVATE
Expand Down Expand Up @@ -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)
Expand Down