diff --git a/CMakeModules/Find/FindSDL2_mixer.cmake b/CMakeModules/Find/FindSDL2_mixer.cmake index 3042b074c0824..469c7ea4591b7 100644 --- a/CMakeModules/Find/FindSDL2_mixer.cmake +++ b/CMakeModules/Find/FindSDL2_mixer.cmake @@ -96,22 +96,30 @@ set(SDL2MIXER_FOUND ${SDL2_MIXER_FOUND}) mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR) -if(NOT DYNAMIC_LINKING AND PKGCONFIG_FOUND) +if(NOT DYNAMIC_LINKING) if (NOT TARGET SDL2_mixer::SDL2_mixer-static) add_library(SDL2_mixer::SDL2_mixer-static STATIC IMPORTED) set_property(TARGET SDL2_mixer::SDL2_mixer-static PROPERTY IMPORTED_LOCATION ${SDL2_MIXER_LIBRARY} ) endif() - message(STATUS "Searching for SDL_mixer deps libraries --") - pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac) - target_link_libraries(SDL2_mixer::SDL2_mixer-static INTERFACE - PkgConfig::FLAC - ) elseif(NOT TARGET SDL2_mixer::SDL2_mixer) add_library(SDL2_mixer::SDL2_mixer STATIC IMPORTED) set_property(TARGET SDL2_mixer::SDL2_mixer PROPERTY IMPORTED_LOCATION ${SDL2_MIXER_LIBRARY} ) +endif() -endif() \ No newline at end of file +if(PKG_CONFIG_FOUND) + message(STATUS "Searching for SDL_mixer deps libraries --") + pkg_check_modules(FLAC REQUIRED IMPORTED_TARGET flac) + if(TARGET SDL2_mixer::SDL2_mixer-static) + target_link_libraries(SDL2_mixer::SDL2_mixer-static INTERFACE + PkgConfig::FLAC + ) + elseif(TARGET SDL2_mixer::SDL2_mixer) + target_link_libraries(SDL2_mixer::SDL2_mixer INTERFACE + PkgConfig::FLAC + ) + endif() +endif()