11 # SDL_FOUND, if false, do not try to link to SDL
12 # SDL_LIBRARY, the name(s) of the library(ies) to link against
13 # SDL_LIBSDL, the full path and name of libSDL (or SDL.[lib|dll].
14 # SDL_LIBSDLMAIN, full path and name of libSDLmain (or SDLmain.lib).
15 # SDL_LIBRARY_PATH, the full path to the found libSDL
16 # SDL_INCLUDE_DIR, where to find SDL.h
17 # SDL_VERSION_STRING, human-readable string containing the version of SDL
21 # This module responds to the flag:
25 # SDL_BUILDING_LIBRARY
26 # If this is defined, then no SDL_main will be linked in because
27 # only applications need main().
28 # Otherwise, it is assumed you are building an application and this
29 # module will attempt to locate and set the proper link flags
30 # as part of the returned SDL_LIBRARY variable.
34 # Don't forget to include SDLmain.h and SDLmain.m your project for the
35 # OS X framework based version. (Other versions link to -lSDLmain which
36 # this module will try to find on your behalf.) Also for OS X, this
37 # module will automatically add the -framework Cocoa on your behalf.
41 # Additional Note: If you see an empty SDL_LIBSDL in your
42 # configuration and no SDL_LIBRARY, it means CMake did not find your SDL
43 # library (SDL.dll, libsdl.so, SDL.framework, etc). Set
44 # SDL_LIBSDL to point to your SDL library, and configure again.
45 # Similarly, if you see an empty SDL_LIBSDLMAIN, you should set this
46 # value as appropriate. These values are used to generate the final
47 # SDL_LIBRARY variable, but when these values are unset, SDL_LIBRARY
48 # does not get created.
52 # $SDLDIR is an environment variable that would correspond to the
53 # ./configure --prefix=$SDLDIR used in building SDL. l.e.galup 9-20-02
55 # Modified by Eric Wing. Added code to assist with automated building
56 # by using environmental variables and providing a more
57 # controlled/consistent search behavior. Added new modifications to
58 # recognize OS X frameworks and additional Unix paths (FreeBSD, etc).
59 # Also corrected the header search path to follow "proper" SDL
60 # guidelines. Added a search for SDLmain which is needed by some
61 # platforms. Added a search for threads which is needed by some
62 # platforms. Added needed compile switches for MinGW.
64 # On OSX, this will prefer the Framework version (if found) over others.
65 # People will have to manually change the cache values of SDL_LIBRARY to
66 # override this selection or set the CMake environment
67 # CMAKE_INCLUDE_PATH to modify the search paths.
69 # Note that the header path has changed from SDL/SDL.h to just SDL.h
70 # This needed to change because "proper" SDL convention is #include
71 # "SDL.h", not <SDL/SDL.h>. This is done for portability reasons
72 # because not all systems place things in SDL/ (see FreeBSD).
75 # Modified for OpenTx by Maxim Paperno 19-Dec-2016
76 # Added SDL_LIBSDL, SDL_LIBSDLMAIN & SDL_LIBRARY_PATH, removed SDLMAIN_LIBRARY,
77 # SDL_LIBRARY_TEMP, and fixed bug with recursive appending of supporting
78 # libraries to cached SDL_LIBRARY_TEMP variable.
81 #=============================================================================
82 #CMake - Cross Platform Makefile Generator
83 #Copyright 2000-2015 Kitware, Inc.
84 #Copyright 2000-2011 Insight Software Consortium
87 #Redistribution and use in source and binary forms, with or without
88 #modification, are permitted provided that the following conditions
91 #* Redistributions of source code must retain the above copyright
92 # notice, this list of conditions and the following disclaimer.
94 #* Redistributions in binary form must reproduce the above copyright
95 # notice, this list of conditions and the following disclaimer in the
96 # documentation and/or other materials provided with the distribution.
98 #* Neither the names of Kitware, Inc., the Insight Software Consortium,
99 # nor the names of their contributors may be used to endorse or promote
100 # products derived from this software without specific prior written
103 #THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
104 #"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
105 #LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
106 #A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
107 #HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
108 #SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
109 #LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
110 #DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
111 #THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
112 #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
113 #OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
115 #------------------------------------------------------------------------------
117 #The above copyright and license notice applies to distributions of
118 #CMake in source and binary form. Some source files contain additional
119 #notices of original copyright by their contributors; see each source
120 #for details. Third-party software packages supplied with CMake under
121 #compatible licenses provide their own copyright notices documented in
122 #corresponding subdirectories.
124 #------------------------------------------------------------------------------
126 #CMake was initially developed by Kitware with the following sponsorship:
128 # * National Library of Medicine at the National Institutes of Health
129 # as part of the Insight Segmentation and Registration Toolkit (ITK).
131 # * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
132 # Visualization Initiative.
134 # * National Alliance for Medical Image Computing (NAMIC) is funded by the
135 # National Institutes of Health through the NIH Roadmap for Medical Research,
136 # Grant U54 EB005149.
139 #=============================================================================
142 find_path(SDL_INCLUDE_DIR SDL.h
145 PATH_SUFFIXES SDL SDL12 SDL11
146 # path suffixes to search inside ENV{SDLDIR}
147 include/SDL include/SDL12 include/SDL11 include
150 if(CMAKE_SIZEOF_VOID_P EQUAL 8)
151 set(VC_LIB_PATH_SUFFIX lib/x64)
153 set(VC_LIB_PATH_SUFFIX lib/x86)
156 # SDL-1.1 is the name used by FreeBSD ports...
157 # don't confuse it for the version number.
158 find_library(SDL_LIBSDL
162 PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
165 # Non-OS X framework versions expect you to also dynamically link to
166 # SDLmain. This is mainly for Windows and OS X. Other (Unix) platforms
167 # seem to provide SDLmain for compatibility even though they don't
168 # necessarily need it.
169 find_library(SDL_LIBSDLMAIN
170 NAMES SDLmain SDLmain-1.1
173 PATH_SUFFIXES lib ${VC_LIB_PATH_SUFFIX}
181 # SDL may require threads on your system.
182 # The Apple build may not need an explicit flag because one of the
183 # frameworks may already provide it.
184 # But for non-OSX systems, I will use the CMake Threads package.
186 find_package(Threads)
189 # MinGW needs an additional library, mwindows
190 # It's total link flags should look like -lmingw32 -lSDLmain -lSDL
192 set(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
197 if(SDL_LIBSDLMAIN AND NOT SDL_BUILDING_LIBRARY AND NOT SDL_INCLUDE_DIR MATCHES ".framework")
198 list(FIND SDL_LIBSDL "${SDL_LIBSDLMAIN}" _SDL_MAIN_INDEX)
199 if(_SDL_MAIN_INDEX EQUAL -1)
200 list(APPEND _SDL_LIBRARY_TEMP "${SDL_LIBSDLMAIN}")
202 unset(_SDL_MAIN_INDEX)
205 list(APPEND _SDL_LIBRARY_TEMP "${SDL_LIBSDL}")
207 # For OS X, SDL uses Cocoa as a backend so it must link to Cocoa.
208 # CMake doesn't display the -framework Cocoa string in the UI even
209 # though it actually is there if I modify a pre-used variable.
210 # I think it has something to do with the CACHE STRING.
211 # So I use a temporary variable until the end so I can set the
212 # "real" variable in one-shot.
214 list(APPEND _SDL_LIBRARY_TEMP "-framework Cocoa")
218 list(APPEND _SDL_LIBRARY_TEMP ${CMAKE_THREAD_LIBS_INIT})
221 # MinGW needs an additional library, mwindows
222 # It's total link flags should look like -lmingw32 -lSDLmain -lSDL
224 list(INSERT 0 _SDL_LIBRARY_TEMP mingw32)
227 # Set the final string here so the GUI reflects the final state.
228 set(SDL_LIBRARY ${_SDL_LIBRARY_TEMP} CACHE STRING "Full list of required SDL & supporting libraries.")
229 unset(_SDL_LIBRARY_TEMP)
231 get_filename_component(_SDL_LIBRARY_TEMP ${SDL_LIBSDL} PATH)
232 set(SDL_LIBRARY_PATH ${_SDL_LIBRARY_TEMP} CACHE PATH "Path to SDL library.")
233 unset(_SDL_LIBRARY_TEMP)
236 if(SDL_INCLUDE_DIR AND EXISTS "${SDL_INCLUDE_DIR}/SDL_version.h")
237 file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$")
238 file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$")
239 file(STRINGS "${SDL_INCLUDE_DIR}/SDL_version.h" SDL_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$")
240 string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MAJOR "${SDL_VERSION_MAJOR_LINE}")
241 string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL_VERSION_MINOR "${SDL_VERSION_MINOR_LINE}")
242 string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL_VERSION_PATCH "${SDL_VERSION_PATCH_LINE}")
243 set(SDL_VERSION_STRING ${SDL_VERSION_MAJOR}.${SDL_VERSION_MINOR}.${SDL_VERSION_PATCH})
244 unset(SDL_VERSION_MAJOR_LINE)
245 unset(SDL_VERSION_MINOR_LINE)
246 unset(SDL_VERSION_PATCH_LINE)
247 unset(SDL_VERSION_MAJOR)
248 unset(SDL_VERSION_MINOR)
249 unset(SDL_VERSION_PATCH)
252 include(FindPackageHandleStandardArgs)
254 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL
255 REQUIRED_VARS SDL_LIBRARY SDL_LIBRARY_PATH SDL_INCLUDE_DIR
256 VERSION_VAR SDL_VERSION_STRING)