-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Feature request: thirdparty libs should be linkable from system installed #11572
Comments
I'm assigning this a priority and Beta 1 release. Will need conversations with the devs here about when to do it.... however, any community members who would like to take it on would be appreciated! |
We have decided to move this to 4.x. We'll be reopening it when 4.0 is released. |
I'm interested in building 4.x, but would prefer to link to system libs (esp. freetype and opus). My distribution (linux) has a build template for 3.6 which seems to use |
Webengine is no longer needed indeed. (Instead, you do need QtNetworkAuthorization.) |
See also #16948 |
I tried to work on making musescore link to system fluidsynth, and I noticed that musescore uses a lot of private functions from the fluidsynth's src... When one installs FluidSynth, by default it includes only:
Here's an example of an error I got:
After applying this rather simple patch:diff --git i/CMakeLists.txt w/CMakeLists.txt
index 621c62126f..e984112959 100644
--- i/CMakeLists.txt
+++ w/CMakeLists.txt
@@ -123,6 +123,7 @@ option(MUE_COMPILE_USE_UNITY "Use unity build." ON)
option(MUE_COMPILE_USE_CCACHE "Try use ccache" ON)
option(MUE_COMPILE_USE_SHARED_LIBS_IN_DEBUG "Build shared libs if possible in debug" OFF)
option(MUE_COMPILE_USE_SYSTEM_FREETYPE "Try use system freetype" OFF) # Important for the maintainer of Linux distributions
+option(MUE_COMPILE_USE_SYSTEM_FLUIDSYNTH "Try use system fluidsynth library" OFF) # Important for the maintainer of Linux distributions
# === Debug ===
option(MUE_ENABLE_LOGGER_DEBUGLEVEL "Enable logging debug level" ON)
diff --git i/src/framework/audio/CMakeLists.txt w/src/framework/audio/CMakeLists.txt
index 6293730784..20ca5e6625 100644
--- i/src/framework/audio/CMakeLists.txt
+++ w/src/framework/audio/CMakeLists.txt
@@ -69,7 +69,6 @@ elseif(OS_IS_WASM)
)
endif()
-add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/fluidsynth fluidsynth)
set(MODULE_SRC
@@ -224,22 +223,35 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/synthesizers/synthresolver.h
)
-set(FLUIDSYNTH_DIR ${PROJECT_SOURCE_DIR}/thirdparty/fluidsynth/fluidsynth-2.1.4)
-set (FLUIDSYNTH_INC
- ${FLUIDSYNTH_DIR}/include
- ${FLUIDSYNTH_DIR}/src
- ${FLUIDSYNTH_DIR}/src/external
- ${FLUIDSYNTH_DIR}/src/utils
- ${FLUIDSYNTH_DIR}/src/midi
- ${FLUIDSYNTH_DIR}/src/rvoice
- ${FLUIDSYNTH_DIR}/src/sfloader
- ${FLUIDSYNTH_DIR}/src/bindings
- ${FLUIDSYNTH_DIR}/src/synth
- ${FLUIDSYNTH_DIR}/src/drivers
- )
+if (MUE_COMPILE_USE_SYSTEM_FLUIDSYNTH)
+ find_package(PkgConfig)
+ pkg_check_modules(FLUIDSYNTH REQUIRED fluidsynth)
+ if (FLUIDSYNTH_FOUND)
+ message(STATUS "Found fluidsynth: ${FLUIDSYNTH_VERSION}")
+ message(STATUS "Found fluidsynth include dirs: ${FLUIDSYNTH_VERSION}")
+ else()
+ message(FATAL_ERROR "Set MUE_COMPILE_USE_SYSTEM_FLUIDSYNTH=ON, but system fluidsynth not found")
+ endif()
+endif()
+if (NOT FLUIDSYNTH_FOUND)
+ add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/fluidsynth fluidsynth)
+ set(FLUIDSYNTH_DIR ${PROJECT_SOURCE_DIR}/thirdparty/fluidsynth/fluidsynth-2.1.4)
+ set (FLUIDSYNTH_INCLUDE_DIRS
+ ${FLUIDSYNTH_DIR}/include
+ ${FLUIDSYNTH_DIR}/src
+ ${FLUIDSYNTH_DIR}/src/external
+ ${FLUIDSYNTH_DIR}/src/utils
+ ${FLUIDSYNTH_DIR}/src/midi
+ ${FLUIDSYNTH_DIR}/src/rvoice
+ ${FLUIDSYNTH_DIR}/src/sfloader
+ ${FLUIDSYNTH_DIR}/src/bindings
+ ${FLUIDSYNTH_DIR}/src/synth
+ ${FLUIDSYNTH_DIR}/src/drivers
+ )
+endif()
set (MODULE_INCLUDE
- ${FLUIDSYNTH_INC}
+ ${FLUIDSYNTH_INCLUDE_DIRS}
)
set(MODULE_LINK @cbjeukendrup Are you aware of this private functions usage? I was wondering whether you'd interesting of avoiding it. |
Yes, I'm aware of it (part of it was added by me recently), and if we could avoid it in a relatively painless way that would be great, but I'm not sure if that's doable. Using those |
Maybe upstream would agree to expose these functions? |
That's certainly worth asking. Especially since FluidSynth still seems to be maintained / developed actively. I'll create an issue (or even a PR, why not) in their repo. |
Another attempt report, for flac this time: I tried to make musescore use a system's flac library, using this patch: Patchdiff --git c/CMakeLists.txt w/CMakeLists.txt
index 621c62126f..96ca7b88b9 100644
--- c/CMakeLists.txt
+++ w/CMakeLists.txt
@@ -123,6 +123,7 @@ option(MUE_COMPILE_USE_UNITY "Use unity build." ON)
option(MUE_COMPILE_USE_CCACHE "Try use ccache" ON)
option(MUE_COMPILE_USE_SHARED_LIBS_IN_DEBUG "Build shared libs if possible in debug" OFF)
option(MUE_COMPILE_USE_SYSTEM_FREETYPE "Try use system freetype" OFF) # Important for the maintainer of Linux distributions
+option(MUE_COMPILE_USE_SYSTEM_FLAC "Try use system flac" OFF) # Important for the maintainer of Linux distributions
# === Debug ===
option(MUE_ENABLE_LOGGER_DEBUGLEVEL "Enable logging debug level" ON)
diff --git c/build/module.cmake w/build/module.cmake
index 32ad9033e3..12229a7e7e 100644
--- c/build/module.cmake
+++ w/build/module.cmake
@@ -143,3 +143,5 @@ set(MODULE_LINK ${QT_LIBRARIES} ${MODULE_LINK})
set(MODULE_LINK ${CMAKE_DL_LIBS} ${MODULE_LINK})
target_link_libraries(${MODULE} PRIVATE ${MODULE_LINK} )
+
+set_target_properties(${MODULE} PROPERTIES LINK_FLAGS "${MODULE_LDFLAGS}")
diff --git c/src/framework/audio/CMakeLists.txt w/src/framework/audio/CMakeLists.txt
index 6293730784..25b06b5e0a 100644
--- c/src/framework/audio/CMakeLists.txt
+++ w/src/framework/audio/CMakeLists.txt
@@ -268,7 +268,18 @@ if (MUE_ENABLE_AUDIO_EXPORT)
add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/lame lame)
add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/opusenc opusenc)
- add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/flac flac)
+ if (MUE_COMPILE_USE_SYSTEM_FLAC)
+ find_package(PkgConfig)
+ pkg_check_modules(FLAC REQUIRED flac)
+ if (NOT FLAC_FOUND)
+ message(FATAL_ERROR "Set MUE_COMPILE_USE_SYSTEM_FLAC=ON, but system FLAC not found, built-in will be used")
+ endif()
+ endif()
+ if (FLAC_FOUND)
+ set(MODULE_LDFLAGS "${FLAC_LDFLAGS}")
+ else()
+ add_subdirectory(${PROJECT_SOURCE_DIR}/thirdparty/flac flac)
+ endif()
set(MODULE_LINK ${MODULE_LINK} lame opusenc flac)
endif() And the build fails with:
This one should be easier to solve, I'm just not familiar with the |
The reason that the line |
That makes sense. I started to use
And more... In |
I'm not sure why the output from pkg_check_modules is not used directly, but it seems to be the case in many places where pkg_check_modules is used, so perhaps that's the way to do it... Perhaps that is the cause of the link failure, but that's difficult to say... In this case, I don't think we are using private functions or doing something unusual. |
Gentoo user working on building MuseScore 4.1.1 here. A prior ebuild had a patch which replaced a few third-party libraries with system libraries, which appears to be what you're looking for. As mentioned above, I did observe that MuseScore uses fluidsynth internals, so it's probably not possible to use system fluidsynth without changes there. This patch is for v4.1.1, but should be very close to what you want (some cmake logic will be required, I assume). |
Thanks for the help @Theofghy :) Your usage of
All of the changes that worked for me, are available in #19795 . |
Just to summarize, after #19795, the following libraries will lack support for using a system version:
|
Add cmake options to use thirdparty libs
A lot of hte libs in thirdparty/* should have flags in cmake to enable the use of system packages, i.e.:
It tries to install headers from opus currently:
The text was updated successfully, but these errors were encountered: