--- CMakeLists.txt	2026-05-01 07:44:06.000000000 +0800
+++ CMakeLists.txt	2026-05-17 07:47:07.000000000 +0800
@@ -148,9 +148,9 @@
 
 # JACK is most commonly used on Linux, but it is cross platform, so allow building it on any OS
 # if the FindJACK.cmake module finds POSIX headers.
-find_package(JACK)
-cmake_dependent_option(PA_USE_JACK "Enable support for JACK Audio Connection Kit" ON JACK_FOUND OFF)
+option(PA_USE_JACK "Enable support for JACK Audio Connection Kit" OFF)
 if(PA_USE_JACK)
+  find_package(JACK REQUIRED)
   target_link_libraries(portaudio PRIVATE JACK::jack)
   target_sources(portaudio PRIVATE
     src/hostapi/jack/pa_jack.c
@@ -168,6 +168,23 @@
   install(FILES cmake/modules/FindJACK.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/portaudio/modules")
 endif()
 
+option(PA_USE_PULSEAUDIO "Enable support for PulseAudio general purpose sound server" OFF)
+if(PA_USE_PULSEAUDIO)
+  find_package(PulseAudio REQUIRED)
+  target_link_libraries(portaudio PRIVATE PulseAudio::PulseAudio)
+  target_sources(portaudio PRIVATE
+    src/hostapi/pulseaudio/pa_linux_pulseaudio_block.c
+    src/hostapi/pulseaudio/pa_linux_pulseaudio.c
+    src/hostapi/pulseaudio/pa_linux_pulseaudio_cb.c)
+
+  target_compile_definitions(portaudio PUBLIC PA_USE_PULSEAUDIO=1)
+  set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -DPA_USE_PULSEAUDIO=1")
+  set(PKGCONFIG_REQUIRES_PRIVATE "${PKGCONFIG_REQUIRES_PRIVATE} libpulse")
+
+  # needed for PortAudioConfig.cmake so `find_package(PortAudio)` works in downstream projects
+  install(FILES cmake/modules/FindPulseAudio.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/portaudio/modules")
+endif()
+
 if(WIN32)
   target_sources(portaudio PRIVATE
     src/os/win/pa_win_coinitialize.c
@@ -345,9 +362,9 @@
       "${PKGCONFIG_LDFLAGS_PRIVATE} -framework CoreAudio -framework AudioToolbox -framework AudioUnit -framework CoreFoundation -framework CoreServices")
   else()
     # Some BSDs have a reimplementation of alsalib, so do not explicitly check for Linux.
-    find_package(ALSA)
-    cmake_dependent_option(PA_USE_ALSA "Enable support for ALSA" ON ALSA_FOUND OFF)
+    cmake_dependent_option(PA_USE_ALSA "Enable support for ALSA" OFF)
     if(PA_USE_ALSA)
+      find_package(ALSA REQUIRED)
       target_sources(portaudio PRIVATE src/hostapi/alsa/pa_linux_alsa.c)
       set(PORTAUDIO_PUBLIC_HEADERS "${PORTAUDIO_PUBLIC_HEADERS}" include/pa_linux_alsa.h)
       target_compile_definitions(portaudio PUBLIC PA_USE_ALSA=1)
@@ -367,9 +384,9 @@
     # OSS is intentionally off by default to avoid confusing users of PortAudio
     # applications. OSS builds but there are no devices available on modern
     # Linux systems.
-    find_package(OSS)
-    cmake_dependent_option(PA_USE_OSS "Enable support for OSS" OFF "OSS_FOUND" OFF)
+    option(PA_USE_OSS "Enable support for OSS" OFF)
     if(PA_USE_OSS)
+      find_package(OSS REQUIRED)
       target_sources(portaudio PRIVATE src/hostapi/oss/pa_unix_oss.c)
       target_compile_definitions(portaudio PUBLIC PA_USE_OSS=1)
       set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -DPA_USE_OSS=1")
@@ -386,26 +403,9 @@
       set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -DPA_USE_AUDIOIO=1")
     endif()
 
-    find_package(PulseAudio)
-    cmake_dependent_option(PA_USE_PULSEAUDIO "Enable support for PulseAudio general purpose sound server" ON PulseAudio_FOUND OFF)
-    if(PA_USE_PULSEAUDIO)
-      target_link_libraries(portaudio PRIVATE PulseAudio::PulseAudio)
-      target_sources(portaudio PRIVATE
-        src/hostapi/pulseaudio/pa_linux_pulseaudio_block.c
-        src/hostapi/pulseaudio/pa_linux_pulseaudio.c
-        src/hostapi/pulseaudio/pa_linux_pulseaudio_cb.c)
-
-      target_compile_definitions(portaudio PUBLIC PA_USE_PULSEAUDIO=1)
-      set(PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS} -DPA_USE_PULSEAUDIO=1")
-      set(PKGCONFIG_REQUIRES_PRIVATE "${PKGCONFIG_REQUIRES_PRIVATE} libpulse")
-
-      # needed for PortAudioConfig.cmake so `find_package(PortAudio)` works in downstream projects
-      install(FILES cmake/modules/FindPulseAudio.cmake DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/portaudio/modules")
-    endif()
-
+    option(PA_USE_SNDIO "Enable support for sndio" OFF)
     pkg_check_modules(SNDIO sndio)
-    cmake_dependent_option(PA_USE_SNDIO "Enable support for sndio" ON SNDIO_FOUND OFF)
-    if(PA_USE_SNDIO)
+    if(SNDIO_FOUND AND PA_USE_SNDIO)
       target_link_libraries(portaudio PRIVATE "${SNDIO_LIBRARIES}")
       target_sources(portaudio PRIVATE src/hostapi/sndio/pa_sndio.c)
       target_compile_definitions(portaudio PUBLIC PA_USE_SNDIO=1)
