OpenCores
URL https://opencores.org/ocsvn/s80186/s80186/trunk

Subversion Repositories s80186

[/] [s80186/] [trunk/] [CMake/] [FindSDL2.cmake] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jamieiles
 
2
# This module defines
3
# SDL2_LIBRARY, the name of the library to link against
4
# SDL2_FOUND, if false, do not try to link to SDL2
5
# SDL2_INCLUDE_DIR, where to find SDL.h
6
#
7
# This module responds to the the flag:
8
# SDL2_BUILDING_LIBRARY
9
# If this is defined, then no SDL2main will be linked in because
10
# only applications need main().
11
# Otherwise, it is assumed you are building an application and this
12
# module will attempt to locate and set the the proper link flags
13
# as part of the returned SDL2_LIBRARY variable.
14
#
15
# Don't forget to include SDLmain.h and SDLmain.m your project for the
16
# OS X framework based version. (Other versions link to -lSDL2main which
17
# this module will try to find on your behalf.) Also for OS X, this
18
# module will automatically add the -framework Cocoa on your behalf.
19
#
20
#
21
# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
22
# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library
23
# (SDL2.dll, libsdl2.so, SDL2.framework, etc).
24
# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again.
25
# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
26
# as appropriate. These values are used to generate the final SDL2_LIBRARY
27
# variable, but when these values are unset, SDL2_LIBRARY does not get created.
28
#
29
#
30
# $SDL2DIR is an environment variable that would
31
# correspond to the ./configure --prefix=$SDL2DIR
32
# used in building SDL2.
33
# l.e.galup  9-20-02
34
#
35
# Modified by Eric Wing.
36
# Added code to assist with automated building by using environmental variables
37
# and providing a more controlled/consistent search behavior.
38
# Added new modifications to recognize OS X frameworks and
39
# additional Unix paths (FreeBSD, etc).
40
# Also corrected the header search path to follow "proper" SDL guidelines.
41
# Added a search for SDL2main which is needed by some platforms.
42
# Added a search for threads which is needed by some platforms.
43
# Added needed compile switches for MinGW.
44
#
45
# On OSX, this will prefer the Framework version (if found) over others.
46
# People will have to manually change the cache values of
47
# SDL2_LIBRARY to override this selection or set the CMake environment
48
# CMAKE_INCLUDE_PATH to modify the search paths.
49
#
50
# Note that the header path has changed from SDL2/SDL.h to just SDL.h
51
# This needed to change because "proper" SDL convention
52
# is #include "SDL.h", not . This is done for portability
53
# reasons because not all systems place things in SDL2/ (see FreeBSD).
54
 
55
#=============================================================================
56
# CMake - Cross Platform Makefile Generator
57
# Copyright 2000-2016 Kitware, Inc.
58
# Copyright 2000-2011 Insight Software Consortium
59
# All rights reserved.
60
#
61
# Redistribution and use in source and binary forms, with or without
62
# modification, are permitted provided that the following conditions
63
# are met:
64
#
65
# * Redistributions of source code must retain the above copyright
66
#   notice, this list of conditions and the following disclaimer.
67
#
68
# * Redistributions in binary form must reproduce the above copyright
69
#   notice, this list of conditions and the following disclaimer in the
70
#   documentation and/or other materials provided with the distribution.
71
#
72
# * Neither the names of Kitware, Inc., the Insight Software Consortium,
73
#   nor the names of their contributors may be used to endorse or promote
74
#   products derived from this software without specific prior written
75
#   permission.
76
#
77
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
78
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
79
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
80
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
81
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
82
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
83
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
84
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
85
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
86
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
87
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
88
#
89
# ------------------------------------------------------------------------------
90
#
91
# The above copyright and license notice applies to distributions of
92
# CMake in source and binary form.  Some source files contain additional
93
# notices of original copyright by their contributors; see each source
94
# for details.  Third-party software packages supplied with CMake under
95
# compatible licenses provide their own copyright notices documented in
96
# corresponding subdirectories.
97
#
98
# ------------------------------------------------------------------------------
99
#
100
# CMake was initially developed by Kitware with the following sponsorship:
101
#
102
#  * National Library of Medicine at the National Institutes of Health
103
#    as part of the Insight Segmentation and Registration Toolkit (ITK).
104
#
105
#  * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
106
#    Visualization Initiative.
107
#
108
#  * National Alliance for Medical Image Computing (NAMIC) is funded by the
109
#    National Institutes of Health through the NIH Roadmap for Medical Research,
110
#    Grant U54 EB005149.
111
#
112
#  * Kitware, Inc.
113
#=============================================================================
114
 
