-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
…for the other targets as well
…PRIME relationship
CMakeLists.txt
Outdated
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} | ||
) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Pull Request Test Coverage Report for Build 1101583044
💛 - Coveralls |
cmake/modules/Findlilv.cmake
Outdated
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find_package(lv2 CONFIG REQUIRED) | |
find_package(lv2) |
Are you sure CONFIG
must be forced?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is taken from here:
https://github.com/microsoft/vcpkg/blob/261c458af6e3eed5d099144aff95d2b5035f656b/ports/lilv/CMakeLists.txt#L4
and it works.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the issue is that some are linked PRIVATE?
https://github.com/microsoft/vcpkg/blob/261c458af6e3eed5d099144aff95d2b5035f656b/ports/lilv/CMakeLists.txt#L54
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handled by Findlilv.cmake
Windows build failed???
|
CMakeLists.txt
Outdated
find_package(FFTW REQUIRED) | ||
find_package(SndFile REQUIRED) | ||
find_package(sord CONFIG REQUIRED) | ||
find_library(SAMPLERATE_LIBRARY samplerate REQUIRED) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rubberband uses libsamplerate
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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>
This is mergeable now. There was a bug in the static library detection. This is fixed now with a new module. |
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find_package(sord CONFIG REQUIRED) | |
find_package(sord REQUIRED) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want the same.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have asked about upstreaming these CMake build scripts.
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) |
There was a problem hiding this comment.
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.
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this caused the issue reported on here? https://mixxx.zulipchat.com/#narrow/stream/247620-development-help/topic/cmake.20fails.20with.20Could.20NOT.20find.20Protobuf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in #4185
This was broken by the refactoring for building with static libraries (c21aec2 mixxxdj#4163): mixxxdj#4163 (comment) https://mixxx.zulipchat.com/#narrow/stream/247620-development-help/topic/cmake.20fails.20with.20Could.20NOT.20find.20Protobuf
This was broken by the refactoring for building with static libraries (c21aec2 mixxxdj#4163): mixxxdj#4163 (comment) https://mixxx.zulipchat.com/#narrow/stream/247620-development-help/topic/cmake.20fails.20with.20Could.20NOT.20find.20Protobuf
* 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
This was broken by the refactoring for building with static libraries (c21aec2 mixxxdj#4163): mixxxdj#4163 (comment) https://mixxx.zulipchat.com/#narrow/stream/247620-development-help/topic/cmake.20fails.20with.20Could.20NOT.20find.20Protobuf
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.