CMake ignores -DUSE_PULSEAUDIO=OFF
I'm trying to build Musescore without pulseaudio support. I have added -DUSE_PULSEAUDIO=OFF to the cmake command, but cmake manages to find some old compatibility libraries I have lying around and decides to use pulseaudio anyway. (And since I don't have the headers for these libraries, the compilation fails).
c012358e711c9445f81b55900e124e00c0eff2f1 patched to show USE_PULSEAUDIO value at beginning and end of CMakeLists.txt:
message("USE_PULSEAUDIO=${USE_PULSEAUDIO}")
$ cmake .. -DUSE_PULSEAUDIO=OFF 2>&1 | grep -i pulse USE_PULSEAUDIO=OFF -- checking for module 'libpulse' -- package 'libpulse' not found -- Found pulseaudio: /usr/lib32/libpulse.so Pulseaudio found. USE_PULSEAUDIO=1
The offending code:
##
## pulseaudio
##
if (APPLE OR MINGW)
set (USE_PULSEAUDIO 0)
else (APPLE OR MINGW)
if (PULSEAUDIO_FOUND)
set(USE_PULSEAUDIO 1)
message("Pulseaudio found.")
else (PULSEAUDIO_FOUND)
set(USE_PULSEAUDIO 0)
message("Pulseaudio not found.")
endif (PULSEAUDIO_FOUND)
endif (APPLE OR MINGW)
Is this variable not meant to be user-settable? Can you change it to be user-settable?
(Interestingly, FindPulseAudio reports pulseaudio as found even though the include dir is not found. But it is a separate issue.
PULSEAUDIO_LIBRARY=/usr/lib32/libpulse.so PULSEAUDIO_INCLUDE_DIR=PULSEAUDIO_INCLUDE_DIR-NOTFOUND
)
//Thomas Axelsson
Comments
I have been looking some more at CMakeLists.txt, and I see that other optionals have the BUILD_ prefix, so I created a patch with BUILD_PULSEAUDIO. It behaves the same as BUILD_LAME: default ON but silently turns off Pulseaudio support if Pulseaudio is not found/supported.
edit.
Diff without whitespace changes:
git show -w ... diff --git a/CMakeLists.txt b/CMakeLists.txt index 86eed5e..6ffb9fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,7 @@ option(BUILD_LAME "enable mp3 export" ON) # requires libmp3 SET(JACK_LONGNAME "jack (jack audio connection kit)") SET(JACK_MIN_VERSION "0.98.0") option(BUILD_JACK "Build with support for ${JACK_LONGNAME}. jack >= ${JACK_MIN_VERSION} will be needed." ON) +option(BUILD_PULSEAUDIO "Build with support for Pulseaudio." ON) if (APPLE) set (CMAKE_CXX_COMPILER clang++) @@ -222,6 +223,7 @@ endif (APPLE OR MINGW) ## pulseaudio ## +if (BUILD_PULSEAUDIO) if (APPLE OR MINGW) set (USE_PULSEAUDIO 0) else (APPLE OR MINGW) @@ -233,6 +235,9 @@ else (APPLE OR MINGW) message("Pulseaudio not found.") endif (PULSEAUDIO_FOUND) endif (APPLE OR MINGW) +else (BUILD_PULSEAUDIO) + message(STATUS "Pulseaudio support disabled.") +endif (BUILD_PULSEAUDIO) ## ## lamePull request PR #2333
https://github.com/musescore/MuseScore/pull/2333
Related Gentoo bug report: https://bugs.gentoo.org/show_bug.cgi?id=570588
Fixed in branch master, commit 413fdc3a1c
fix #92521: make pulseaudio support optional
Fixed in branch master, commit 937d977ea1
Merge pull request #2333 from thomasa88/92521-optional-pulseaudio
fix #92521: make pulseaudio support optional
Fixed in branch 2.0.3, commit 647c4161e7
fix #92521: make pulseaudio support optional
Automatically closed -- issue fixed for 2 weeks with no activity.