Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 73 lines (65 sloc) 2.824 kb
076456a @LaurentGomila Added a FindSFML.cmake file for CMake
LaurentGomila authored
1 # Locate the SFML library
2 #
3 # This module defines
4 # SFML_FOUND, if false, do not try to link to SFML
5 # SFML_XXX_LIBRARY library corresponding to the XXX component
6 # SFML_LIBRARIES, list containing all the libraries corresponding to the requested components
7 # SFML_INCLUDE_DIR, where to find SFML/Config.hpp
8 #
9 # To select a particular debug/release/static/dynamic variant of the SFML libraries,
10 # you must set these variables before calling find_package(SFML ...):
11 # - SFML_DEBUG_LIBRARIES: 1 for debug, 0 for release
12 # - SFML_STATIC_LIBRARIES: 1 for static, 0 for dynamic
13 # If not specified, both are set to 0 (release dynamic)
14
15 # deduce the SFML libraries prefix from the major version number
16 set(FIND_SFML_LIB_PREFIX "sfml-")
17 if(${SFML_FIND_VERSION_MAJOR} GREATER 1)
18 set(FIND_SFML_LIB_PREFIX "sfml${SFML_FIND_VERSION_MAJOR}-")
19 endif()
20
21 # deduce the libraries suffix from the options
22 set(FIND_SFML_LIB_SUFFIX "")
23 if(SFML_STATIC_LIBRARIES)
24 set(FIND_SFML_LIB_SUFFIX "${FIND_SFML_LIB_SUFFIX}-s")
25 endif()
26 if(SFML_DEBUG_LIBRARIES)
27 set(FIND_SFML_LIB_SUFFIX "${FIND_SFML_LIB_SUFFIX}-d")
28 endif()
29
30 # find the SFML include directory
31 find_path(SFML_INCLUDE_DIR SFML/Config.hpp
32 PATH_SUFFIXES include
33 PATHS
34 ~/Library/Frameworks
35 /Library/Frameworks
36 /usr/local/
37 /usr/
38 /sw # Fink
39 /opt/local/ # DarwinPorts
40 /opt/csw/ # Blastwave
41 /opt/
42 ${SFMLDIR})
43
44 # find the requested components
45 foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
46 string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
47 string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
48 set(FIND_SFML_COMPONENT_VAR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY)
49 set(FIND_SFML_COMPONENT_NAME ${FIND_SFML_LIB_PREFIX}${FIND_SFML_COMPONENT_LOWER}${FIND_SFML_LIB_SUFFIX})
50
51 find_library(${FIND_SFML_COMPONENT_VAR}
52 NAMES ${FIND_SFML_COMPONENT_NAME}
53 PATH_SUFFIXES lib64 lib
54 PATHS
55 ~/Library/Frameworks
56 /Library/Frameworks
57 /usr/local
58 /usr
59 /sw
60 /opt/local
61 /opt/csw
62 /opt
63 ${SFMLDIR})
64
65 set(SFML_LIBRARIES_NAMES ${SFML_LIBRARIES_NAMES} ${FIND_SFML_COMPONENT_VAR})
66 set(SFML_LIBRARIES ${SFML_LIBRARIES} ${${FIND_SFML_COMPONENT_VAR}})
67 endforeach()
68
69 # handle the QUIETLY and REQUIRED arguments and set SFML_FOUND to TRUE if all listed variables are TRUE
70 INCLUDE(FindPackageHandleStandardArgs)
71 FIND_PACKAGE_HANDLE_STANDARD_ARGS(SFML DEFAULT_MSG SFML_INCLUDE_DIR ${SFML_LIBRARIES_NAMES})
72 MARK_AS_ADVANCED(SFML_INCLUDE_DIR ${SFML_LIBRARIES_NAMES})
Something went wrong with that request. Please try again.