Added a FindSFML.cmake file for CMake

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1571 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-10-04 21:16:12 +00:00
parent 19cb364afe
commit 076456aa91
2 changed files with 74 additions and 0 deletions

View File

@ -57,6 +57,8 @@ install(DIRECTORY include
DESTINATION . DESTINATION .
COMPONENT devel COMPONENT devel
PATTERN ".svn" EXCLUDE) PATTERN ".svn" EXCLUDE)
install(FILES cmake/Modules/FindSFML.cmake
DESTINATION ${INSTALL_MISC_DIR}/cmake/Modules)
install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR}) install(FILES license.txt DESTINATION ${INSTALL_MISC_DIR})
if(WINDOWS) if(WINDOWS)
install(FILES extlibs/bin/libsndfile-1.dll DESTINATION bin) install(FILES extlibs/bin/libsndfile-1.dll DESTINATION bin)

View File

@ -0,0 +1,72 @@
# Locate the SFML library
#
# This module defines
# SFML_FOUND, if false, do not try to link to SFML
# SFML_XXX_LIBRARY library corresponding to the XXX component
# SFML_LIBRARIES, list containing all the libraries corresponding to the requested components
# SFML_INCLUDE_DIR, where to find SFML/Config.hpp
#
# To select a particular debug/release/static/dynamic variant of the SFML libraries,
# you must set these variables before calling find_package(SFML ...):
# - SFML_DEBUG_LIBRARIES: 1 for debug, 0 for release
# - SFML_STATIC_LIBRARIES: 1 for static, 0 for dynamic
# If not specified, both are set to 0 (release dynamic)
# deduce the SFML libraries prefix from the major version number
set(FIND_SFML_LIB_PREFIX "sfml-")
if(${SFML_FIND_VERSION_MAJOR} GREATER 1)
set(FIND_SFML_LIB_PREFIX "sfml${SFML_FIND_VERSION_MAJOR}-")
endif()
# deduce the libraries suffix from the options
set(FIND_SFML_LIB_SUFFIX "")
if(SFML_STATIC_LIBRARIES)
set(FIND_SFML_LIB_SUFFIX "${FIND_SFML_LIB_SUFFIX}-s")
endif()
if(SFML_DEBUG_LIBRARIES)
set(FIND_SFML_LIB_SUFFIX "${FIND_SFML_LIB_SUFFIX}-d")
endif()
# find the SFML include directory
find_path(SFML_INCLUDE_DIR SFML/Config.hpp
PATH_SUFFIXES include
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local/
/usr/
/sw # Fink
/opt/local/ # DarwinPorts
/opt/csw/ # Blastwave
/opt/
${SFMLDIR})
# find the requested components
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_VAR SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY)
set(FIND_SFML_COMPONENT_NAME ${FIND_SFML_LIB_PREFIX}${FIND_SFML_COMPONENT_LOWER}${FIND_SFML_LIB_SUFFIX})
find_library(${FIND_SFML_COMPONENT_VAR}
NAMES ${FIND_SFML_COMPONENT_NAME}
PATH_SUFFIXES lib64 lib
PATHS
~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
${SFMLDIR})
set(SFML_LIBRARIES_NAMES ${SFML_LIBRARIES_NAMES} ${FIND_SFML_COMPONENT_VAR})
set(SFML_LIBRARIES ${SFML_LIBRARIES} ${${FIND_SFML_COMPONENT_VAR}})
endforeach()
# handle the QUIETLY and REQUIRED arguments and set SFML_FOUND to TRUE if all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SFML DEFAULT_MSG SFML_INCLUDE_DIR ${SFML_LIBRARIES_NAMES})
MARK_AS_ADVANCED(SFML_INCLUDE_DIR ${SFML_LIBRARIES_NAMES})