From e3395a75858373ddea040aca2ea210dff2dbead7 Mon Sep 17 00:00:00 2001 From: Robert Edmonds Date: Sat, 6 Apr 2024 12:19:55 -0400 Subject: [PATCH] cmake: Fix ALSA "Unable to find..." warning If cmake is invoked with -DSDL_ALSA=OFF, the misleading warning message "Unable to find the alsa development library" is printed. It's misleading because no attempt was actually made to find the ALSA development library. It's always printed by the CheckALSA macro if SDL_ALSA is false. This commit moves this warning message in the CheckALSA macro to being printed if ALSA_FOUND is false. However, I don't see an explicit warning message like this for the other macros that search for development libraries, so I wonder if the message shouldn't just be removed entirely. It seems redundant with the "Could NOT find ALSA ..." message generated by cmake. Before this commit: $ cmake -B build -DSDL_ALSA=OFF [...] CMake Warning at cmake/sdlchecks.cmake:125 (message): Unable to find the alsa development library Call Stack (most recent call first): CMakeLists.txt:1530 (CheckALSA) [...] -- Options: -- SDL_ALSA (Wanted: OFF): OFF [...] $ cmake -B build -DSDL_ALSA=ON [...] -- Could NOT find ALSA (missing: ALSA_LIBRARY ALSA_INCLUDE_DIR) [...] -- Options: -- SDL_ALSA (Wanted: ON): OFF [...] After this commit: $ cmake -B build -DSDL_ALSA=OFF [...] -- Options: -- SDL_ALSA (Wanted: OFF): OFF [...] $ cmake -B build -DSDL_ALSA=ON [...] -- Could NOT find ALSA (missing: ALSA_LIBRARY ALSA_INCLUDE_DIR) CMake Warning at cmake/sdlchecks.cmake:123 (message): Unable to find the alsa development library Call Stack (most recent call first): CMakeLists.txt:1530 (CheckALSA) [...] -- Options: -- SDL_ALSA (Wanted: ON): OFF [...] All of the cmake invocations above were without the libasound2-dev package installed. --- cmake/sdlchecks.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake index 6a12b3049..0f1480f18 100644 --- a/cmake/sdlchecks.cmake +++ b/cmake/sdlchecks.cmake @@ -119,10 +119,11 @@ macro(CheckALSA) sdl_link_dependency(alsa LIBS ALSA::ALSA CMAKE_MODULE ALSA PKG_CONFIG_SPECS "${ALSA_PKG_CONFIG_SPEC}") endif() set(HAVE_SDL_AUDIO TRUE) + else() + message(WARNING "Unable to find the alsa development library") endif() else() set(HAVE_ALSA FALSE) - message(WARNING "Unable to find the alsa development library") endif() endmacro()