···11+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> ... )
22+#
33+# This function is intended to be used in FindXXX.cmake modules files.
44+# It handles the REQUIRED, QUIET and version-related arguments to find_package().
55+# It also sets the <UPPERCASED_NAME>_FOUND variable.
66+# The package is considered found if all variables <var1>... listed contain
77+# valid results, e.g. valid filepaths.
88+#
99+# There are two modes of this function. The first argument in both modes is
1010+# the name of the Find-module where it is called (in original casing).
1111+#
1212+# The first simple mode looks like this:
1313+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(<name> (DEFAULT_MSG|"Custom failure message") <var1>...<varN> )
1414+# If the variables <var1> to <varN> are all valid, then <UPPERCASED_NAME>_FOUND
1515+# will be set to TRUE.
1616+# If DEFAULT_MSG is given as second argument, then the function will generate
1717+# itself useful success and error messages. You can also supply a custom error message
1818+# for the failure case. This is not recommended.
1919+#
2020+# The second mode is more powerful and also supports version checking:
2121+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME [REQUIRED_VARS <var1>...<varN>]
2222+# [VERSION_VAR <versionvar>]
2323+# [HANDLE_COMPONENTS]
2424+# [CONFIG_MODE]
2525+# [FAIL_MESSAGE "Custom failure message"] )
2626+#
2727+# As above, if <var1> through <varN> are all valid, <UPPERCASED_NAME>_FOUND
2828+# will be set to TRUE.
2929+# After REQUIRED_VARS the variables which are required for this package are listed.
3030+# Following VERSION_VAR the name of the variable can be specified which holds
3131+# the version of the package which has been found. If this is done, this version
3232+# will be checked against the (potentially) specified required version used
3333+# in the find_package() call. The EXACT keyword is also handled. The default
3434+# messages include information about the required version and the version
3535+# which has been actually found, both if the version is ok or not.
3636+# If the package supports components, use the HANDLE_COMPONENTS option to enable
3737+# handling them. In this case, find_package_handle_standard_args() will report
3838+# which components have been found and which are missing, and the <NAME>_FOUND
3939+# variable will be set to FALSE if any of the required components (i.e. not the
4040+# ones listed after OPTIONAL_COMPONENTS) are missing.
4141+# Use the option CONFIG_MODE if your FindXXX.cmake module is a wrapper for
4242+# a find_package(... NO_MODULE) call. In this case VERSION_VAR will be set
4343+# to <NAME>_VERSION and the macro will automatically check whether the
4444+# Config module was found.
4545+# Via FAIL_MESSAGE a custom failure message can be specified, if this is not
4646+# used, the default message will be displayed.
4747+#
4848+# Example for mode 1:
4949+#
5050+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR)
5151+#
5252+# LibXml2 is considered to be found, if both LIBXML2_LIBRARY and
5353+# LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to TRUE.
5454+# If it is not found and REQUIRED was used, it fails with FATAL_ERROR,
5555+# independent whether QUIET was used or not.
5656+# If it is found, success will be reported, including the content of <var1>.
5757+# On repeated Cmake runs, the same message won't be printed again.
5858+#
5959+# Example for mode 2:
6060+#
6161+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(BISON REQUIRED_VARS BISON_EXECUTABLE
6262+# VERSION_VAR BISON_VERSION)
6363+# In this case, BISON is considered to be found if the variable(s) listed
6464+# after REQUIRED_VAR are all valid, i.e. BISON_EXECUTABLE in this case.
6565+# Also the version of BISON will be checked by using the version contained
6666+# in BISON_VERSION.
6767+# Since no FAIL_MESSAGE is given, the default messages will be printed.
6868+#
6969+# Another example for mode 2:
7070+#
7171+# find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4)
7272+# FIND_PACKAGE_HANDLE_STANDARD_ARGS(Automoc4 CONFIG_MODE)
7373+# In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4 NO_MODULE)
7474+# and adds an additional search directory for automoc4.
7575+# The following FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper
7676+# success/error message.
7777+7878+#=============================================================================
7979+# Copyright 2007-2009 Kitware, Inc.
8080+#
8181+# Distributed under the OSI-approved BSD License (the "License");
8282+# see accompanying file Copyright.txt for details.
8383+#
8484+# This software is distributed WITHOUT ANY WARRANTY; without even the
8585+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
8686+# See the License for more information.
8787+#=============================================================================
8888+# (To distribute this file outside of CMake, substitute the full
8989+# License text for the above reference.)
9090+9191+include(FindPackageMessage)
9292+include(CMakeParseArguments)
9393+9494+# internal helper macro
9595+macro(_FPHSA_FAILURE_MESSAGE _msg)
9696+ if (${_NAME}_FIND_REQUIRED)
9797+ message(FATAL_ERROR "${_msg}")
9898+ else ()
9999+ if (NOT ${_NAME}_FIND_QUIETLY)
100100+ message(STATUS "${_msg}")
101101+ endif ()
102102+ endif ()
103103+endmacro()
104104+105105+106106+# internal helper macro to generate the failure message when used in CONFIG_MODE:
107107+macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE)
108108+ # <name>_CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found:
109109+ if(${_NAME}_CONFIG)
110110+ _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})")
111111+ else()
112112+ # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version.
113113+ # List them all in the error message:
114114+ if(${_NAME}_CONSIDERED_CONFIGS)
115115+ set(configsText "")
116116+ list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount)
117117+ math(EXPR configsCount "${configsCount} - 1")
118118+ foreach(currentConfigIndex RANGE ${configsCount})
119119+ list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename)
120120+ list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version)
121121+ set(configsText "${configsText} ${filename} (version ${version})\n")
122122+ endforeach()
123123+ if (${_NAME}_NOT_FOUND_MESSAGE)
124124+ set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n")
125125+ endif()
126126+ _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}")
127127+128128+ else()
129129+ # Simple case: No Config-file was found at all:
130130+ _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}")
131131+ endif()
132132+ endif()
133133+endmacro()
134134+135135+136136+function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG)
137137+138138+# set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in
139139+# new extended or in the "old" mode:
140140+ set(options CONFIG_MODE HANDLE_COMPONENTS)
141141+ set(oneValueArgs FAIL_MESSAGE VERSION_VAR)
142142+ set(multiValueArgs REQUIRED_VARS)
143143+ set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} )
144144+ list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX)
145145+146146+ if(${INDEX} EQUAL -1)
147147+ set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG})
148148+ set(FPHSA_REQUIRED_VARS ${ARGN})
149149+ set(FPHSA_VERSION_VAR)
150150+ else()
151151+152152+ CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
153153+154154+ if(FPHSA_UNPARSED_ARGUMENTS)
155155+ message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"")
156156+ endif()
157157+158158+ if(NOT FPHSA_FAIL_MESSAGE)
159159+ set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG")
160160+ endif()
161161+ endif()
162162+163163+# now that we collected all arguments, process them
164164+165165+ if("${FPHSA_FAIL_MESSAGE}" STREQUAL "DEFAULT_MSG")
166166+ set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}")
167167+ endif()
168168+169169+ # In config-mode, we rely on the variable <package>_CONFIG, which is set by find_package()
170170+ # when it successfully found the config-file, including version checking:
171171+ if(FPHSA_CONFIG_MODE)
172172+ list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG)
173173+ list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS)
174174+ set(FPHSA_VERSION_VAR ${_NAME}_VERSION)
175175+ endif()
176176+177177+ if(NOT FPHSA_REQUIRED_VARS)
178178+ message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()")
179179+ endif()
180180+181181+ list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR)
182182+183183+ string(TOUPPER ${_NAME} _NAME_UPPER)
184184+ string(TOLOWER ${_NAME} _NAME_LOWER)
185185+186186+ # collect all variables which were not found, so they can be printed, so the
187187+ # user knows better what went wrong (#6375)
188188+ set(MISSING_VARS "")
189189+ set(DETAILS "")
190190+ set(${_NAME_UPPER}_FOUND TRUE)
191191+ # check if all passed variables are valid
192192+ foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS})
193193+ if(NOT ${_CURRENT_VAR})
194194+ set(${_NAME_UPPER}_FOUND FALSE)
195195+ set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}")
196196+ else()
197197+ set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]")
198198+ endif()
199199+ endforeach()
200200+201201+ # component handling
202202+ unset(FOUND_COMPONENTS_MSG)
203203+ unset(MISSING_COMPONENTS_MSG)
204204+205205+ if(FPHSA_HANDLE_COMPONENTS)
206206+ foreach(comp ${${_NAME}_FIND_COMPONENTS})
207207+ if(${_NAME}_${comp}_FOUND)
208208+209209+ if(NOT DEFINED FOUND_COMPONENTS_MSG)
210210+ set(FOUND_COMPONENTS_MSG "found components: ")
211211+ endif()
212212+ set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}")
213213+214214+ else()
215215+216216+ if(NOT DEFINED MISSING_COMPONENTS_MSG)
217217+ set(MISSING_COMPONENTS_MSG "missing components: ")
218218+ endif()
219219+ set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}")
220220+221221+ if(${_NAME}_FIND_REQUIRED_${comp})
222222+ set(${_NAME_UPPER}_FOUND FALSE)
223223+ set(MISSING_VARS "${MISSING_VARS} ${comp}")
224224+ endif()
225225+226226+ endif()
227227+ endforeach()
228228+ set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}")
229229+ set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]")
230230+ endif()
231231+232232+ # version handling:
233233+ set(VERSION_MSG "")
234234+ set(VERSION_OK TRUE)
235235+ set(VERSION ${${FPHSA_VERSION_VAR}} )
236236+ if (${_NAME}_FIND_VERSION)
237237+238238+ if(VERSION)
239239+240240+ if(${_NAME}_FIND_VERSION_EXACT) # exact version required
241241+ if (NOT "${${_NAME}_FIND_VERSION}" VERSION_EQUAL "${VERSION}")
242242+ set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"")
243243+ set(VERSION_OK FALSE)
244244+ else ()
245245+ set(VERSION_MSG "(found suitable exact version \"${VERSION}\")")
246246+ endif ()
247247+248248+ else() # minimum version specified:
249249+ if ("${${_NAME}_FIND_VERSION}" VERSION_GREATER "${VERSION}")
250250+ set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"")
251251+ set(VERSION_OK FALSE)
252252+ else ()
253253+ set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")")
254254+ endif ()
255255+ endif()
256256+257257+ else()
258258+259259+ # if the package was not found, but a version was given, add that to the output:
260260+ if(${_NAME}_FIND_VERSION_EXACT)
261261+ set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")")
262262+ else()
263263+ set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")")
264264+ endif()
265265+266266+ endif()
267267+ else ()
268268+ if(VERSION)
269269+ set(VERSION_MSG "(found version \"${VERSION}\")")
270270+ endif()
271271+ endif ()
272272+273273+ if(VERSION_OK)
274274+ set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]")
275275+ else()
276276+ set(${_NAME_UPPER}_FOUND FALSE)
277277+ endif()
278278+279279+280280+ # print the result:
281281+ if (${_NAME_UPPER}_FOUND)
282282+ FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}")
283283+ else ()
284284+285285+ if(FPHSA_CONFIG_MODE)
286286+ _FPHSA_HANDLE_FAILURE_CONFIG_MODE()
287287+ else()
288288+ if(NOT VERSION_OK)
289289+ _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})")
290290+ else()
291291+ _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}")
292292+ endif()
293293+ endif()
294294+295295+ endif ()
296296+297297+ set(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE)
298298+299299+endfunction()
+27-155
scripts/FindSDL2.cmake
···11-# Locate SDL2 library
22-# This module defines
33-# SDL2_LIBRARY, the name of the library to link against
44-# SDL2_FOUND, if false, do not try to link to SDL2
55-# SDL2_INCLUDE_DIR, where to find SDL.h
66-#
77-# This module responds to the the flag:
88-# SDL2_BUILDING_LIBRARY
99-# If this is defined, then no SDL2_main will be linked in because
1010-# only applications need main().
1111-# Otherwise, it is assumed you are building an application and this
1212-# module will attempt to locate and set the the proper link flags
1313-# as part of the returned SDL2_LIBRARY variable.
1414-#
1515-# Don't forget to include SDL2main.h and SDL2main.m your project for the
1616-# OS X framework based version. (Other versions link to -lSDL2main which
1717-# this module will try to find on your behalf.) Also for OS X, this
1818-# module will automatically add the -framework Cocoa on your behalf.
1919-#
2020-#
2121-# Additional Note: If you see an empty SDL2_LIBRARY_TEMP in your configuration
2222-# and no SDL2_LIBRARY, it means CMake did not find your SDL2 library
2323-# (SDL2.dll, libsdl2.so, SDL2.framework, etc).
2424-# Set SDL2_LIBRARY_TEMP to point to your SDL2 library, and configure again.
2525-# Similarly, if you see an empty SDL2MAIN_LIBRARY, you should set this value
2626-# as appropriate. These values are used to generate the final SDL2_LIBRARY
2727-# variable, but when these values are unset, SDL2_LIBRARY does not get created.
11+# - Find SDL
22+# Find the SDL libraries (asound)
283#
44+# This module defines the following variables:
55+# SDL_FOUND - True if SDL_INCLUDE_DIR & SDL_LIBRARY are found
66+# SDL_LIBRARY - Set when SDL_LIBRARY is found
297#
3030-# $SDL2DIR is an environment variable that would
3131-# correspond to the ./configure --prefix=$SDL2DIR
3232-# used in building SDL2.
3333-# l.e.galup 9-20-02
88+# SDL_INCLUDE_DIR - where to find SDL.h, etc.
349#
3535-# Modified by Eric Wing.
3636-# Added code to assist with automated building by using environmental variables
3737-# and providing a more controlled/consistent search behavior.
3838-# Added new modifications to recognize OS X frameworks and
3939-# additional Unix paths (FreeBSD, etc).
4040-# Also corrected the header search path to follow "proper" SDL2 guidelines.
4141-# Added a search for SDL2main which is needed by some platforms.
4242-# Added a search for threads which is needed by some platforms.
4343-# Added needed compile switches for MinGW.
4444-#
4545-# On OSX, this will prefer the Framework version (if found) over others.
4646-# People will have to manually change the cache values of
4747-# SDL2_LIBRARY to override this selection or set the CMake environment
4848-# CMAKE_INCLUDE_PATH to modify the search paths.
4949-#
5050-# Note that the header path has changed from SDL2/SDL.h to just SDL.h
5151-# This needed to change because "proper" SDL2 convention
5252-# is #include "SDL.h", not <SDL2/SDL.h>. This is done for portability
5353-# reasons because not all systems place things in SDL2/ (see FreeBSD).
5454-#
5555-# Ported by Johnny Patterson. This is a literal port for SDL2 of the FindSDL.cmake
5656-# module with the minor edit of changing "SDL" to "SDL2" where necessary. This
5757-# was not created for redistribution, and exists temporarily pending official
5858-# SDL2 CMake modules.
59106011#=============================================================================
6161-# Copyright 2003-2009 Kitware, Inc.
1212+# Copyright Eric Wing
6213#
6314# Distributed under the OSI-approved BSD License (the "License");
6415# see accompanying file Copyright.txt for details.
···7021# (To distribute this file outside of CMake, substitute the full
7122# License text for the above reference.)
72237373-FIND_PATH(SDL2_INCLUDE_DIR SDL.h
7474- HINTS
7575- $ENV{SDL2DIR}
7676- PATH_SUFFIXES include/SDL2 include
7777- PATHS
7878- ~/Library/Frameworks
7979- /Library/Frameworks
8080- /usr/local/include/SDL2
8181- /usr/include/SDL2
8282- /sw # Fink
8383- /opt/local # DarwinPorts
8484- /opt/csw # Blastwave
8585- /opt
2424+find_path(SDL2_INCLUDE_DIR NAMES SDL.h
2525+ PATH_SUFFIXES include/SDL2 include
2626+ DOC "The SDL include directory"
8627)
8787-#MESSAGE("SDL2_INCLUDE_DIR is ${SDL2_INCLUDE_DIR}")
88288989-FIND_LIBRARY(SDL2_LIBRARY_TEMP
9090- NAMES SDL2
9191- HINTS
9292- $ENV{SDL2DIR}
9393- PATH_SUFFIXES lib64 lib
9494- PATHS
9595- /sw
9696- /opt/local
9797- /opt/csw
9898- /opt
2929+find_library(SDL2_LIBRARY NAMES SDL2 sdl2 sdl2 sdl-2.0
3030+ DOC "The SDL library"
9931)
10032101101-#MESSAGE("SDL2_LIBRARY_TEMP is ${SDL2_LIBRARY_TEMP}")
3333+if(WIN32)
3434+ find_library(SDL2MAIN_LIBRARY NAMES SDL2main sdl2main
3535+ DOC "The SDLmain library needed on some platforms when builing an application (opposed to a library)"
3636+)
3737+else()
3838+ set(SDL2MAIN_LIBRARY "")
3939+endif()
10240103103-IF(NOT SDL2_BUILDING_LIBRARY)
104104- IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
105105- # Non-OS X framework versions expect you to also dynamically link to
106106- # SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
107107- # seem to provide SDL2main for compatibility even though they don't
108108- # necessarily need it.
109109- FIND_LIBRARY(SDL2MAIN_LIBRARY
110110- NAMES SDL2main
111111- HINTS
112112- $ENV{SDL2DIR}
113113- PATH_SUFFIXES lib64 lib
114114- PATHS
115115- /sw
116116- /opt/local
117117- /opt/csw
118118- /opt
119119- )
120120- ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
121121-ENDIF(NOT SDL2_BUILDING_LIBRARY)
12241123123-# SDL2 may require threads on your system.
124124-# The Apple build may not need an explicit flag because one of the
125125-# frameworks may already provide it.
126126-# But for non-OSX systems, I will use the CMake Threads package.
127127-IF(NOT APPLE)
128128- FIND_PACKAGE(Threads)
129129-ENDIF(NOT APPLE)
4242+# handle the QUIETLY and REQUIRED arguments and set SDL_FOUND to TRUE if
4343+# all listed variables are TRUE
4444+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
13045131131-# MinGW needs an additional library, mwindows
132132-# It's total link flags should look like -lmingw32 -lSDL2main -lSDL2 -lmwindows
133133-# (Actually on second look, I think it only needs one of the m* libraries.)
134134-IF(MINGW)
135135- SET(MINGW32_LIBRARY mingw32 CACHE STRING "mwindows for MinGW")
136136-ENDIF(MINGW)
4646+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
4747+ REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
4848+ VERSION_VAR SDL2_VERSION_STRING)
4949+5050+#mark_as_advanced(SDL_INCLUDE_DIR SDL_LIBRARIES)
13751138138-SET(SDL2_FOUND "NO")
139139-IF(SDL2_LIBRARY_TEMP)
140140- # For SDL2main
141141- IF(NOT SDL2_BUILDING_LIBRARY)
142142- IF(SDL2MAIN_LIBRARY)
143143- SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
144144- ENDIF(SDL2MAIN_LIBRARY)
145145- ENDIF(NOT SDL2_BUILDING_LIBRARY)
14652147147- # For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
148148- # CMake doesn't display the -framework Cocoa string in the UI even
149149- # though it actually is there if I modify a pre-used variable.
150150- # I think it has something to do with the CACHE STRING.
151151- # So I use a temporary variable until the end so I can set the
152152- # "real" variable in one-shot.
153153- IF(APPLE)
154154- SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} "-framework Cocoa")
155155- ENDIF(APPLE)
156156-157157- # For threads, as mentioned Apple doesn't need this.
158158- # In fact, there seems to be a problem if I used the Threads package
159159- # and try using this line, so I'm just skipping it entirely for OS X.
160160- IF(NOT APPLE)
161161- SET(SDL2_LIBRARY_TEMP ${SDL2_LIBRARY_TEMP} ${CMAKE_THREAD_LIBS_INIT})
162162- ENDIF(NOT APPLE)
163163-164164- # For MinGW library
165165- IF(MINGW)
166166- SET(SDL2_LIBRARY_TEMP ${MINGW32_LIBRARY} ${SDL2_LIBRARY_TEMP})
167167- ENDIF(MINGW)
168168-169169- # Set the final string here so the GUI reflects the final state.
170170- SET(SDL2_LIBRARY ${SDL2_LIBRARY_TEMP} CACHE STRING "Where the SDL2 Library can be found")
171171- # Set the temp variable to INTERNAL so it is not seen in the CMake GUI
172172- SET(SDL2_LIBRARY_TEMP "${SDL2_LIBRARY_TEMP}" CACHE INTERNAL "")
173173-174174- SET(SDL2_FOUND "YES")
175175-ENDIF(SDL2_LIBRARY_TEMP)
176176-177177-INCLUDE(FindPackageHandleStandardArgs)
178178-179179-FIND_PACKAGE_HANDLE_STANDARD_ARGS(SDL2
180180- REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR)
+55
scripts/ios-cmake/toolchain/XcodeDefaults.cmake
···11+# This file is here to initial Xcode to better default settings.
22+33+macro(SDL_gpu_CONFIGURE_XCODE_DEFAULTS _EXE_NAME)
44+55+# This iOS toolchain provides this convenience macro, but this is not in the mainline Mac, so let's define it.
66+if(APPLE AND NOT IOS)
77+ macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
88+ set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE})
99+ endmacro (set_xcode_property)
1010+endif()
1111+1212+1313+if(APPLE)
1414+ if(IOS)
1515+1616+ # We need to make sure dead code stripping is off for "plugins" since we must statically link.
1717+# set_xcode_property(${_EXE_NAME} DEAD_CODE_STRIPPING "No")
1818+1919+ set_xcode_property(${_EXE_NAME} GCC_GENERATE_DEBUGGING_SYMBOLS[variant=Debug] YES)
2020+ set_xcode_property(${_EXE_NAME} GCC_GENERATE_DEBUGGING_SYMBOLS[variant=MinSizeRel] YES)
2121+ set_xcode_property(${_EXE_NAME} GCC_GENERATE_DEBUGGING_SYMBOLS[variant=RelWithDebInfo] YES)
2222+ set_xcode_property(${_EXE_NAME} GCC_GENERATE_DEBUGGING_SYMBOLS[variant=Release] YES)
2323+2424+ set_xcode_property(${_EXE_NAME} IPHONEOS_DEPLOYMENT_TARGET 5.1)
2525+ set_xcode_property(${_EXE_NAME} TARGETED_DEVICE_FAMILY "1,2")
2626+2727+ # OSX
2828+ else()
2929+ set_xcode_property(${_EXE_NAME} GCC_GENERATE_DEBUGGING_SYMBOLS[variant=Debug] YES)
3030+ set_xcode_property(${_EXE_NAME} GCC_GENERATE_DEBUGGING_SYMBOLS[variant=MinSizeRel] YES)
3131+ set_xcode_property(${_EXE_NAME} GCC_GENERATE_DEBUGGING_SYMBOLS[variant=RelWithDebInfo] YES)
3232+ set_xcode_property(${_EXE_NAME} GCC_GENERATE_DEBUGGING_SYMBOLS[variant=Release] YES)
3333+3434+ set_xcode_property(${_EXE_NAME} MACOSX_DEPLOYMENT_TARGET 10.6)
3535+3636+3737+ endif(IOS)
3838+3939+ # Common to both
4040+ # Use Apple's recommended standard architectures
4141+ set_xcode_property(${_EXE_NAME} ARCHS "$(ARCHS_STANDARD)")
4242+4343+4444+4545+ set_xcode_property(${_EXE_NAME} GCC_OPTIMIZATION_LEVEL[variant=Debug] "0")
4646+ set_xcode_property(${_EXE_NAME} GCC_OPTIMIZATION_LEVEL[variant=MinSizeRel] "s")
4747+ set_xcode_property(${_EXE_NAME} GCC_OPTIMIZATION_LEVEL[variant=RelWithDebInfo] "s")
4848+ set_xcode_property(${_EXE_NAME} GCC_OPTIMIZATION_LEVEL[variant=Release] "s")
4949+5050+5151+ set_xcode_property(${_EXE_NAME} ONLY_ACTIVE_ARCH NO)
5252+ set_xcode_property(${_EXE_NAME} DEBUG_INFORMATION_FORMAT "dwarf-with-dsym")
5353+5454+endif(APPLE)
5555+endmacro(SDL_gpu_CONFIGURE_XCODE_DEFAULTS)
+101-15
scripts/ios-cmake/toolchain/iOS.cmake
···1818# In this case it will always be the most up-to-date SDK found in the CMAKE_IOS_DEVELOPER_ROOT path.
1919# If set manually, this will force the use of a specific SDK version
20202121+# Macros:
2222+#
2323+# set_xcode_property (TARGET XCODE_PROPERTY XCODE_VALUE)
2424+# A convenience macro for setting xcode specific properties on targets
2525+# example: set_xcode_property (myioslib IPHONEOS_DEPLOYMENT_TARGET "3.1")
2626+#
2727+# find_host_package (PROGRAM ARGS)
2828+# A macro used to find executable programs on the host system, not within the iOS environment.
2929+# Thanks to the android-cmake project for providing the command
3030+3131+2132# Standard settings
2233set (CMAKE_SYSTEM_NAME Darwin)
2323-set (CMAKE_SYSTEM_VERSION 1 )
3434+set (CMAKE_SYSTEM_VERSION 1)
2435set (UNIX True)
2536set (APPLE True)
2637set (IOS True)
27382828-# Force the compilers to gcc for iOS
3939+# Required as of cmake 2.8.10
4040+set (CMAKE_OSX_DEPLOYMENT_TARGET "" CACHE STRING "Force unset of the deployment target for iOS" FORCE)
4141+4242+# Determine the cmake host system version so we know where to find the iOS SDKs
4343+find_program (CMAKE_UNAME uname /bin /usr/bin /usr/local/bin)
4444+if (CMAKE_UNAME)
4545+ exec_program(uname ARGS -r OUTPUT_VARIABLE CMAKE_HOST_SYSTEM_VERSION)
4646+ string (REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\1" DARWIN_MAJOR_VERSION "${CMAKE_HOST_SYSTEM_VERSION}")
4747+endif (CMAKE_UNAME)
4848+4949+# Force the compilers to clang for iOS
2950include (CMakeForceCompiler)
3030-CMAKE_FORCE_C_COMPILER (gcc gcc)
3131-CMAKE_FORCE_CXX_COMPILER (g++ g++)
5151+CMAKE_FORCE_C_COMPILER (/usr/bin/clang clang)
5252+CMAKE_FORCE_CXX_COMPILER (/usr/bin/clang++ clang++)
32533354# Skip the platform compiler checks for cross compiling
3455set (CMAKE_CXX_COMPILER_WORKS TRUE)
···4869set (CMAKE_CXX_OSX_CURRENT_VERSION_FLAG "${CMAKE_C_OSX_CURRENT_VERSION_FLAG}")
49705071# Hidden visibilty is required for cxx on iOS
5151-set (CMAKE_C_FLAGS "")
5252-set (CMAKE_CXX_FLAGS "-headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden")
7272+set (CMAKE_C_FLAGS_INIT "")
7373+set (CMAKE_CXX_FLAGS_INIT "-headerpad_max_install_names -fvisibility=hidden -fvisibility-inlines-hidden")
53745475set (CMAKE_C_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_C_LINK_FLAGS}")
5576set (CMAKE_CXX_LINK_FLAGS "-Wl,-search_paths_first ${CMAKE_CXX_LINK_FLAGS}")
···6990 find_program(CMAKE_INSTALL_NAME_TOOL install_name_tool)
7091endif (NOT DEFINED CMAKE_INSTALL_NAME_TOOL)
71927272-# Setup iOS platform
9393+# Setup iOS platform unless specified manually with IOS_PLATFORM
7394if (NOT DEFINED IOS_PLATFORM)
7495 set (IOS_PLATFORM "OS")
7596endif (NOT DEFINED IOS_PLATFORM)
···7899# Check the platform selection and setup for developer root
79100if (${IOS_PLATFORM} STREQUAL "OS")
80101 set (IOS_PLATFORM_LOCATION "iPhoneOS.platform")
102102+103103+ # This causes the installers to properly locate the output libraries
104104+ set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos")
81105elseif (${IOS_PLATFORM} STREQUAL "SIMULATOR")
82106 set (IOS_PLATFORM_LOCATION "iPhoneSimulator.platform")
107107+108108+ # This causes the installers to properly locate the output libraries
109109+ set (CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphonesimulator")
83110else (${IOS_PLATFORM} STREQUAL "OS")
84111 message (FATAL_ERROR "Unsupported IOS_PLATFORM value selected. Please choose OS or SIMULATOR")
85112endif (${IOS_PLATFORM} STREQUAL "OS")
861138787-# Setup iOS developer location
114114+# Setup iOS developer location unless specified manually with CMAKE_IOS_DEVELOPER_ROOT
115115+# Note Xcode 4.3 changed the installation location, choose the most recent one available
116116+set (XCODE_POST_43_ROOT "/Applications/Xcode.app/Contents/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
117117+set (XCODE_PRE_43_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
88118if (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
8989- set (CMAKE_IOS_DEVELOPER_ROOT "/Developer/Platforms/${IOS_PLATFORM_LOCATION}/Developer")
119119+ if (EXISTS ${XCODE_POST_43_ROOT})
120120+ set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_POST_43_ROOT})
121121+ elseif(EXISTS ${XCODE_PRE_43_ROOT})
122122+ set (CMAKE_IOS_DEVELOPER_ROOT ${XCODE_PRE_43_ROOT})
123123+ endif (EXISTS ${XCODE_POST_43_ROOT})
90124endif (NOT DEFINED CMAKE_IOS_DEVELOPER_ROOT)
91125set (CMAKE_IOS_DEVELOPER_ROOT ${CMAKE_IOS_DEVELOPER_ROOT} CACHE PATH "Location of iOS Platform")
921269393-# Find and use the most recent iOS sdk
127127+# Find and use the most recent iOS sdk unless specified manually with CMAKE_IOS_SDK_ROOT
94128if (NOT DEFINED CMAKE_IOS_SDK_ROOT)
95129 file (GLOB _CMAKE_IOS_SDKS "${CMAKE_IOS_DEVELOPER_ROOT}/SDKs/*")
96130 if (_CMAKE_IOS_SDKS)
···98132 list (REVERSE _CMAKE_IOS_SDKS)
99133 list (GET _CMAKE_IOS_SDKS 0 CMAKE_IOS_SDK_ROOT)
100134 else (_CMAKE_IOS_SDKS)
101101- message (FATAL_ERROR "No iOS SDK's found in default seach path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
135135+ message (FATAL_ERROR "No iOS SDK's found in default search path ${CMAKE_IOS_DEVELOPER_ROOT}. Manually set CMAKE_IOS_SDK_ROOT or install the iOS SDK.")
102136 endif (_CMAKE_IOS_SDKS)
103137 message (STATUS "Toolchain using default iOS SDK: ${CMAKE_IOS_SDK_ROOT}")
104138endif (NOT DEFINED CMAKE_IOS_SDK_ROOT)
105139set (CMAKE_IOS_SDK_ROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Location of the selected iOS SDK")
106140107141# Set the sysroot default to the most recent SDK
108108-set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
142142+# The generic "iphoneos" is used to trigger the "Latest" setting. The full SDK path which CMake has been trying to do actually breaks functionality in subtle ways.
143143+set (CMAKE_OSX_SYSROOT iphoneos CACHE PATH "Sysroot used for iOS support")
144144+#set (CMAKE_OSX_SYSROOT ${CMAKE_IOS_SDK_ROOT} CACHE PATH "Sysroot used for iOS support")
109145110110-# set the architecture for iOS - using ARCHS_STANDARD_32_BIT sets armv6,armv7 and appears to be XCode's standard.
111111-# The other value that works is ARCHS_UNIVERSAL_IPHONE_OS but that sets armv7 only
112112-set (CMAKE_OSX_ARCHITECTURES "$(ARCHS_STANDARD_32_BIT)" CACHE string "Build architecture for iOS")
146146+# set the architecture for iOS
147147+# NOTE: Currently both ARCHS_STANDARD_32_BIT and ARCHS_UNIVERSAL_IPHONE_OS set armv7 only, so set both manually
148148+# NOTE: EW: I'm disabling this because it breaks arm64. Apple has dropped armv6. Time to move on.
149149+#if (${IOS_PLATFORM} STREQUAL "OS")
150150+# set (IOS_ARCH armv6 armv7)
151151+#else (${IOS_PLATFORM} STREQUAL "OS")
152152+# set (IOS_ARCH i386)
153153+#endif (${IOS_PLATFORM} STREQUAL "OS")
154154+155155+set (CMAKE_OSX_ARCHITECTURES ${IOS_ARCH} CACHE string "Build architecture for iOS")
113156114157# Set the find root to the iOS developer roots and to user defined paths
115158set (CMAKE_FIND_ROOT_PATH ${CMAKE_IOS_DEVELOPER_ROOT} ${CMAKE_IOS_SDK_ROOT} ${CMAKE_PREFIX_PATH} CACHE string "iOS find search path root")
···129172set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
130173set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
131174175175+176176+# This little macro lets you set any XCode specific property
177177+macro (set_xcode_property TARGET XCODE_PROPERTY XCODE_VALUE)
178178+ set_property (TARGET ${TARGET} PROPERTY XCODE_ATTRIBUTE_${XCODE_PROPERTY} ${XCODE_VALUE})
179179+endmacro (set_xcode_property)
180180+181181+182182+# This macro lets you find executable programs on the host system
183183+macro (find_host_package)
184184+ set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
185185+ set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
186186+ set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
187187+ set (IOS FALSE)
188188+189189+ find_package(${ARGN})
190190+191191+ set (IOS TRUE)
192192+ set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY)
193193+ set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
194194+ set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
195195+endmacro (find_host_package)
196196+197197+198198+# We need to make sure dead code stripping is off for "plugins" since we must statically link.
199199+set(CMAKE_XCODE_ATTRIBUTE_DEAD_CODE_STRIPPING NO)
200200+201201+# Not working correctly
202202+#set(CMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS[variant=Debug] YES)
203203+#set(CMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS[variant=MinSizeRel] NO)
204204+#set(CMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS[variant=RelWithDebInfo] YES)
205205+#set(CMAKE_XCODE_ATTRIBUTE_GCC_GENERATE_DEBUGGING_SYMBOLS[variant=Release] NO)
206206+207207+# Not working correctly
208208+#set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL[variant=Debug] "0")
209209+#set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL[variant=MinSizeRel] "s")
210210+#set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL[variant=RelWithDebInfo] "fast")
211211+#set(CMAKE_XCODE_ATTRIBUTE_GCC_OPTIMIZATION_LEVEL[variant=Release] "fast")
212212+213213+# Common to both
214214+# Use Apple's recommended standard architectures
215215+set(CMAKE_XCODE_ATTRIBUTE_ARCHS "$(ARCHS_STANDARD)")
216216+217217+
+55-5
src/CMakeLists.txt
···6161 set (SDL_gpu_OUTPUT_NAME "SDL2_gpu")
6262endif ( SDL_gpu_USE_SDL1)
63636464+if(APPLE)
6565+ set(CMAKE_MACOSX_RPATH 1)
6666+ # use, i.e. don't skip the full RPATH for the build tree
6767+ # SET(CMAKE_SKIP_BUILD_RPATH FALSE)
6868+6969+ # when building, don't use the install RPATH already
7070+ # (but later on when installing)
7171+ set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
7272+7373+ # add the automatically determined parts of the RPATH
7474+ # which point to directories outside the build tree to the install RPATH
7575+ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
7676+endif()
7777+6478# Build the shared library (.so or .dll)
6579if(SDL_gpu_BUILD_SHARED)
6680 add_library(SDL_gpu_shared SHARED
6781 ${SDL_gpu_HDRS}
6882 ${SDL_gpu_SRCS}
6983 )
7070- set_target_properties(SDL_gpu_shared PROPERTIES
7171- OUTPUT_NAME ${SDL_gpu_OUTPUT_NAME}
7272- CLEAN_DIRECT_OUTPUT 1
7373- VERSION ${SDL_gpu_VERSION}
7474- )
8484+ if(SDL_gpu_BUILD_FRAMEWORK)
8585+ set_target_properties(SDL_gpu_shared PROPERTIES
8686+ FRAMEWORK TRUE
8787+ FRAMEWORK_VERSION "A"
8888+ PUBLIC_HEADER "${SDL_gpu_install_HDRS}"
8989+ #RESOURCE "${RESOURCE_FILES}"
9090+ VERSION ${SDL_gpu_VERSION}
9191+ SOVERSION ${SDL_gpu_VERSION}
9292+ OUTPUT_NAME ${SDL_gpu_OUTPUT_NAME}
9393+ )
9494+ # Short Version is the "marketing version". It is the version
9595+ # the user sees in an information panel.
9696+ SET(MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${SDL_gpu_VERSION}")
9797+ # Bundle version is the version the OS looks at.
9898+ SET(MACOSX_FRAMEWORK_BUNDLE_VERSION "${SDL_gpu_VERSION}")
9999+ # FIXME: org.libsdl probably isn't the right domain
100100+ SET(MACOSX_FRAMEWORK_IDENTIFIER "org.libsdl.sdl-gpu")
101101+102102+103103+104104+ else()
105105+ if(ANDROID)
106106+ set_target_properties(SDL_gpu_shared PROPERTIES
107107+ OUTPUT_NAME ${SDL_gpu_OUTPUT_NAME}
108108+ CLEAN_DIRECT_OUTPUT 1
109109+ )
110110+ else()
111111+ set_target_properties(SDL_gpu_shared PROPERTIES
112112+ OUTPUT_NAME ${SDL_gpu_OUTPUT_NAME}
113113+ CLEAN_DIRECT_OUTPUT 1
114114+# VERSION ${SDL_gpu_VERSION}
115115+ )
116116+ endif()
117117+118118+ endif()
75119 set_target_properties(SDL_gpu_shared PROPERTIES LINKER_LANGUAGE C)
120120+ if(APPLE)
121121+ SDL_gpu_CONFIGURE_XCODE_DEFAULTS(SDL_gpu_shared)
122122+ endif()
76123endif()
7712478125# Build the static library (.a or .lib)
···87134 VERSION ${SDL_gpu_VERSION}
88135 )
89136 set_target_properties(SDL_gpu PROPERTIES LINKER_LANGUAGE C)
137137+ if(APPLE)
138138+ SDL_gpu_CONFIGURE_XCODE_DEFAULTS(SDL_gpu)
139139+ endif()
90140endif()
9114192142# These are used to create visual studio folders.