PageRenderTime 33ms CodeModel.GetById 31ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 1ms

/extlibs/SFML/cmake/Modules/FindSFML.cmake

https://bitbucket.org/hugoruscitti/pilascpp
CMake | 74 lines | 48 code | 8 blank | 18 comment | 2 complexity | 880499c1235d1fd1ba3c07ccb403d716 MD5 | raw file
 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 (release)
 6#  SFML_XXX_LIBRARY_DEBUG, library corresponding to the XXX component (debug)
 7#  SFML_LIBRARIES, list containing all the libraries corresponding to the requested components
 8#  SFML_INCLUDE_DIR, where to find SFML/Config.hpp
 9#
10# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
11# you must set the SFML_STATIC_LIBRARIES variable to TRUE before calling find_package(SFML ...).
12
13# deduce the SFML libraries prefix from the major version number
14set(FIND_SFML_LIB_PREFIX "sfml-")
15if(${SFML_FIND_VERSION_MAJOR} GREATER 1)
16    set(FIND_SFML_LIB_PREFIX "sfml${SFML_FIND_VERSION_MAJOR}-")
17endif()
18
19# deduce the libraries suffix from the options
20set(FIND_SFML_LIB_SUFFIX "")
21if(SFML_STATIC_LIBRARIES)
22    set(FIND_SFML_LIB_SUFFIX "${FIND_SFML_LIB_SUFFIX}-s")
23endif()
24
25# find the SFML include directory
26find_path(SFML_INCLUDE_DIR SFML/Config.hpp
27          PATH_SUFFIXES include
28          PATHS
29          ~/Library/Frameworks
30          /Library/Frameworks
31          /usr/local/
32          /usr/
33          /sw          # Fink
34          /opt/local/  # DarwinPorts
35          /opt/csw/    # Blastwave
36          /opt/
37          ${SFMLDIR})
38
39# find the requested components
40set(FIND_SFML_LIB_PATHS ~/Library/Frameworks
41                        /Library/Frameworks
42                        /usr/local
43                        /usr
44                        /sw
45                        /opt/local
46                        /opt/csw
47                        /opt
48                        ${SFMLDIR})
49foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
50    string(TOLOWER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_LOWER)
51    string(TOUPPER ${FIND_SFML_COMPONENT} FIND_SFML_COMPONENT_UPPER)
52    set(FIND_SFML_COMPONENT_VAR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY)
53    set(FIND_SFML_COMPONENT_NAME ${FIND_SFML_LIB_PREFIX}${FIND_SFML_COMPONENT_LOWER}${FIND_SFML_LIB_SUFFIX})
54
55    # release library
56    find_library(${FIND_SFML_COMPONENT_VAR}
57                 NAMES ${FIND_SFML_COMPONENT_NAME}
58                 PATH_SUFFIXES lib64 lib
59                 PATHS ${FIND_SFML_LIB_PATHS})
60
61    # debug library
62    find_library(${FIND_SFML_COMPONENT_VAR}_DEBUG
63                 NAMES ${FIND_SFML_COMPONENT_NAME}-d
64                 PATH_SUFFIXES lib64 lib
65                 PATHS ${FIND_SFML_LIB_PATHS})
66
67    set(SFML_LIBRARIES_NAMES ${SFML_LIBRARIES_NAMES} ${FIND_SFML_COMPONENT_VAR})
68    set(SFML_LIBRARIES ${SFML_LIBRARIES} ${${FIND_SFML_COMPONENT_VAR}})
69endforeach()
70
71# handle the QUIETLY and REQUIRED arguments and set SFML_FOUND to TRUE if all listed variables are TRUE
72INCLUDE(FindPackageHandleStandardArgs)
73FIND_PACKAGE_HANDLE_STANDARD_ARGS(SFML DEFAULT_MSG SFML_INCLUDE_DIR ${SFML_LIBRARIES_NAMES})
74MARK_AS_ADVANCED(SFML_INCLUDE_DIR ${SFML_LIBRARIES_NAMES})