115
SET(SDL2_SEARCH_PATHS
116
        ~/Library/Frameworks
117
        /Library/Frameworks
118
        /usr/local
119
        /usr
120
        /sw # Fink
121
        /opt/local # DarwinPorts
122
        /opt/csw # Blastwave
123
        /opt
124
        ${SDL2_PATH}
125
)
126
 
127
FIND_PATH(SDL2_INCLUDE_DIR SDL.h
128
        HINTS
129
        $ENV{SDL2DIR}
130
        PATH_SUFFIXES include/SDL2 include
131
        PATHS ${SDL2_SEARCH_PATHS}
132
)
133
 
134
FIND_LIBRARY(SDL2_LIBRARY_TEMP
135
        NAMES SDL2
136
        HINTS
137
        $ENV{SDL2DIR}
138
        PATH_SUFFIXES lib64 lib
139
        PATHS ${SDL2_SEARCH_PATHS}
140
)
141
 
142
IF(NOT SDL2_BUILDING_LIBRARY)
143
        IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
144
                # Non-OS X framework versions expect you to also dynamically link to
145
                # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
146
                # seem to provide SDL2main for compatibility even though they don't
147
                # necessarily need it.
148
                FIND_LIBRARY(SDL2MAIN_LIBRARY
149
                        NAMES SDL2main
150
                        HINTS
151
                        $ENV{SDL2DIR}
152
                        PATH_SUFFIXES lib64 lib
153
                        PATHS ${SDL2_SEARCH_PATHS}
154
                )
155
        ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
156
ENDIF(NOT SDL2_BUILDING_LIBRARY)
157
 
158
# SDL2 may require threads on your system.
159
# The Apple build may not need an explicit flag because one of the
160
# frameworks may already provide it.
161
# But for non-OSX systems, I will use the CMake Threads package.
162
IF(NOT APPLE)
163
        FIND_PACKAGE(Threads)
164
ENDIF(NOT APPLE)
165
 
166
# MinGW needs an additional library, mwindows
167
# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows
168
# (Actually on second look, I think it only needs one of the m* libraries.)
169
IF(MINGW)
170
        SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
171
ENDIF(MINGW)
172
 
173
IF(SDL2_LIBRARY_TEMP)
174
        # For SDL2main
175
        IF(NOT SDL2_BUILDING_LIBRARY)
176
                IF(SDL2MAIN_LIBRARY)
177
                        SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
178
                ENDIF(SDL2MAIN_LIBRARY)
179
        ENDIF(NOT SDL2_BUILDING_LIBRARY)
180
 
181
        # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
182
        # CMake doesn't display the -framework Cocoa string in the UI even
183
        # though it actually is there if I modify a pre-used variable.
184
        # I think it has something to do with the CACHE STRING.
185
        # So I use a temporary variable until the end so I can set the
186
        # "real" variable in one-shot.
187
        IF(APPLE)
188
                SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
189
        ENDIF(APPLE)
190
 
191
        # For threads, as mentioned Apple doesn't need this.
192
        # In fact, there seems to be a problem if I used the Threads package
193
        # and try using this line, so I'm just skipping it entirely for OS X.
194
        IF(NOT APPLE)
195
                SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
196
        ENDIF(NOT APPLE)
197
 
198
        # For MinGW library
199
        IF(MINGW)
200
                SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
201
        ENDIF(MINGW)
202
 
203
        # Set the final string here so the GUI reflects the final state.
204
        SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
205
        # Set the temp variable to INTERNAL so it is not seen in the CMake GUI
206
        SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
207
ENDIF(SDL2_LIBRARY_TEMP)
208
 
209
INCLUDE(FindPackageHandleStandardArgs)
210
 
211
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.