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

macOS static build support #4163

merged 18 commits into from
Aug 5, 2021

Conversation

daschuer
Copy link
Member

This is the collection of changes that are required to build MacOs statically with VCPKG support.
This also still builds dynamically with the current environment.

@github-actions github-actions bot added the build label Jul 31, 2021
CMakeLists.txt Outdated
Comment on lines 2145 to 2156
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}
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Aren't these handled elsewhere in CMakeLists.txt?

Copy link
Member Author

Choose a reason for hiding this comment

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

I have tried to get rid of some of them but these are the remaining bits.

@coveralls
Copy link

coveralls commented Jul 31, 2021

Pull Request Test Coverage Report for Build 1101583044

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 36 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.003%) to 26.023%

Files with Coverage Reduction New Missed Lines %
src/engine/cachingreader/cachingreaderworker.cpp 2 63.48%
src/engine/readaheadmanager.cpp 2 88.79%
src/controllers/scripting/controllerscriptenginebase.cpp 32 40.74%
Totals Coverage Status
Change from base Build 1100644322: -0.003%
Covered Lines: 20016
Relevant Lines: 76916

💛 - Coveralls

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
find_package(lv2 CONFIG REQUIRED)
find_package(lv2)

Are you sure CONFIG must be forced?

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

These libraries do not ship CMake config modules. Those come from vcpkg. So I think CONFIG REQUIRED can only work if the static lilv library comes from vcpkg.

Copy link
Contributor

Choose a reason for hiding this comment

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

The config module for lilv in vcpkg should already search for these libraries...
https://github.com/microsoft/vcpkg/blob/261c458af6e3eed5d099144aff95d2b5035f656b/ports/lilv/CMakeLists.txt#L84

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Why shouldn't we rely on that?

Copy link
Contributor

@uklotzde uklotzde Jul 31, 2021

Choose a reason for hiding this comment

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

Because it is to be considered an implementation detail that might change at any time.

Example: All crate dependencies in Rust are private. If I need a dependency myself I have to declare it explicitly. Cargo then will figure out if a single, shared version could be used or if multiple different versions are needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

We should use PUBLIC only for our own, static libs that are just an intermediate build artifact and no deployment unit.

Copy link
Contributor

Choose a reason for hiding this comment

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

I disagree. Downstream applications should not be responsible for manually linking all the transient dependencies of their dependencies. IMO that indicates a bug in either the library's build system or the vcpkg port.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then this was a misunderstanding. Of course, not manually link unless we use transient dependencies elsewhere!

CMakeLists.txt Outdated
target_link_libraries(mixxx-lib PRIVATE ${COREFOUNDATION_LIBRARY})
if(QT5_TYPE STREQUAL "STATIC_LIBRARY")
find_package(FFTW REQUIRED)
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

CMakeLists.txt Outdated
if(QT5_TYPE STREQUAL "STATIC_LIBRARY")
find_package(FFTW REQUIRED)
find_package(SndFile REQUIRED)
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

@Be-ing Be-ing changed the title OSX static build macOS static build support Jul 31, 2021
CMakeLists.txt Outdated Show resolved Hide resolved
@Be-ing
Copy link
Contributor

Be-ing commented Jul 31, 2021

Windows build failed???

 [763/870] Automatic MOC for target mixxx-test
FAILED: mixxx-test_autogen/timestamp 
cmd.exe /C "cd /D D:\a\mixxx\mixxx\build && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E cmake_autogen D:/a/mixxx/mixxx/build/CMakeFiles/mixxx-test_autogen.dir/AutogenInfo.json RelWithDebInfo && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E touch D:/a/mixxx/mixxx/build/mixxx-test_autogen/timestamp && "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E cmake_transform_depfile Ninja gccdepfile D:/a/mixxx/mixxx D:/a/mixxx/mixxx D:/a/mixxx/mixxx/build D:/a/mixxx/mixxx/build D:/a/mixxx/mixxx/build/mixxx-test_autogen/deps D:/a/mixxx/mixxx/build/CMakeFiles/d/fd30099103cc38c9d949ff52ba949bf29cca78df1ae23494c1a9032d94f5cfbc.d"

CMakeLists.txt Outdated
find_package(FFTW REQUIRED)
find_package(SndFile REQUIRED)
find_package(sord CONFIG 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.

CMakeLists.txt Outdated

if(APPLE)
if(QT5_TYPE STREQUAL "STATIC_LIBRARY")
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.

Co-authored-by: Be <be.0@gmx.com>
@daschuer
Copy link
Member Author

daschuer commented Aug 1, 2021

This is mergeable now. There was a bug in the static library detection. This is fixed now with a new module.

CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
find_package(sord CONFIG REQUIRED)
find_package(sord REQUIRED)

Copy link
Member Author

@daschuer daschuer Aug 1, 2021

Choose a reason for hiding this comment

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

As already mentioned, this is how it is called in the lilv CMakeList.txt both place need to be use the same method.
See: https://github.com/microsoft/vcpkg/blob/261c458af6e3eed5d099144aff95d2b5035f656b/ports/lilv/CMakeLists.txt#L6

Copy link
Contributor

Choose a reason for hiding this comment

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

This means this CMake module can only work with vcpkg because the upstream library does not ship a CMake config module.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Holzhaus what are your thoughts on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ping @Holzhaus, this is all that is left on this PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

We want the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

The context here is different. This module might be copied into another application which doesn't use vcpkg and has its own Findsord.cmake module. Hardcoding CONFIG would break that. I don't think there's a good reason to make this code less flexible by doing that.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't care about writing the module to use it in other applications, sorry.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is more about the general principle not to hardcode unnecessary assumptions. Anyway I am done bikeshedding this. If anyone really needs to change it, it would simply be deleting a single word.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Be-ing
Copy link
Contributor

Be-ing commented Aug 1, 2021

It would be good to get manual testing of this on Windows and macOS to confirm there are no regressions.

CMakeLists.txt Outdated Show resolved Hide resolved
daschuer and others added 2 commits August 2, 2021 01:41
Co-authored-by: Be <be.0@gmx.com>
Co-authored-by: Be <be.0@gmx.com>
@foss-
Copy link
Contributor

foss- commented Aug 3, 2021

It would be good to get manual testing of this on Windows and macOS to confirm there are no regressions.

macOS 11.5.1, 2.4-alpha-724-gfecab7c1db (HEAD)

No regressions noticeable.

CMakeLists.txt Outdated
if(FDK_AAC_LIBRARY)
message(STATUS "Found fdk-aac: ${FDK_AAC_LIBRARY}")
install(FILES ${FDK_AAC_LIBRARY} DESTINATION ${MIXXX_INSTALL_PREFIX}/Contents/Frameworks)
install(FILES ${FDK_AAC_LIBRARY} DESTINATION ${MIXXX_INSTALL_PREFIX}/Contents/Frameworks FOLLOW_SYMLINK_CHAIN)
Copy link
Contributor

Choose a reason for hiding this comment

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

I remember using this then reverting it when we initially added fdk-aac but I do not remember why I reverted it.

CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
@Be-ing Be-ing merged commit c21aec2 into mixxxdj:main Aug 5, 2021
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Fixed in #4185

Be-ing added a commit to Be-ing/mixxx that referenced this pull request Aug 6, 2021
Be-ing added a commit to Be-ing/mixxx that referenced this pull request Aug 6, 2021
ronso0 pushed a commit to ronso0/mixxx that referenced this pull request Sep 24, 2021
* Move Apple extra linking to the block where extra linking is defined for the other targets as well

* Added additional libraries required for static linking on macOs

* Remove unneeded extra Apple link dependencies for the non static case

* Added Qt5::PrintSupport needed for MacOS linking

* Add Support for VCPKG_OVERLAY_TRIPLETS

* Improve cmake find modules for static linking

* Remove obsolete STATIC_DEPS parameter

* Enable LOCALECOMPARE option for static linking on macOS and fix ENGINEPRIME relationship
  with SQLite
ronso0 pushed a commit to ronso0/mixxx that referenced this pull request Sep 24, 2021
@fwcd fwcd added the macos label Jan 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants