summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJames Cowgill <james410@cowgill.org.uk>2013-08-23 09:57:55 +0100
committerJames Cowgill <james410@cowgill.org.uk>2013-08-23 09:57:55 +0100
commit9a298ca833d9b6a3425bb30c2e52cf04e34aeb7c (patch)
treed46630a885bcea03bbea036b86c645dc6c55708d /cmake
parent0969839d538a385254c6eced9648acc7299876cc (diff)
Imported Upstream version 2.1+dfsg
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Config.cmake75
-rw-r--r--cmake/Macros.cmake256
-rw-r--r--cmake/Modules/FindGLEW.cmake65
-rw-r--r--cmake/Modules/FindSFML.cmake209
-rw-r--r--cmake/Modules/FindSndfile.cmake28
5 files changed, 633 insertions, 0 deletions
diff --git a/cmake/Config.cmake b/cmake/Config.cmake
new file mode 100644
index 0000000..ce9bb2c
--- /dev/null
+++ b/cmake/Config.cmake
@@ -0,0 +1,75 @@
+# detect the OS
+if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
+ set(WINDOWS 1)
+
+ # detect the architecture (note: this test won't work for cross-compilation)
+ include(CheckTypeSize)
+ check_type_size(void* SIZEOF_VOID_PTR)
+ if("${SIZEOF_VOID_PTR}" STREQUAL "4")
+ set(ARCH_32BITS 1)
+ elseif("${SIZEOF_VOID_PTR}" STREQUAL "8")
+ set(ARCH_64BITS 1)
+ else()
+ message(FATAL_ERROR "Unsupported architecture")
+ return()
+ endif()
+elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+ set(LINUX 1)
+elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
+ # FreeBSD compile path is the same as Linux
+ set(LINUX 1)
+elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
+ set(MACOSX 1)
+
+ # detect OS X version. (use '/usr/bin/sw_vers -productVersion' to extract V from '10.V.x'.)
+ EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW)
+ STRING(REGEX REPLACE "10\\.([0-9]).*" "\\1" MACOSX_VERSION "${MACOSX_VERSION_RAW}")
+ if(${MACOSX_VERSION} LESS 5)
+ message(FATAL_ERROR "Unsupported version of OS X : ${MACOSX_VERSION_RAW}")
+ return()
+ endif()
+else()
+ message(FATAL_ERROR "Unsupported operating system")
+ return()
+endif()
+
+# detect the compiler and its version
+# Note: on some platforms (OS X), CMAKE_COMPILER_IS_GNUCXX is true
+# even when CLANG is used, therefore the Clang test is done first
+if(CMAKE_CXX_COMPILER MATCHES ".*clang[+][+]" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ # CMAKE_CXX_COMPILER_ID is an internal CMake variable subject to change,
+ # but there is no other way to detect CLang at the moment
+ set(COMPILER_CLANG 1)
+ execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE CLANG_VERSION_OUTPUT)
+ string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
+elseif(CMAKE_COMPILER_IS_GNUCXX)
+ set(COMPILER_GCC 1)
+ execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
+ string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" GCC_VERSION "${GCC_VERSION_OUTPUT}")
+ execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
+ string(STRIP "${GCC_MACHINE}" GCC_MACHINE)
+ if(${GCC_MACHINE} MATCHES ".*w64.*")
+ set(COMPILER_GCC_W64 1)
+ endif()
+elseif(MSVC)
+ set(COMPILER_MSVC 1)
+ if(MSVC_VERSION EQUAL 1400)
+ set(MSVC_VERSION 2005)
+ elseif(MSVC_VERSION EQUAL 1500)
+ set(MSVC_VERSION 2008)
+ elseif(MSVC_VERSION EQUAL 1600)
+ set(MSVC_VERSION 2010)
+ elseif(MSVC_VERSION EQUAL 1700)
+ set(MSVC_VERSION 2011)
+ endif()
+else()
+ message(FATAL_ERROR "Unsupported compiler")
+ return()
+endif()
+
+# define the install directory for miscellaneous files
+if(WINDOWS)
+ set(INSTALL_MISC_DIR .)
+elseif(UNIX)
+ set(INSTALL_MISC_DIR share/SFML)
+endif()
diff --git a/cmake/Macros.cmake b/cmake/Macros.cmake
new file mode 100644
index 0000000..072fe75
--- /dev/null
+++ b/cmake/Macros.cmake
@@ -0,0 +1,256 @@
+# some of these macros are inspired from the boost/cmake macros
+
+# this macro adds external dependencies to a static target,
+# compensating for the lack of a link step when building a static library.
+# every compiler has its own way of doing it:
+# - VC++ supports it directly through the static library flags
+# - MinGW/gcc doesn't support it, but as a static library is nothing more than an archive,
+# we can simply merge the external dependencies to our generated target as a post-build step
+# - for other compilers and OSes, static build is not encouraged so we don't try to
+# pre-link dependencies, we just "link" them so that the SFML samples can compile
+# out-of-the-box (CMake forwards the dependencies automatically)
+macro(sfml_static_add_libraries target)
+ if(WINDOWS AND COMPILER_GCC)
+ # Windows - gcc
+ foreach(lib ${ARGN})
+ if(NOT ${lib} MATCHES ".*/.*")
+ string(REGEX REPLACE "(.*)/bin/.*\\.exe" "\\1" STANDARD_LIBS_PATH "${CMAKE_CXX_COMPILER}")
+ if(COMPILER_GCC_W64)
+ set(lib "${STANDARD_LIBS_PATH}/${GCC_MACHINE}/lib/lib${lib}.a")
+ else()
+ set(lib "${STANDARD_LIBS_PATH}/lib/lib${lib}.a")
+ endif()
+ endif()
+ string(TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE)
+ get_target_property(TARGET_FILENAME ${target} ${BUILD_TYPE}_LOCATION)
+ add_custom_command(TARGET ${target}
+ POST_BUILD
+ COMMAND ${CMAKE_AR} x ${lib}
+ COMMAND ${CMAKE_AR} rcs ${TARGET_FILENAME} *.o
+ COMMAND del *.o /f /q
+ VERBATIM)
+ endforeach()
+ elseif(MSVC)
+ # Visual C++
+ set(LIBRARIES "")
+ foreach(lib ${ARGN})
+ if(NOT ${lib} MATCHES ".*\\.lib")
+ set(lib ${lib}.lib)
+ endif()
+ if(MSVC_IDE AND MSVC_VERSION LESS 2010)
+ # for Visual Studio projects < 2010, we must add double quotes
+ # around paths because they may contain spaces
+ set(LIBRARIES "${LIBRARIES} &quot\\;${lib}&quot\\;")
+ else()
+ set(LIBRARIES "${LIBRARIES} \"${lib}\"")
+ endif()
+ endforeach()
+ set_target_properties(${target} PROPERTIES STATIC_LIBRARY_FLAGS ${LIBRARIES})
+ else()
+ # All other platforms
+ target_link_libraries(${target} ${ARGN})
+ endif()
+endmacro()
+
+# check if a value is contained in a list
+# sets ${var} to TRUE if the value is found
+macro(sfml_list_contains var value)
+ set(${var})
+ foreach(value2 ${ARGN})
+ if(${value} STREQUAL ${value2})
+ set(${var} TRUE)
+ endif()
+ endforeach()
+endmacro()
+
+# parse a list of arguments and options
+# ex: sfml_parse_arguments(THIS "SOURCES;DEPENDS" "FLAG" FLAG SOURCES s1 s2 s3 DEPENDS d1 d2)
+# will define the following variables:
+# - THIS_SOURCES (s1 s2 s3)
+# - THIS_DEPENDS (d1 d2)
+# - THIS_FLAG TRUE
+macro(sfml_parse_arguments prefix arg_names option_names)
+ foreach(arg_name ${arg_names})
+ set(${prefix}_${arg_name})
+ endforeach()
+ foreach(option_name ${option_names})
+ set(${prefix}_${option_name} FALSE)
+ endforeach()
+ set(current_arg_name)
+ set(current_arg_list)
+ foreach(arg ${ARGN})
+ sfml_list_contains(is_arg_name ${arg} ${arg_names})
+ if(is_arg_name)
+ set(${prefix}_${current_arg_name} ${current_arg_list})
+ set(current_arg_name ${arg})
+ set(current_arg_list)
+ else()
+ sfml_list_contains(is_option ${arg} ${option_names})
+ if(is_option)
+ set(${prefix}_${arg} TRUE)
+ else()
+ set(current_arg_list ${current_arg_list} ${arg})
+ endif()
+ endif()
+ endforeach()
+ set(${prefix}_${current_arg_name} ${current_arg_list})
+endmacro()
+
+# add a new target which is a SFML library
+# ex: sfml_add_library(sfml-graphics
+# SOURCES sprite.cpp image.cpp ...
+# DEPENDS sfml-window sfml-system
+# EXTERNAL_LIBS opengl freetype ...)
+macro(sfml_add_library target)
+
+ # parse the arguments
+ sfml_parse_arguments(THIS "SOURCES;DEPENDS;EXTERNAL_LIBS" "" ${ARGN})
+
+ # create the target
+ add_library(${target} ${THIS_SOURCES})
+
+ # define the export symbol of the module
+ string(REPLACE "-" "_" NAME_UPPER "${target}")
+ string(TOUPPER "${NAME_UPPER}" NAME_UPPER)
+ set_target_properties(${target} PROPERTIES DEFINE_SYMBOL ${NAME_UPPER}_EXPORTS)
+
+ # adjust the output file prefix/suffix to match our conventions
+ if(BUILD_SHARED_LIBS)
+ if(WINDOWS)
+ # include the major version number in Windows shared library names (but not import library names)
+ set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
+ set_target_properties(${target} PROPERTIES SUFFIX "-${VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}")
+ else()
+ set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
+ endif()
+ if (WINDOWS AND COMPILER_GCC)
+ # on Windows/gcc get rid of "lib" prefix for shared libraries,
+ # and transform the ".dll.a" suffix into ".a" for import libraries
+ set_target_properties(${target} PROPERTIES PREFIX "")
+ set_target_properties(${target} PROPERTIES IMPORT_SUFFIX ".a")
+ endif()
+ else()
+ set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -s-d)
+ set_target_properties(${target} PROPERTIES RELEASE_POSTFIX -s)
+ set_target_properties(${target} PROPERTIES MINSIZEREL_POSTFIX -s)
+ endif()
+
+ # set the version and soversion of the target (for compatible systems -- mostly Linuxes)
+ set_target_properties(${target} PROPERTIES SOVERSION ${VERSION_MAJOR})
+ set_target_properties(${target} PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR})
+
+ # set the target's folder (for IDEs that support it, e.g. Visual Studio)
+ set_target_properties(${target} PROPERTIES FOLDER "SFML")
+
+ # for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
+ if(WINDOWS AND COMPILER_GCC AND SFML_USE_STATIC_STD_LIBS)
+ if(NOT GCC_VERSION VERSION_LESS "4")
+ set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
+ endif()
+ endif()
+
+ # if using gcc >= 4.0 or clang >= 3.0 on a non-Windows platform, we must hide public symbols by default
+ # (exported ones are explicitely marked)
+ if(NOT WINDOWS AND ((COMPILER_GCC AND NOT GCC_VERSION VERSION_LESS "4") OR (COMPILER_CLANG AND NOT CLANG_VERSION VERSION_LESS "3")))
+ set_target_properties(${target} PROPERTIES COMPILE_FLAGS -fvisibility=hidden)
+ endif()
+
+ # link the target to its SFML dependencies
+ if(THIS_DEPENDS)
+ target_link_libraries(${target} ${THIS_DEPENDS})
+ endif()
+
+ # build frameworks or dylibs
+ if(MACOSX AND BUILD_SHARED_LIBS)
+ if(SFML_BUILD_FRAMEWORKS)
+ # adapt target to build frameworks instead of dylibs
+ set_target_properties(${target} PROPERTIES
+ FRAMEWORK TRUE
+ FRAMEWORK_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
+ MACOSX_FRAMEWORK_IDENTIFIER org.sfml-dev.${target}
+ MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
+ MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
+ endif()
+
+ # adapt install directory to allow distributing dylibs/frameworks in user’s frameworks/application bundle
+ set_target_properties(${target} PROPERTIES
+ BUILD_WITH_INSTALL_RPATH 1
+ INSTALL_NAME_DIR "@executable_path/../Frameworks")
+ endif()
+
+ # link the target to its external dependencies
+ if(THIS_EXTERNAL_LIBS)
+ if(BUILD_SHARED_LIBS)
+ # in shared build, we use the regular linker commands
+ target_link_libraries(${target} ${THIS_EXTERNAL_LIBS})
+ else()
+ # in static build there's no link stage, but with some compilers it is possible to force
+ # the generated static library to directly contain the symbols from its dependencies
+ sfml_static_add_libraries(${target} ${THIS_EXTERNAL_LIBS})
+ endif()
+ endif()
+
+ # add the install rule
+ install(TARGETS ${target}
+ RUNTIME DESTINATION bin COMPONENT bin
+ LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT bin
+ ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT devel
+ FRAMEWORK DESTINATION ${CMAKE_INSTALL_FRAMEWORK_PREFIX} COMPONENT bin)
+
+endmacro()
+
+# add a new target which is a SFML example
+# ex: sfml_add_example(ftp
+# SOURCES ftp.cpp ...
+# DEPENDS sfml-network sfml-system)
+macro(sfml_add_example target)
+
+ # parse the arguments
+ sfml_parse_arguments(THIS "SOURCES;DEPENDS" "GUI_APP" ${ARGN})
+
+ # set a source group for the source files
+ source_group("" FILES ${THIS_SOURCES})
+
+ # create the target
+ if(THIS_GUI_APP AND WINDOWS)
+ add_executable(${target} WIN32 ${THIS_SOURCES})
+ target_link_libraries(${target} sfml-main)
+ else()
+ add_executable(${target} ${THIS_SOURCES})
+ endif()
+
+ # set the debug suffix
+ set_target_properties(${target} PROPERTIES DEBUG_POSTFIX -d)
+
+ # set the target's folder (for IDEs that support it, e.g. Visual Studio)
+ set_target_properties(${target} PROPERTIES FOLDER "Examples")
+
+ # for gcc >= 4.0 on Windows, apply the SFML_USE_STATIC_STD_LIBS option if it is enabled
+ if(WINDOWS AND COMPILER_GCC AND SFML_USE_STATIC_STD_LIBS)
+ if(NOT GCC_VERSION VERSION_LESS "4")
+ set_target_properties(${target} PROPERTIES LINK_FLAGS "-static-libgcc -static-libstdc++")
+ endif()
+ endif()
+
+ # link the target to its SFML dependencies
+ if(THIS_DEPENDS)
+ target_link_libraries(${target} ${THIS_DEPENDS})
+ endif()
+
+ # add the install rule
+ install(TARGETS ${target}
+ RUNTIME DESTINATION ${INSTALL_MISC_DIR}/examples/${target} COMPONENT examples)
+
+ # install the example's source code
+ install(FILES ${THIS_SOURCES}
+ DESTINATION ${INSTALL_MISC_DIR}/examples/${target}
+ COMPONENT examples)
+
+ # install the example's resources as well
+ set(EXAMPLE_RESOURCES "${CMAKE_SOURCE_DIR}/examples/${target}/resources")
+ if(EXISTS ${EXAMPLE_RESOURCES})
+ install(DIRECTORY ${EXAMPLE_RESOURCES}
+ DESTINATION ${INSTALL_MISC_DIR}/examples/${target}
+ COMPONENT examples)
+ endif()
+endmacro()
diff --git a/cmake/Modules/FindGLEW.cmake b/cmake/Modules/FindGLEW.cmake
new file mode 100644
index 0000000..5546487
--- /dev/null
+++ b/cmake/Modules/FindGLEW.cmake
@@ -0,0 +1,65 @@
+#
+# Try to find GLEW library and include path.
+# Once done this will define
+#
+# GLEW_FOUND
+# GLEW_INCLUDE_PATH
+# GLEW_LIBRARY
+#
+
+IF (WIN32)
+ FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
+ $ENV{PROGRAMFILES}/GLEW/include
+ ${GLEW_ROOT_DIR}/include
+ DOC "The directory where GL/glew.h resides")
+
+ IF (NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
+ FIND_LIBRARY( GLEW_LIBRARY
+ NAMES glew64 glew64s
+ PATHS
+ $ENV{PROGRAMFILES}/GLEW/lib
+ ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
+ ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
+ DOC "The GLEW library (64-bit)"
+ )
+ ELSE(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
+ FIND_LIBRARY( GLEW_LIBRARY
+ NAMES glew GLEW glew32 glew32s
+ PATHS
+ $ENV{PROGRAMFILES}/GLEW/lib
+ ${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
+ ${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
+ DOC "The GLEW library"
+ )
+ ENDIF(NV_SYSTEM_PROCESSOR STREQUAL "AMD64")
+ELSE (WIN32)
+ FIND_PATH( GLEW_INCLUDE_PATH GL/glew.h
+ /usr/include
+ /usr/local/include
+ /sw/include
+ /opt/local/include
+ ${GLEW_ROOT_DIR}/include
+ DOC "The directory where GL/glew.h resides")
+
+ FIND_LIBRARY( GLEW_LIBRARY
+ NAMES GLEW glew
+ PATHS
+ /usr/lib64
+ /usr/lib
+ /usr/local/lib64
+ /usr/local/lib
+ /sw/lib
+ /opt/local/lib
+ ${GLEW_ROOT_DIR}/lib
+ DOC "The GLEW library")
+ENDIF (WIN32)
+
+SET(GLEW_FOUND "NO")
+IF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
+ SET(GLEW_LIBRARIES ${GLEW_LIBRARY})
+ SET(GLEW_FOUND "YES")
+ENDIF (GLEW_INCLUDE_PATH AND GLEW_LIBRARY)
+
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(GLEW DEFAULT_MSG GLEW_LIBRARY GLEW_INCLUDE_PATH)
diff --git a/cmake/Modules/FindSFML.cmake b/cmake/Modules/FindSFML.cmake
new file mode 100644
index 0000000..3c57641
--- /dev/null
+++ b/cmake/Modules/FindSFML.cmake
@@ -0,0 +1,209 @@
+# 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:
+# find_package(SFML COMPONENTS graphics window system) // find the graphics, window and system modules
+#
+# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
+# If nothing is specified, the version won't be checked (ie. any version will be accepted).
+# example:
+# 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
+#
+# 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 ...).
+# 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_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)
+#
+# 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)
+ add_definitions(-DSFML_STATIC)
+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()
+
+# find the SFML include directory
+find_path(SFML_INCLUDE_DIR SFML/Config.hpp
+ PATH_SUFFIXES include
+ PATHS
+ ${SFML_ROOT}
+ $ENV{SFML_ROOT}
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local/
+ /usr/
+ /sw # Fink
+ /opt/local/ # DarwinPorts
+ /opt/csw/ # Blastwave
+ /opt/)
+
+# 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)
+ STRING(REGEX MATCH ".*#define SFML_VERSION_MAJOR ([0-9]+).*#define SFML_VERSION_MINOR ([0-9]+).*" SFML_CONFIG_HPP_CONTENTS "${SFML_CONFIG_HPP_CONTENTS}")
+ 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}")
+ math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10 + ${SFML_FIND_VERSION_MINOR}")
+
+ # 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} * 10 + ${SFML_VERSION_MINOR}")
+
+ # 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 19)
+ set(SFML_VERSION_OK FALSE)
+ set(SFML_VERSION_MAJOR 1)
+ set(SFML_VERSION_MINOR 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
+set(FIND_SFML_LIB_PATHS
+ ${SFML_ROOT}
+ $ENV{SFML_ROOT}
+ ~/Library/Frameworks
+ /Library/Frameworks
+ /usr/local
+ /usr
+ /sw
+ /opt/local
+ /opt/csw
+ /opt)
+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}${FIND_SFML_LIB_SUFFIX})
+
+ # no suffix for sfml-main, it is always a static library
+ if(FIND_SFML_COMPONENT_LOWER STREQUAL "main")
+ set(FIND_SFML_COMPONENT_NAME sfml-${FIND_SFML_COMPONENT_LOWER})
+ endif()
+
+ # debug library
+ find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG
+ NAMES ${FIND_SFML_COMPONENT_NAME}-d
+ PATH_SUFFIXES lib64 lib
+ PATHS ${FIND_SFML_LIB_PATHS})
+
+ # release library
+ find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
+ NAMES ${FIND_SFML_COMPONENT_NAME}
+ PATH_SUFFIXES lib64 lib
+ PATHS ${FIND_SFML_LIB_PATHS})
+
+ 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)
+
+ # 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}
+ optimized ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE})
+ 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
+ SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE
+ SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG)
+
+ # add to the global list of libraries
+ set(SFML_LIBRARIES ${SFML_LIBRARIES} "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}")
+endforeach()
+
+# 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})")
+ 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
+if(SFML_FOUND)
+ message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR} in ${SFML_INCLUDE_DIR}")
+endif()
diff --git a/cmake/Modules/FindSndfile.cmake b/cmake/Modules/FindSndfile.cmake
new file mode 100644
index 0000000..16c31dd
--- /dev/null
+++ b/cmake/Modules/FindSndfile.cmake
@@ -0,0 +1,28 @@
+# - Find sndfile
+# Find the native sndfile includes and libraries
+#
+# SNDFILE_INCLUDE_DIR - where to find sndfile.h, etc.
+# SNDFILE_LIBRARIES - List of libraries when using libsndfile.
+# SNDFILE_FOUND - True if libsndfile found.
+
+if(SNDFILE_INCLUDE_DIR)
+ # Already in cache, be silent
+ set(SNDFILE_FIND_QUIETLY TRUE)
+endif(SNDFILE_INCLUDE_DIR)
+
+find_path(SNDFILE_INCLUDE_DIR sndfile.h)
+
+find_library(SNDFILE_LIBRARY NAMES sndfile sndfile-1)
+
+# Handle the QUIETLY and REQUIRED arguments and set SNDFILE_FOUND to TRUE if
+# all listed variables are TRUE.
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(SNDFILE DEFAULT_MSG SNDFILE_LIBRARY SNDFILE_INCLUDE_DIR)
+
+if(SNDFILE_FOUND)
+ set(SNDFILE_LIBRARIES ${SNDFILE_LIBRARY})
+else(SNDFILE_FOUND)
+ set(SNDFILE_LIBRARIES)
+endif(SNDFILE_FOUND)
+
+mark_as_advanced(SNDFILE_INCLUDE_DIR SNDFILE_LIBRARY)