summaryrefslogtreecommitdiff
path: root/Modules/FindSDL_sound.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/FindSDL_sound.cmake')
-rw-r--r--Modules/FindSDL_sound.cmake144
1 files changed, 78 insertions, 66 deletions
diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake
index efd26580b..cf33a4c2c 100644
--- a/Modules/FindSDL_sound.cmake
+++ b/Modules/FindSDL_sound.cmake
@@ -1,73 +1,84 @@
-# - Locates the SDL_sound library
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#.rst:
+# FindSDL_sound
+# -------------
+#
+# Locates the SDL_sound library
+#
#
-# This module depends on SDL being found and
-# must be called AFTER FindSDL.cmake is called.
+#
+# This module depends on SDL being found and must be called AFTER
+# FindSDL.cmake is called.
#
# This module defines
-# SDL_SOUND_INCLUDE_DIR, where to find SDL_sound.h
-# SDL_SOUND_FOUND, if false, do not try to link to SDL_sound
-# SDL_SOUND_LIBRARIES, this contains the list of libraries that you need
-# to link against. This is a read-only variable and is marked INTERNAL.
-# SDL_SOUND_EXTRAS, this is an optional variable for you to add your own
-# flags to SDL_SOUND_LIBRARIES. This is prepended to SDL_SOUND_LIBRARIES.
-# This is available mostly for cases this module failed to anticipate for
-# and you must add additional flags. This is marked as ADVANCED.
-# SDL_SOUND_VERSION_STRING, human-readable string containing the version of SDL_sound
+#
+# ::
+#
+# SDL_SOUND_INCLUDE_DIR, where to find SDL_sound.h
+# SDL_SOUND_FOUND, if false, do not try to link to SDL_sound
+# SDL_SOUND_LIBRARIES, this contains the list of libraries that you need
+# to link against.
+# SDL_SOUND_EXTRAS, this is an optional variable for you to add your own
+# flags to SDL_SOUND_LIBRARIES. This is prepended to SDL_SOUND_LIBRARIES.
+# This is available mostly for cases this module failed to anticipate for
+# and you must add additional flags. This is marked as ADVANCED.
+# SDL_SOUND_VERSION_STRING, human-readable string containing the
+# version of SDL_sound
+#
+#
#
# This module also defines (but you shouldn't need to use directly)
-# SDL_SOUND_LIBRARY, the name of just the SDL_sound library you would link
-# against. Use SDL_SOUND_LIBRARIES for you link instructions and not this one.
+#
+# ::
+#
+# SDL_SOUND_LIBRARY, the name of just the SDL_sound library you would link
+# against. Use SDL_SOUND_LIBRARIES for you link instructions and not this one.
+#
# And might define the following as needed
-# MIKMOD_LIBRARY
-# MODPLUG_LIBRARY
-# OGG_LIBRARY
-# VORBIS_LIBRARY
-# SMPEG_LIBRARY
-# FLAC_LIBRARY
-# SPEEX_LIBRARY
#
-# Typically, you should not use these variables directly, and you should use
-# SDL_SOUND_LIBRARIES which contains SDL_SOUND_LIBRARY and the other audio libraries
-# (if needed) to successfully compile on your system.
+# ::
#
-# Created by Eric Wing.
-# This module is a bit more complicated than the other FindSDL* family modules.
-# The reason is that SDL_sound can be compiled in a large variety of different ways
-# which are independent of platform. SDL_sound may dynamically link against other 3rd
-# party libraries to get additional codec support, such as Ogg Vorbis, SMPEG, ModPlug,
-# MikMod, FLAC, Speex, and potentially others.
-# Under some circumstances which I don't fully understand,
-# there seems to be a requirement
-# that dependent libraries of libraries you use must also be explicitly
-# linked against in order to successfully compile. SDL_sound does not currently
-# have any system in place to know how it was compiled.
-# So this CMake module does the hard work in trying to discover which 3rd party
-# libraries are required for building (if any).
-# This module uses a brute force approach to create a test program that uses SDL_sound,
-# and then tries to build it. If the build fails, it parses the error output for
-# known symbol names to figure out which libraries are needed.
+# MIKMOD_LIBRARY
+# MODPLUG_LIBRARY
+# OGG_LIBRARY
+# VORBIS_LIBRARY
+# SMPEG_LIBRARY
+# FLAC_LIBRARY
+# SPEEX_LIBRARY
#
-# Responds to the $SDLDIR and $SDLSOUNDDIR environmental variable that would
-# correspond to the ./configure --prefix=$SDLDIR used in building SDL.
#
-# On OSX, this will prefer the Framework version (if found) over others.
-# People will have to manually change the cache values of
-# SDL_LIBRARY to override this selectionor set the CMake environment
-# CMAKE_INCLUDE_PATH to modify the search paths.
-
-#=============================================================================
-# Copyright 2005-2009 Kitware, Inc.
-# Copyright 2012 Benjamin Eikel
#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
+# Typically, you should not use these variables directly, and you should
+# use SDL_SOUND_LIBRARIES which contains SDL_SOUND_LIBRARY and the other
+# audio libraries (if needed) to successfully compile on your system.
#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
+# Created by Eric Wing. This module is a bit more complicated than the
+# other FindSDL* family modules. The reason is that SDL_sound can be
+# compiled in a large variety of different ways which are independent of
+# platform. SDL_sound may dynamically link against other 3rd party
+# libraries to get additional codec support, such as Ogg Vorbis, SMPEG,
+# ModPlug, MikMod, FLAC, Speex, and potentially others. Under some
+# circumstances which I don't fully understand, there seems to be a
+# requirement that dependent libraries of libraries you use must also be
+# explicitly linked against in order to successfully compile. SDL_sound
+# does not currently have any system in place to know how it was
+# compiled. So this CMake module does the hard work in trying to
+# discover which 3rd party libraries are required for building (if any).
+# This module uses a brute force approach to create a test program that
+# uses SDL_sound, and then tries to build it. If the build fails, it
+# parses the error output for known symbol names to figure out which
+# libraries are needed.
+#
+# Responds to the $SDLDIR and $SDLSOUNDDIR environmental variable that
+# would correspond to the ./configure --prefix=$SDLDIR used in building
+# SDL.
+#
+# On OSX, this will prefer the Framework version (if found) over others.
+# People will have to manually change the cache values of SDL_LIBRARY to
+# override this selectionor set the CMake environment CMAKE_INCLUDE_PATH
+# to modify the search paths.
set(SDL_SOUND_EXTRAS "" CACHE STRING "SDL_sound extra flags")
mark_as_advanced(SDL_SOUND_EXTRAS)
@@ -77,7 +88,9 @@ find_path(SDL_SOUND_INCLUDE_DIR SDL_sound.h
HINTS
ENV SDLSOUNDDIR
ENV SDLDIR
- PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
+ PATH_SUFFIXES SDL
+ # path suffixes to search inside ENV{SDLDIR}
+ include/SDL include/SDL12 include/SDL11 include
)
find_library(SDL_SOUND_LIBRARY
@@ -85,7 +98,7 @@ find_library(SDL_SOUND_LIBRARY
HINTS
ENV SDLSOUNDDIR
ENV SDLDIR
- PATH_SUFFIXES lib
+ PATH_SUFFIXES lib VisualC/win32lib
)
if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
@@ -99,7 +112,7 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
# To get multiple single variables to work, I must separate them with a "\;"
# I could go back and modify the FindSDL.cmake module, but that's kind of painful.
# The solution would be to try something like:
- # set(SDL_TRY_COMPILE_LIBRARY_LIST "${SDL_TRY_COMPILE_LIBRARY_LIST}\;${CMAKE_THREAD_LIBS_INIT}")
+ # string(APPEND SDL_TRY_COMPILE_LIBRARY_LIST "\;${CMAKE_THREAD_LIBS_INIT}")
# Instead, it was suggested on the mailing list to write a temporary CMakeLists.txt
# with a temporary test project and invoke that with TRY_COMPILE.
# See message thread "Figuring out dependencies for a library in order to build"
@@ -149,7 +162,7 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
# would fix the problem.
set(TMP_TRY_LIBS)
foreach(lib ${SDL_SOUND_LIBRARY} ${SDL_LIBRARY})
- set(TMP_TRY_LIBS "${TMP_TRY_LIBS} \"${lib}\"")
+ string(APPEND TMP_TRY_LIBS " \"${lib}\"")
endforeach()
# message("TMP_TRY_LIBS ${TMP_TRY_LIBS}")
@@ -160,7 +173,7 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
# in the SDL_LIBRARY string after the "-framework".
# But if I quote the stuff in INCLUDE_DIRECTORIES, it doesn't work.
file(WRITE ${PROJECT_BINARY_DIR}/CMakeTmp/CMakeLists.txt
- "cmake_minimum_required(VERSION 2.8)
+ "cmake_minimum_required(VERSION ${CMAKE_VERSION})
project(DetermineSoundLibs)
include_directories(${SDL_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR})
add_executable(DetermineSoundLibs DetermineSoundLibs.c)
@@ -354,11 +367,10 @@ if(SDL_FOUND AND SDL_SOUND_INCLUDE_DIR AND SDL_SOUND_LIBRARY)
endif()
endif()
+ set(SDL_SOUND_LIBRARIES ${SDL_SOUND_EXTRAS} ${SDL_SOUND_LIBRARIES_TMP})
else()
- set(SDL_SOUND_LIBRARIES "${SDL_SOUND_EXTRAS} ${SDL_SOUND_LIBRARY}" CACHE INTERNAL "SDL_sound and dependent libraries")
+ set(SDL_SOUND_LIBRARIES ${SDL_SOUND_EXTRAS} ${SDL_SOUND_LIBRARY})
endif()
-
- set(SDL_SOUND_LIBRARIES "${SDL_SOUND_EXTRAS} ${SDL_SOUND_LIBRARIES_TMP}" CACHE INTERNAL "SDL_sound and dependent libraries")
endif()
if(SDL_SOUND_INCLUDE_DIR AND EXISTS "${SDL_SOUND_INCLUDE_DIR}/SDL_sound.h")