diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindSDL2_Mixer.cmake | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/cmake/FindSDL2_Mixer.cmake b/cmake/FindSDL2_Mixer.cmake new file mode 100644 index 0000000..1d9778c --- /dev/null +++ b/cmake/FindSDL2_Mixer.cmake | |||
@@ -0,0 +1,100 @@ | |||
1 | # Locate SDL_MIXER library | ||
2 | # | ||
3 | # This module defines: | ||
4 | # | ||
5 | # :: | ||
6 | # | ||
7 | # SDL2_MIXER_LIBRARIES, the name of the library to link against | ||
8 | # SDL2_MIXER_INCLUDE_DIRS, where to find the headers | ||
9 | # SDL2_MIXER_FOUND, if false, do not try to link against | ||
10 | # SDL2_MIXER_VERSION_STRING - human-readable string containing the version of SDL_MIXER | ||
11 | # | ||
12 | # | ||
13 | # | ||
14 | # For backward compatibility the following variables are also set: | ||
15 | # | ||
16 | # :: | ||
17 | # | ||
18 | # SDLMIXER_LIBRARY (same value as SDL2_MIXER_LIBRARIES) | ||
19 | # SDLMIXER_INCLUDE_DIR (same value as SDL2_MIXER_INCLUDE_DIRS) | ||
20 | # SDLMIXER_FOUND (same value as SDL2_MIXER_FOUND) | ||
21 | # | ||
22 | # | ||
23 | # | ||
24 | # $SDLDIR is an environment variable that would correspond to the | ||
25 | # ./configure --prefix=$SDLDIR used in building SDL. | ||
26 | # | ||
27 | # Created by Eric Wing. This was influenced by the FindSDL.cmake | ||
28 | # module, but with modifications to recognize OS X frameworks and | ||
29 | # additional Unix paths (FreeBSD, etc). | ||
30 | |||
31 | #============================================================================= | ||
32 | # Copyright 2005-2009 Kitware, Inc. | ||
33 | # Copyright 2012 Benjamin Eikel | ||
34 | # | ||
35 | # Distributed under the OSI-approved BSD License (the "License"); | ||
36 | # see accompanying file Copyright.txt for details. | ||
37 | # | ||
38 | # This software is distributed WITHOUT ANY WARRANTY; without even the | ||
39 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
40 | # See the License for more information. | ||
41 | #============================================================================= | ||
42 | # (To distribute this file outside of CMake, substitute the full | ||
43 | # License text for the above reference.) | ||
44 | |||
45 | find_path(SDL2_MIXER_INCLUDE_DIR SDL_mixer.h | ||
46 | HINTS | ||
47 | ENV SDL2MIXERDIR | ||
48 | ENV SDL2DIR | ||
49 | PATH_SUFFIXES SDL2 | ||
50 | # path suffixes to search inside ENV{SDLDIR} | ||
51 | include/SDL2 include | ||
52 | PATHS ${SDL2_MIXER_PATH} | ||
53 | ) | ||
54 | |||
55 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
56 | set(VC_LIB_PATH_SUFFIX lib/x64) | ||
57 | else() | ||
58 | set(VC_LIB_PATH_SUFFIX lib/x86) | ||
59 | endif() | ||
60 | |||
61 | find_library(SDL2_MIXER_LIBRARY | ||
62 | NAMES SDL2_mixer | ||
63 | HINTS | ||
64 | ENV SDL2MIXERDIR | ||
65 | ENV SDL2DIR | ||
66 | PATH_SUFFIXES lib bin ${VC_LIB_PATH_SUFFIX} | ||
67 | PATHS ${SDL2_MIXER_PATH} | ||
68 | ) | ||
69 | |||
70 | if(SDL2_MIXER_INCLUDE_DIR AND EXISTS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h") | ||
71 | file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+[0-9]+$") | ||
72 | file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+[0-9]+$") | ||
73 | file(STRINGS "${SDL2_MIXER_INCLUDE_DIR}/SDL_mixer.h" SDL2_MIXER_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+[0-9]+$") | ||
74 | string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MAJOR "${SDL2_MIXER_VERSION_MAJOR_LINE}") | ||
75 | string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_MINOR "${SDL2_MIXER_VERSION_MINOR_LINE}") | ||
76 | string(REGEX REPLACE "^#define[ \t]+SDL_MIXER_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_MIXER_VERSION_PATCH "${SDL2_MIXER_VERSION_PATCH_LINE}") | ||
77 | set(SDL2_MIXER_VERSION_STRING ${SDL2_MIXER_VERSION_MAJOR}.${SDL2_MIXER_VERSION_MINOR}.${SDL2_MIXER_VERSION_PATCH}) | ||
78 | unset(SDL2_MIXER_VERSION_MAJOR_LINE) | ||
79 | unset(SDL2_MIXER_VERSION_MINOR_LINE) | ||
80 | unset(SDL2_MIXER_VERSION_PATCH_LINE) | ||
81 | unset(SDL2_MIXER_VERSION_MAJOR) | ||
82 | unset(SDL2_MIXER_VERSION_MINOR) | ||
83 | unset(SDL2_MIXER_VERSION_PATCH) | ||
84 | endif() | ||
85 | |||
86 | set(SDL2_MIXER_LIBRARIES ${SDL2_MIXER_LIBRARY}) | ||
87 | set(SDL2_MIXER_INCLUDE_DIRS ${SDL2_MIXER_INCLUDE_DIR}) | ||
88 | |||
89 | include(FindPackageHandleStandardArgs) | ||
90 | |||
91 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2_mixer | ||
92 | REQUIRED_VARS SDL2_MIXER_LIBRARIES SDL2_MIXER_INCLUDE_DIRS | ||
93 | VERSION_VAR SDL2_MIXER_VERSION_STRING) | ||
94 | |||
95 | # for backward compatibility | ||
96 | set(SDLMIXER_LIBRARY ${SDL2_MIXER_LIBRARIES}) | ||
97 | set(SDLMIXER_INCLUDE_DIR ${SDL2_MIXER_INCLUDE_DIRS}) | ||
98 | set(SDLMIXER_FOUND ${SDL2_MIXER_FOUND}) | ||
99 | |||
100 | mark_as_advanced(SDL2_MIXER_LIBRARY SDL2_MIXER_INCLUDE_DIR) | ||