2015-05-06 01:27:09 +00:00
# This script locates the SFML library
# ------------------------------------
#
# Usage
# -----
#
# When you try to locate the SFML libraries, you must specify which modules you want to use (system, window, graphics, network, audio, main).
# If none is given, the SFML_LIBRARIES variable will be empty and you'll end up linking to nothing.
# example:
2016-11-14 18:56:50 +00:00
# find_package(SFML COMPONENTS graphics window system) # find the graphics, window and system modules
2015-05-06 01:27:09 +00:00
#
# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
# If nothing is specified, the version won't be checked (i.e. any version will be accepted).
# example:
2016-11-14 18:56:50 +00:00
# find_package(SFML COMPONENTS ...) # no specific version required
# find_package(SFML 2 COMPONENTS ...) # any 2.x version
# find_package(SFML 2.4 COMPONENTS ...) # version 2.4 or greater
2015-05-06 01:27:09 +00:00
#
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
# Since you have to link yourself all the SFML dependencies when you link it statically, the following
# additional variables are defined: SFML_XXX_DEPENDENCIES and SFML_DEPENDENCIES (see their detailed
# description below).
# In case of static linking, the SFML_STATIC macro will also be defined by this script.
# example:
# set(SFML_STATIC_LIBRARIES TRUE)
# find_package(SFML 2 COMPONENTS network system)
#
# On Mac OS X if SFML_STATIC_LIBRARIES is not set to TRUE then by default CMake will search for frameworks unless
# CMAKE_FIND_FRAMEWORK is set to "NEVER" for example. Please refer to CMake documentation for more details.
# Moreover, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
# are available for both release and debug modes.
#
# If SFML is not installed in a standard path, you can use the SFML_ROOT CMake (or environment) variable
# to tell CMake where SFML is.
#
# Output
# ------
#
# This script defines the following variables:
# - For each specified module XXX (system, window, graphics, network, audio, main):
# - SFML_XXX_LIBRARY_DEBUG: the name of the debug library of the xxx module (set to SFML_XXX_LIBRARY_RELEASE is no debug version is found)
# - SFML_XXX_LIBRARY_RELEASE: the name of the release library of the xxx module (set to SFML_XXX_LIBRARY_DEBUG is no release version is found)
# - SFML_XXX_LIBRARY: the name of the library to link to for the xxx module (includes both debug and optimized names if necessary)
# - SFML_XXX_FOUND: true if either the debug or release library of the xxx module is found
# - SFML_XXX_DEPENDENCIES: the list of libraries the module depends on, in case of static linking
# - SFML_LIBRARIES: the list of all libraries corresponding to the required modules
# - SFML_FOUND: true if all the required modules are found
# - SFML_INCLUDE_DIR: the path where SFML headers are located (the directory containing the SFML/Config.hpp file)
# - SFML_DEPENDENCIES: the list of libraries SFML depends on, in case of static linking
#
# example:
# find_package(SFML 2 COMPONENTS system window graphics audio REQUIRED)
# include_directories(${SFML_INCLUDE_DIR})
# add_executable(myapp ...)
# target_link_libraries(myapp ${SFML_LIBRARIES})
# define the SFML_STATIC macro if static build was chosen
if ( SFML_STATIC_LIBRARIES )
2024-03-15 16:19:01 +00:00
add_compile_definitions ( SFML_STATIC )
2015-05-06 01:27:09 +00:00
endif ( )
# define the list of search paths for headers and libraries
set ( FIND_SFML_PATHS
$ { S F M L _ R O O T }
$ E N V { S F M L _ R O O T }
~ / L i b r a r y / F r a m e w o r k s
/ L i b r a r y / F r a m e w o r k s
/ u s r / l o c a l
/ u s r
/ s w
/ o p t / l o c a l
/ o p t / c s w
/ o p t )
# find the SFML include directory
find_path ( SFML_INCLUDE_DIR SFML/Config.hpp
2016-12-21 21:02:55 +00:00
P A T H _ S U F F I X E S i n c l u d e
2015-05-06 01:27:09 +00:00
P A T H S $ { F I N D _ S F M L _ P A T H S } )
# check the version number
set ( SFML_VERSION_OK TRUE )
if ( SFML_FIND_VERSION AND SFML_INCLUDE_DIR )
# extract the major and minor version numbers from SFML/Config.hpp
# we have to handle framework a little bit differently:
if ( "${SFML_INCLUDE_DIR}" MATCHES "SFML.framework" )
set ( SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/Headers/Config.hpp" )
else ( )
set ( SFML_CONFIG_HPP_INPUT "${SFML_INCLUDE_DIR}/SFML/Config.hpp" )
endif ( )
FILE ( READ "${SFML_CONFIG_HPP_INPUT}" SFML_CONFIG_HPP_CONTENTS )
builder: update core dists and macOS build
cmake:
Add cmake option `DISABLE_MACOS_PACKAGE_MANAGERS` to disable
automatically using macOS Homebrew, MacPorts or Fink.
Use `-Ofast` instead of `-O2` for default compiler optimization flags,
which enables `-ffast-math` among a few other tweaks. There is a lot of
controversy about this, but in our testing on MSVC with `/fp:fast` the
performance increase for this specific app is dramatic.
Update version regexps on the SFML headers in `FindSFML.cmake` to allow
for a variable number of spaces between the macro and its definition.
Update the version of the Sparkle update checker framework for macOS
from 1.23.0 to 2.3.0-beta.2, and add a command to the cmake commands for
copying the framework to the `.app` to delete it first if already
copied.
Builder dist changes:
Updates:
dist old v new v
==============================================================
xz 5.2.4 5.2.6
openssl 1.1.1f 1.1.1g
curl 7.65.3 7.85.0
ccache 3.4.3 4.6.3
cmake 3.19.4 3.24.1
autoconf 2.69 2.71
autoconf-archive 2017.09.28 2022.09.03
libtool 2.4.6 2.4.7
help2man 1.47.5 1.49.2
libiconv 1.16 1.17
gsed 4.4 4.8
bison 3.0.5 3.8.2
texinfo 6.5 6.8
flex e7d45afc ea6493d9
libicu 65_1 71_1
nasm 2.14.02 2.15.05
pcre 8.41 8.45
libffi 3.2.1 3.4.2
libxml2 2.9.12 2.10.2
libxslt 1.1.33-rc2 1.1.37
XML-SAX 0.99 1.02
expat 2.2.4 2.4.8
libjpeg-turbo 2.0.4 2.1.4
libtiff 4.1.0 4.4.0
freetype 2.10.0 2.12.1
libgd 2.2.5 2.3.3
liberation 2.0.1 2.1.5
urw 91edd6ec 20200910
graphviz 4bf0ec9b 5.0.1
python2 2.7.15 2.7.18
python3 3.9.1 3.10.6
swig 3.0.12 4.0.2
doxygen 1.8.14 1.9.5
bakefile 33c270a5 7a218d89
XML-Parser 2.44 2.46
ninja 1.9.0 1.11.1
meson 0.51.2 0.63.2
glib 2.62.2 51251940
libgpg-error 1.41 1.45
libgcrypt 1.8.5 1.10.1
libsecret 0.19.1 0.20.5
sdl2 2.0.10 2.24.0
flac 1.3.3 1.3.4
libogg 1.3.4 1.3.5
libvorbis 1.3.6 1.3.7
harfbuzz 1.7.5 5.1.0
sfml 03375688 2.5.1
shared-mime-info 1.9 2.2
wxwidgets 9cc0c9a0 31720e1e
graphite2 ce0e793f 425da3d0
xvidcore 1.3.5 1.3.7
fribidi 1.0.1 1.0.12
libgsm 1.0.18 1.0.22
libmodplug 5a39f591 d1b97ed0
libopencore-amrnb 0.1.5 0.1.6
snappy 1.1.7 af720f9a
speex 1.2.0 1.2.1
vidstab 1.1.0 90c76aca
libvo-amrwbenc 0.1.3 3b3fcd0d
libass 0.14.0 0.16.0
libbluray 1.1.2 1.3.2
libvpx 1.8.1 1.12.0
libx264 20190913-2245 f7074e12
libxavs distrotech-xavs-git 8300fbf4
libzmq 4.2.2 4.3.4
ffmpeg 4.3.1 5.1.1
Removed dists:
dist ver
=========================
zlib 1.2.11
pkgconfig 0.29.2
docbook5.0 5.0
libwavpack 5.1.0
Added dists:
dist ver
========================
zlib-ng ce01b1e4
zstd 1.5.2
hiredis 1.0.2
pkgconf 1.9.3
pcre2 10.40
docbook5.0.1 5.0.1
docbook5.1 5.1
Changes:
Update all non-working dist URLs.
Replace zlib 1.2.11 with a recent zlib-ng built with `--zlib-compat`.
Add zstd and hiredis, new deps of ccache.
Replace pkgconfig with pkgconf.
Use both pcre1 and pcre2.
Remove the libxml2-python dist alias and rebuild libxml2 `--with-python`
and `--with-python3` after python 2 and 3 have built.
Remove libwavpack as ffmpeg 5 no longer uses it as a dependency.
Builder core:
Rename some of the directories and files to be a bit nicer.
Add `-Ofast -march=core2 -mtune=generic -pipe` to the global
`{C,CXX,OBJC,LD}FLAGS`. These are the optimization settings used by
default in the project as well, while `-pipe` significantly reduces
build time by making the compiler use pipes internally.
Add `-DFLOAT_APPROX` to the global `{CPP,C,CXX,OBJC}FLAGS` because we
are now using `-Ofast` and consequently, `-ffast-math`.
Set the `LIBRARY_PATH` variable in the global environment.
Make some adjustments for the new dist versions and make some other
improvements.
macOS builder fixes (tested on High Sierra 10.13 and Catalina 10.15):
Add support for predefined BUILD_ROOT and append BUILD_ROOT_SUFFIX.
Allow pre-defined CHECKOUT directory for building the project sources.
Sanitize `PATH` before build to remove `/usr/local` etc., use
/usr/local/bin/brew explicitly for deps instead.
If llvm and clang is installed from nix or brew, prepend the path of the
highest version found to `PATH`.
Remove `-lm` from build environment as macOS has never had an `m` math
library and this causes problems in some config checks.
Add LLVM `libunwind` from the LLVM archive.
Add a patch for `glib`'s `meson.build` to statically link
`gettext`/`libintl`, adds `-liconv -framework CoreFoundation`.
Add an extra location to check for `stdint.h` in XCode.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2022-11-11 14:19:47 +00:00
STRING ( REGEX REPLACE ".*#define *SFML_VERSION_MAJOR *([0-9]+).*" "\\1" SFML_VERSION_MAJOR "${SFML_CONFIG_HPP_CONTENTS}" )
STRING ( REGEX REPLACE ".*#define *SFML_VERSION_MINOR *([0-9]+).*" "\\1" SFML_VERSION_MINOR "${SFML_CONFIG_HPP_CONTENTS}" )
STRING ( REGEX REPLACE ".*#define *SFML_VERSION_PATCH *([0-9]+).*" "\\1" SFML_VERSION_PATCH "${SFML_CONFIG_HPP_CONTENTS}" )
2016-11-14 18:56:50 +00:00
if ( NOT "${SFML_VERSION_PATCH}" MATCHES "^[0-9]+$" )
set ( SFML_VERSION_PATCH 0 )
endif ( )
2015-05-06 01:27:09 +00:00
math ( EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10000 + ${SFML_FIND_VERSION_MINOR} * 100 + ${SFML_FIND_VERSION_PATCH}" )
# if we could extract them, compare with the requested version number
if ( SFML_VERSION_MAJOR )
# transform version numbers to an integer
math ( EXPR SFML_VERSION "${SFML_VERSION_MAJOR} * 10000 + ${SFML_VERSION_MINOR} * 100 + ${SFML_VERSION_PATCH}" )
# compare them
if ( SFML_VERSION LESS SFML_REQUESTED_VERSION )
set ( SFML_VERSION_OK FALSE )
endif ( )
else ( )
# SFML version is < 2.0
if ( SFML_REQUESTED_VERSION GREATER 10900 )
set ( SFML_VERSION_OK FALSE )
set ( SFML_VERSION_MAJOR 1 )
set ( SFML_VERSION_MINOR x )
set ( SFML_VERSION_PATCH x )
endif ( )
endif ( )
endif ( )
# find the requested modules
set ( SFML_FOUND TRUE ) # will be set to false if one of the required modules is not found
foreach ( FIND_SFML_COMPONENT ${ SFML_FIND_COMPONENTS } )
string ( TOLOWER ${ FIND_SFML_COMPONENT } FIND_SFML_COMPONENT_LOWER )
string ( TOUPPER ${ FIND_SFML_COMPONENT } FIND_SFML_COMPONENT_UPPER )
set ( FIND_SFML_COMPONENT_NAME sfml- ${ FIND_SFML_COMPONENT_LOWER } )
# no suffix for sfml-main, it is always a static library
if ( FIND_SFML_COMPONENT_LOWER STREQUAL "main" )
# release library
find_library ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_RELEASE
N A M E S $ { F I N D _ S F M L _ C O M P O N E N T _ N A M E }
P A T H _ S U F F I X E S l i b 6 4 l i b
P A T H S $ { F I N D _ S F M L _ P A T H S } )
# debug library
find_library ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DEBUG
N A M E S $ { F I N D _ S F M L _ C O M P O N E N T _ N A M E } - d
P A T H _ S U F F I X E S l i b 6 4 l i b
P A T H S $ { F I N D _ S F M L _ P A T H S } )
else ( )
# static release library
find_library ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_STATIC_RELEASE
N A M E S $ { F I N D _ S F M L _ C O M P O N E N T _ N A M E } - s
P A T H _ S U F F I X E S l i b 6 4 l i b
P A T H S $ { F I N D _ S F M L _ P A T H S } )
# static debug library
find_library ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_STATIC_DEBUG
N A M E S $ { F I N D _ S F M L _ C O M P O N E N T _ N A M E } - s - d
P A T H _ S U F F I X E S l i b 6 4 l i b
P A T H S $ { F I N D _ S F M L _ P A T H S } )
# dynamic release library
find_library ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DYNAMIC_RELEASE
N A M E S $ { F I N D _ S F M L _ C O M P O N E N T _ N A M E }
P A T H _ S U F F I X E S l i b 6 4 l i b
P A T H S $ { F I N D _ S F M L _ P A T H S } )
# dynamic debug library
find_library ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DYNAMIC_DEBUG
N A M E S $ { F I N D _ S F M L _ C O M P O N E N T _ N A M E } - d
P A T H _ S U F F I X E S l i b 6 4 l i b
P A T H S $ { F I N D _ S F M L _ P A T H S } )
# choose the entries that fit the requested link type
if ( SFML_STATIC_LIBRARIES )
if ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_STATIC_RELEASE )
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_RELEASE ${ SFML_${FIND_SFML_COMPONENT_UPPER } _LIBRARY_STATIC_RELEASE} )
endif ( )
if ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_STATIC_DEBUG )
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DEBUG ${ SFML_${FIND_SFML_COMPONENT_UPPER } _LIBRARY_STATIC_DEBUG} )
endif ( )
else ( )
if ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DYNAMIC_RELEASE )
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_RELEASE ${ SFML_${FIND_SFML_COMPONENT_UPPER } _LIBRARY_DYNAMIC_RELEASE} )
endif ( )
if ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DYNAMIC_DEBUG )
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DEBUG ${ SFML_${FIND_SFML_COMPONENT_UPPER } _LIBRARY_DYNAMIC_DEBUG} )
endif ( )
endif ( )
endif ( )
if ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DEBUG OR SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_RELEASE )
# library found
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _FOUND TRUE )
2016-11-14 18:56:50 +00:00
2015-05-06 01:27:09 +00:00
# if both are found, set SFML_XXX_LIBRARY to contain both
if ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DEBUG AND SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_RELEASE )
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY debug ${ SFML_${FIND_SFML_COMPONENT_UPPER } _LIBRARY_DEBUG}
o p t i m i z e d $ { S F M L _ $ { F I N D _ S F M L _ C O M P O N E N T _ U P P E R } _ L I B R A R Y _ R E L E A S E } )
endif ( )
# if only one debug/release variant is found, set the other to be equal to the found one
if ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DEBUG AND NOT SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_RELEASE )
# debug and not release
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_RELEASE ${ SFML_${FIND_SFML_COMPONENT_UPPER } _LIBRARY_DEBUG} )
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY ${ SFML_${FIND_SFML_COMPONENT_UPPER } _LIBRARY_DEBUG} )
endif ( )
if ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_RELEASE AND NOT SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DEBUG )
# release and not debug
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY_DEBUG ${ SFML_${FIND_SFML_COMPONENT_UPPER } _LIBRARY_RELEASE} )
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY ${ SFML_${FIND_SFML_COMPONENT_UPPER } _LIBRARY_RELEASE} )
endif ( )
else ( )
# library not found
set ( SFML_FOUND FALSE )
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _FOUND FALSE )
set ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY "" )
set ( FIND_SFML_MISSING "${FIND_SFML_MISSING} SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY" )
endif ( )
# mark as advanced
MARK_AS_ADVANCED ( SFML_ ${ FIND_SFML_COMPONENT_UPPER } _LIBRARY
S F M L _ $ { F I N D _ S F M L _ C O M P O N E N T _ U P P E R } _ L I B R A R Y _ R E L E A S E
S F M L _ $ { F I N D _ S F M L _ C O M P O N E N T _ U P P E R } _ L I B R A R Y _ D E B U G
S F M L _ $ { F I N D _ S F M L _ C O M P O N E N T _ U P P E R } _ L I B R A R Y _ S T A T I C _ R E L E A S E
S F M L _ $ { F I N D _ S F M L _ C O M P O N E N T _ U P P E R } _ L I B R A R Y _ S T A T I C _ D E B U G
S F M L _ $ { F I N D _ S F M L _ C O M P O N E N T _ U P P E R } _ L I B R A R Y _ D Y N A M I C _ R E L E A S E
S F M L _ $ { F I N D _ S F M L _ C O M P O N E N T _ U P P E R } _ L I B R A R Y _ D Y N A M I C _ D E B U G )
# add to the global list of libraries
set ( SFML_LIBRARIES ${ SFML_LIBRARIES } "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}" )
endforeach ( )
# in case of static linking, we must also define the list of all the dependencies of SFML libraries
if ( SFML_STATIC_LIBRARIES )
# detect the OS
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "Windows" )
set ( FIND_SFML_OS_WINDOWS 1 )
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES "Linux" )
set ( FIND_SFML_OS_LINUX 1 )
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES "FreeBSD" )
set ( FIND_SFML_OS_FREEBSD 1 )
elseif ( ${ CMAKE_SYSTEM_NAME } MATCHES "Darwin" )
set ( FIND_SFML_OS_MACOSX 1 )
endif ( )
# start with an empty list
set ( SFML_DEPENDENCIES )
set ( FIND_SFML_DEPENDENCIES_NOTFOUND )
# macro that searches for a 3rd-party library
macro ( find_sfml_dependency output friendlyname )
2016-11-14 18:56:50 +00:00
# No lookup in environment variables (PATH on Windows), as they may contain wrong library versions
find_library ( ${ output } NAMES ${ ARGN } PATHS ${ FIND_SFML_PATHS } PATH_SUFFIXES lib NO_SYSTEM_ENVIRONMENT_PATH )
2015-05-06 01:27:09 +00:00
if ( ${ ${output } } STREQUAL "${output}-NOTFOUND" )
unset ( output )
set ( FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${friendlyname}" )
endif ( )
endmacro ( )
# sfml-system
list ( FIND SFML_FIND_COMPONENTS "system" FIND_SFML_SYSTEM_COMPONENT )
if ( NOT ${ FIND_SFML_SYSTEM_COMPONENT } EQUAL -1 )
# update the list -- these are only system libraries, no need to find them
if ( FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD OR FIND_SFML_OS_MACOSX )
set ( SFML_SYSTEM_DEPENDENCIES "pthread" )
endif ( )
if ( FIND_SFML_OS_LINUX )
2016-11-14 18:56:50 +00:00
set ( SFML_SYSTEM_DEPENDENCIES ${ SFML_SYSTEM_DEPENDENCIES } "rt" )
2015-05-06 01:27:09 +00:00
endif ( )
if ( FIND_SFML_OS_WINDOWS )
set ( SFML_SYSTEM_DEPENDENCIES "winmm" )
endif ( )
set ( SFML_DEPENDENCIES ${ SFML_SYSTEM_DEPENDENCIES } ${ SFML_DEPENDENCIES } )
endif ( )
# sfml-network
list ( FIND SFML_FIND_COMPONENTS "network" FIND_SFML_NETWORK_COMPONENT )
if ( NOT ${ FIND_SFML_NETWORK_COMPONENT } EQUAL -1 )
# update the list -- these are only system libraries, no need to find them
if ( FIND_SFML_OS_WINDOWS )
set ( SFML_NETWORK_DEPENDENCIES "ws2_32" )
endif ( )
set ( SFML_DEPENDENCIES ${ SFML_NETWORK_DEPENDENCIES } ${ SFML_DEPENDENCIES } )
endif ( )
# sfml-window
list ( FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT )
if ( NOT ${ FIND_SFML_WINDOW_COMPONENT } EQUAL -1 )
# find libraries
2016-11-14 18:56:50 +00:00
if ( FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD )
2015-05-06 01:27:09 +00:00
find_sfml_dependency ( X11_LIBRARY "X11" X11 )
find_sfml_dependency ( XRANDR_LIBRARY "Xrandr" Xrandr )
2016-11-14 18:56:50 +00:00
endif ( )
if ( FIND_SFML_OS_LINUX )
find_sfml_dependency ( UDEV_LIBRARIES "UDev" udev libudev )
2015-05-06 01:27:09 +00:00
endif ( )
# update the list
if ( FIND_SFML_OS_WINDOWS )
set ( SFML_WINDOW_DEPENDENCIES ${ SFML_WINDOW_DEPENDENCIES } "opengl32" "winmm" "gdi32" )
2016-11-14 18:56:50 +00:00
elseif ( FIND_SFML_OS_LINUX )
set ( SFML_WINDOW_DEPENDENCIES ${ SFML_WINDOW_DEPENDENCIES } "GL" ${ X11_LIBRARY } ${ XRANDR_LIBRARY } ${ UDEV_LIBRARIES } )
elseif ( FIND_SFML_OS_FREEBSD )
set ( SFML_WINDOW_DEPENDENCIES ${ SFML_WINDOW_DEPENDENCIES } "GL" ${ X11_LIBRARY } ${ XRANDR_LIBRARY } "usbhid" )
2015-05-06 01:27:09 +00:00
elseif ( FIND_SFML_OS_MACOSX )
set ( SFML_WINDOW_DEPENDENCIES ${ SFML_WINDOW_DEPENDENCIES } "-framework OpenGL -framework Foundation -framework AppKit -framework IOKit -framework Carbon" )
endif ( )
set ( SFML_DEPENDENCIES ${ SFML_WINDOW_DEPENDENCIES } ${ SFML_DEPENDENCIES } )
endif ( )
# sfml-graphics
list ( FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT )
if ( NOT ${ FIND_SFML_GRAPHICS_COMPONENT } EQUAL -1 )
2016-11-14 18:56:50 +00:00
2015-05-06 01:27:09 +00:00
# find libraries
find_sfml_dependency ( FREETYPE_LIBRARY "FreeType" freetype )
find_sfml_dependency ( JPEG_LIBRARY "libjpeg" jpeg )
# update the list
2016-11-14 18:56:50 +00:00
set ( SFML_GRAPHICS_DEPENDENCIES ${ FREETYPE_LIBRARY } ${ JPEG_LIBRARY } )
2015-05-06 01:27:09 +00:00
set ( SFML_DEPENDENCIES ${ SFML_GRAPHICS_DEPENDENCIES } ${ SFML_DEPENDENCIES } )
endif ( )
# sfml-audio
list ( FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT )
if ( NOT ${ FIND_SFML_AUDIO_COMPONENT } EQUAL -1 )
# find libraries
find_sfml_dependency ( OPENAL_LIBRARY "OpenAL" openal openal32 )
2016-11-14 18:56:50 +00:00
find_sfml_dependency ( OGG_LIBRARY "Ogg" ogg )
find_sfml_dependency ( VORBIS_LIBRARY "Vorbis" vorbis )
find_sfml_dependency ( VORBISFILE_LIBRARY "VorbisFile" vorbisfile )
find_sfml_dependency ( VORBISENC_LIBRARY "VorbisEnc" vorbisenc )
find_sfml_dependency ( FLAC_LIBRARY "FLAC" FLAC )
2015-05-06 01:27:09 +00:00
# update the list
2016-11-14 18:56:50 +00:00
set ( SFML_AUDIO_DEPENDENCIES ${ OPENAL_LIBRARY } ${ FLAC_LIBRARY } ${ VORBISENC_LIBRARY } ${ VORBISFILE_LIBRARY } ${ VORBIS_LIBRARY } ${ OGG_LIBRARY } )
set ( SFML_DEPENDENCIES ${ SFML_DEPENDENCIES } ${ SFML_AUDIO_DEPENDENCIES } )
2015-05-06 01:27:09 +00:00
endif ( )
endif ( )
# handle errors
if ( NOT SFML_VERSION_OK )
# SFML version not ok
set ( FIND_SFML_ERROR "SFML found but version too low (requested: ${SFML_FIND_VERSION}, found: ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH})" )
set ( SFML_FOUND FALSE )
elseif ( SFML_STATIC_LIBRARIES AND FIND_SFML_DEPENDENCIES_NOTFOUND )
set ( FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})" )
set ( SFML_FOUND FALSE )
elseif ( NOT SFML_FOUND )
# include directory or library not found
set ( FIND_SFML_ERROR "Could NOT find SFML (missing: ${FIND_SFML_MISSING})" )
endif ( )
if ( NOT SFML_FOUND )
if ( SFML_FIND_REQUIRED )
# fatal error
message ( FATAL_ERROR ${ FIND_SFML_ERROR } )
elseif ( NOT SFML_FIND_QUIETLY )
# error but continue
message ( "${FIND_SFML_ERROR}" )
endif ( )
endif ( )
# handle success
2016-11-14 18:56:50 +00:00
if ( SFML_FOUND AND NOT SFML_FIND_QUIETLY )
2015-05-06 01:27:09 +00:00
message ( STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH} in ${SFML_INCLUDE_DIR}" )
endif ( )