CMake ignores -DUSE_PULSEAUDIO=OFF

• Jan 2, 2016 - 11:07
Type
Functional
Severity
S4 - Minor
Status
closed
Project

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)
 
 ##
 ## lame