cmake_modules/FindSDL2_mixer.cmake
author Wuzzy <Wuzzy2@mail.ru>
Wed, 07 Mar 2018 15:09:31 +0100
changeset 13089 c9cdbf630447
parent 12383 e3d9abcc427a
permissions -rw-r--r--
Stop SplitByChar also lowercasing the entire string. Fixes bug #581. It's weird that a function with this name would lowercase the whole string. Nemo and I have checked the history and code for any justifications of the lowercasing but we found none. I have checked in the code if anything actually depends on SplitByChar also lowercasing the string but I found nothing. It would surprise me since it's not obvious from the name IMO is bad coding practice anyway. Bug 581 is fixed by this because cLocale was (incorrectly) lowercased, which broke locale names like pt_BR to pt_br.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9677
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
     1
# - Locate SDL2_mixer library
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
     2
# This module defines:
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
     3
#  SDL2_MIXER_LIBRARIES, the name of the library to link against
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
     4
#  SDL2_MIXER_INCLUDE_DIRS, where to find the headers
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
     5
#  SDL2_MIXER_FOUND, if false, do not try to link against
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
     6
#  SDL2_MIXER_VERSION_STRING - human-readable string containing the version of SDL2_mixer
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
     7
#
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
     8
# For backward compatiblity the following variables are also set:
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
     9
#  SDL2MIXER_LIBRARY (same value as SDL2_MIXER_LIBRARIES)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    10
#  SDL2MIXER_INCLUDE_DIR (same value as SDL2_MIXER_INCLUDE_DIRS)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    11
#  SDL2MIXER_FOUND (same value as SDL2_MIXER_FOUND)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    12
#
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    13
# $SDL2DIR is an environment variable that would
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    14
# correspond to the ./configure --prefix=$SDL2DIR
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    15
# used in building SDL2.
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    16
#
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    17
# Created by Eric Wing. This was influenced by the FindSDL2.cmake
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    18
# module, but with modifications to recognize OS X frameworks and
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    19
# additional Unix paths (FreeBSD, etc).
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    20
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    21
#=============================================================================
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    22
# Copyright 2005-2009 Kitware, Inc.
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    23
# Copyright 2012 Benjamin Eikel
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    24
#
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    25
# Distributed under the OSI-approved BSD License (the "License");
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    26
# see accompanying file Copyright.txt for details.
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    27
#
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    28
# This software is distributed WITHOUT ANY WARRANTY; without even the
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    29
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    30
# See the License for more information.
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    31
#=============================================================================
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    32
# (To distribute this file outside of CMake, substitute the full
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    33
#  License text for the above reference.)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    34
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    35
if(NOT SDL2_MIXER_INCLUDE_DIR AND SDL2MIXER_INCLUDE_DIR)
12383
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11657
diff changeset
    36
  set(SDL2_MIXER_INCLUDE_DIR ${SDL2MIXER_INCLUDE_DIR} CACHE PATH "directory cache entry initialized from old variable name")
9677
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    37
endif()
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    38
find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    39
  HINTS
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    40
    ENV SDL2MIXERDIR
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    41
    ENV SDL2DIR
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    42
  PATH_SUFFIXES include/SDL2 include
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    43
)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    44
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    45
if(NOT SDL2_MIXER_LIBRARY AND SDL2MIXER_LIBRARY)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    46
  set(SDL2_MIXER_LIBRARY ${SDL2MIXER_LIBRARY} CACHE FILEPATH "file cache entry
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    47
initialized from old variable name")
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    48
endif()
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    49
find_library(SDL2_MIXER_LIBRARY
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    50
  NAMES SDL2_mixer
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    51
  HINTS
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    52
    ENV SDL2MIXERDIR
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    53
    ENV SDL2DIR
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    54
  PATH_SUFFIXES lib
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    55
)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    56
12383
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11657
diff changeset
    57
if(SDL2_MIXER_INCLUDE_DIR AND EXISTS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h")
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11657
diff changeset
    58
  file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+[0-9]+$")
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11657
diff changeset
    59
  file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+[0-9]+$")
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11657
diff changeset
    60
  file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+[0-9]+$")
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11657
diff changeset
    61
  string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MAJOR "${SDL2_MIXER_VERSION_MAJOR_LINE}")
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11657
diff changeset
    62
  string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MINOR "${SDL2_MIXER_VERSION_MINOR_LINE}")
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11657
diff changeset
    63
  string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_PATCH "${SDL2_MIXER_VERSION_PATCH_LINE}")
9677
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    64
  set(SDL2_MIXER_VERSION_STRING ${SDL2_MIXER_VERSION_MAJOR}.${SDL2_MIXER_VERSION_MINOR}.${SDL2_MIXER_VERSION_PATCH})
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    65
  unset(SDL2_MIXER_VERSION_MAJOR_LINE)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    66
  unset(SDL2_MIXER_VERSION_MINOR_LINE)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    67
  unset(SDL2_MIXER_VERSION_PATCH_LINE)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    68
  unset(SDL2_MIXER_VERSION_MAJOR)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    69
  unset(SDL2_MIXER_VERSION_MINOR)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    70
  unset(SDL2_MIXER_VERSION_PATCH)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    71
endif()
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    72
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    73
set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY})
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    74
set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR})
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    75
11657
ae6706411b24 Hijack SDL2 and GLEW include and library when compiling to javascript
koda
parents: 9677
diff changeset
    76
if(BUILD_ENGINE_JS)
ae6706411b24 Hijack SDL2 and GLEW include and library when compiling to javascript
koda
parents: 9677
diff changeset
    77
    set(SDL2_MIXER_LIBRARY "sdl2_mixer_emscripten_internal")
ae6706411b24 Hijack SDL2 and GLEW include and library when compiling to javascript
koda
parents: 9677
diff changeset
    78
    set(SDL2_MIXER_LIBRARIES "sdl2_mixer_emscripten_internal")
ae6706411b24 Hijack SDL2 and GLEW include and library when compiling to javascript
koda
parents: 9677
diff changeset
    79
    set(SDL2_MIXER_INCLUDE_DIRS "${CMAKE_SYSTEM_INCLUDE_PATH}/SDL")
ae6706411b24 Hijack SDL2 and GLEW include and library when compiling to javascript
koda
parents: 9677
diff changeset
    80
endif()
ae6706411b24 Hijack SDL2 and GLEW include and library when compiling to javascript
koda
parents: 9677
diff changeset
    81
9677
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    82
include(FindPackageHandleStandardArgs)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    83
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    84
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    85
                                  REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    86
                                  VERSION_VAR SDL2_MIXER_VERSION_STRING)
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    87
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    88
# for backward compatiblity
12383
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11657
diff changeset
    89
set(SDLMIXER_LIBRARY ${SDL2_MIXER_LIBRARIES})
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11657
diff changeset
    90
set(SDLMIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS})
e3d9abcc427a cmake: Fix SDL2 header version detection
sheepluva
parents: 11657
diff changeset
    91
set(SDLMIXER_FOUND ${SDL2_MIXER_FOUND})
9677
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    92
71626318f80e - Use USESDL12 for old SDL
unc0rr
parents:
diff changeset
    93
mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR)