summaryrefslogtreecommitdiff
path: root/externals/cmake-modules
diff options
context:
space:
mode:
Diffstat (limited to 'externals/cmake-modules')
-rw-r--r--externals/cmake-modules/FindSDL2.cmake224
-rw-r--r--externals/cmake-modules/WindowsCopyFiles.cmake28
2 files changed, 252 insertions, 0 deletions
diff --git a/externals/cmake-modules/FindSDL2.cmake b/externals/cmake-modules/FindSDL2.cmake
new file mode 100644
index 000000000..0af86840a
--- /dev/null
+++ b/externals/cmake-modules/FindSDL2.cmake
@@ -0,0 +1,224 @@
1
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 <SDL2/SDL.h>. This is done for portability
53# reasons because not all systems place things in SDL2/ (see FreeBSD).
54
55#=============================================================================
56# Copyright 2003-2009 Kitware, Inc.
57#
58# Distributed under the OSI-approved BSD License (the "License").
59#
60# This software is distributed WITHOUT ANY WARRANTY; without even the
61# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
62# See the License for more information.
63#=============================================================================
64# CMake - Cross Platform Makefile Generator
65# Copyright 2000-2016 Kitware, Inc.
66# Copyright 2000-2011 Insight Software Consortium
67# All rights reserved.
68#
69# Redistribution and use in source and binary forms, with or without
70# modification, are permitted provided that the following conditions
71# are met:
72#
73# * Redistributions of source code must retain the above copyright
74# notice, this list of conditions and the following disclaimer.
75#
76# * Redistributions in binary form must reproduce the above copyright
77# notice, this list of conditions and the following disclaimer in the
78# documentation and/or other materials provided with the distribution.
79#
80# * Neither the names of Kitware, Inc., the Insight Software Consortium,
81# nor the names of their contributors may be used to endorse or promote
82# products derived from this software without specific prior written
83# permission.
84#
85# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
86# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
87# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
88# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
89# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
90# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
91# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
92# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
93# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
94# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
95# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
96#
97# ------------------------------------------------------------------------------
98#
99# The above copyright and license notice applies to distributions of
100# CMake in source and binary form. Some source files contain additional
101# notices of original copyright by their contributors; see each source
102# for details. Third-party software packages supplied with CMake under
103# compatible licenses provide their own copyright notices documented in
104# corresponding subdirectories.
105#
106# ------------------------------------------------------------------------------
107#
108# CMake was initially developed by Kitware with the following sponsorship:
109#
110# * National Library of Medicine at the National Institutes of Health
111# as part of the Insight Segmentation and Registration Toolkit (ITK).
112#
113# * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
114# Visualization Initiative.
115#
116# * National Alliance for Medical Image Computing (NAMIC) is funded by the
117# National Institutes of Health through the NIH Roadmap for Medical Research,
118# Grant U54 EB005149.
119#
120# * Kitware, Inc.
121#
122
123message("<FindSDL2.cmake>")
124
125SET(SDL2_SEARCH_PATHS
126 ~/Library/Frameworks
127 /Library/Frameworks
128 /usr/local
129 /usr
130 /sw # Fink
131 /opt/local # DarwinPorts
132 /opt/csw # Blastwave
133 /opt
134 ${SDL2_PATH}
135)
136
137FIND_LIBRARY(SDL2_LIBRARY_TEMP
138 NAMES SDL2
139 HINTS
140 $ENV{SDL2DIR}
141 PATH_SUFFIXES lib64 lib
142 PATHS ${SDL2_SEARCH_PATHS}
143)
144
145IF(SDL2_LIBRARY_TEMP)
146 FIND_PATH(SDL2_INCLUDE_DIR SDL.h
147 HINTS
148 $ENV{SDL2DIR}
149 PATH_SUFFIXES include/SDL2 include
150 PATHS ${SDL2_SEARCH_PATHS}
151 )
152
153 IF(NOT SDL2_BUILDING_LIBRARY)
154 IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
155 # Non-OS X framework versions expect you to also dynamically link to
156 # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
157 # seem to provide SDL2main for compatibility even though they don't
158 # necessarily need it.
159 FIND_LIBRARY(SDL2MAIN_LIBRARY
160 NAMES SDL2main
161 HINTS
162 $ENV{SDL2DIR}
163 PATH_SUFFIXES lib64 lib
164 PATHS ${SDL2_SEARCH_PATHS}
165 )
166 ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
167 ENDIF(NOT SDL2_BUILDING_LIBRARY)
168
169 # SDL2 may require threads on your system.
170 # The Apple build may not need an explicit flag because one of the
171 # frameworks may already provide it.
172 # But for non-OSX systems, I will use the CMake Threads package.
173 IF(NOT APPLE)
174 FIND_PACKAGE(Threads)
175 ENDIF(NOT APPLE)
176
177 # MinGW needs an additional library, mwindows
178 # It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows
179 # (Actually on second look, I think it only needs one of the m* libraries.)
180 IF(MINGW)
181 SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
182 ENDIF(MINGW)
183
184 # For SDL2main
185 IF(NOT SDL2_BUILDING_LIBRARY)
186 IF(SDL2MAIN_LIBRARY)
187 SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
188 ENDIF(SDL2MAIN_LIBRARY)
189 ENDIF(NOT SDL2_BUILDING_LIBRARY)
190
191 # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
192 # CMake doesn't display the -framework Cocoa string in the UI even
193 # though it actually is there if I modify a pre-used variable.
194 # I think it has something to do with the CACHE STRING.
195 # So I use a temporary variable until the end so I can set the
196 # "real" variable in one-shot.
197 IF(APPLE)
198 SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
199 ENDIF(APPLE)
200
201 # For threads, as mentioned Apple doesn't need this.
202 # In fact, there seems to be a problem if I used the Threads package
203 # and try using this line, so I'm just skipping it entirely for OS X.
204 IF(NOT APPLE)
205 SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
206 ENDIF(NOT APPLE)
207
208 # For MinGW library
209 IF(MINGW)
210 SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
211 ENDIF(MINGW)
212
213 # Set the final string here so the GUI reflects the final state.
214 SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
215
216 # Unset the temp variable to INTERNAL so it is not seen in the CMake GUI
217 UNSET(SDL2_LIBRARY_TEMP)
218ENDIF(SDL2_LIBRARY_TEMP)
219
220message("</FindSDL2.cmake>")
221
222INCLUDE(FindPackageHandleStandardArgs)
223
224FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
diff --git a/externals/cmake-modules/WindowsCopyFiles.cmake b/externals/cmake-modules/WindowsCopyFiles.cmake
new file mode 100644
index 000000000..cd0c2ce47
--- /dev/null
+++ b/externals/cmake-modules/WindowsCopyFiles.cmake
@@ -0,0 +1,28 @@
1# Copyright 2016 Citra Emulator Project
2# Licensed under GPLv2 or any later version
3# Refer to the license.txt file included.
4
5# This file provides the function windows_copy_files.
6# This is only valid on Windows.
7
8# Include guard
9if(__windows_copy_files)
10 return()
11endif()
12set(__windows_copy_files YES)
13
14# Any number of files to copy from SOURCE_DIR to DEST_DIR can be specified after DEST_DIR.
15# This copying happens post-build.
16function(windows_copy_files TARGET SOURCE_DIR DEST_DIR)
17 # windows commandline expects the / to be \ so switch them
18 string(REPLACE "/" "\\\\" SOURCE_DIR ${SOURCE_DIR})
19 string(REPLACE "/" "\\\\" DEST_DIR ${DEST_DIR})
20
21 # /NJH /NJS /NDL /NFL /NC /NS /NP - Silence any output
22 # cmake adds an extra check for command success which doesn't work too well with robocopy
23 # so trick it into thinking the command was successful with the || cmd /c "exit /b 0"
24 add_custom_command(TARGET ${TARGET} POST_BUILD
25 COMMAND if not exist ${DEST_DIR} mkdir ${DEST_DIR} 2> nul
26 COMMAND robocopy ${SOURCE_DIR} ${DEST_DIR} ${ARGN} /NJH /NJS /NDL /NFL /NC /NS /NP || cmd /c "exit /b 0"
27 )
28endfunction() \ No newline at end of file