From dca3e6bc397c8e97b21c807d2d22af7aef70f74b Mon Sep 17 00:00:00 2001 From: "Amine B. Hassouna" Date: Sun, 3 Feb 2019 09:57:32 +0100 Subject: [PATCH] Modernize FindSDL2_mixer.cmake (SDL2::Mixer) --- FindSDL2_mixer.cmake | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/FindSDL2_mixer.cmake b/FindSDL2_mixer.cmake index 8bafb17..5f58319 100644 --- a/FindSDL2_mixer.cmake +++ b/FindSDL2_mixer.cmake @@ -7,6 +7,16 @@ FindSDL2_mixer Locate SDL2_mixer library +This module defines the following 'IMPORTED' target: + +:: + + SDL2::Mixer + The SDL2_mixer library, if found. + Have SDL2::Core as a link dependency. + + + This module will set the following variables in your project: :: @@ -40,8 +50,9 @@ Additional Note: If you see an empty SDL2_MIXER_LIBRARY in your project configuration, it means CMake did not find your SDL2_mixer library (SDL2_mixer.dll, libsdl2_mixer.so, etc). Set SDL2_MIXER_LIBRARY to point to your SDL2_mixer library, and configure again. This value is used to -generate the final SDL2_MIXER_LIBRARIES variable, but when this value is -unset, SDL2_MIXER_LIBRARIES does not get created. +generate the final SDL2_MIXER_LIBRARIES variable and the SDL2::Mixer target, +but when this value is unset, SDL2_MIXER_LIBRARIES and SDL2::Mixer does not +get created. $SDL2MIXERDIR is an environment variable that would correspond to the @@ -57,6 +68,8 @@ Created by Amine Ben Hassouna: Add cache variables for more flexibility: SDL2_MIXER_PATH, SDL2_MIXER_NO_DEFAULT_PATH (for details, see doc above). Add SDL2 as a required dependency. + Modernize the FindSDL2_mixer.cmake module by creating a specific target: + SDL2::Mixer (for details, see doc above). Original FindSDL_mixer.cmake module: Created by Eric Wing. This was influenced by the FindSDL.cmake @@ -162,3 +175,15 @@ mark_as_advanced(SDL2_MIXER_PATH SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR) + +if(SDL2_MIXER_FOUND) + + # SDL2::Mixer target + if(SDL2_MIXER_LIBRARY AND NOT TARGET SDL2::Mixer) + add_library(SDL2::Mixer UNKNOWN IMPORTED) + set_target_properties(SDL2::Mixer PROPERTIES + IMPORTED_LOCATION "${SDL2_MIXER_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${SDL2_MIXER_INCLUDE_DIR}" + INTERFACE_LINK_LIBRARIES SDL2::Core) + endif() +endif()