Skip to content

Commit

Permalink
Merge pull request #1522 from jcowgill/sfml-2.1
Browse files Browse the repository at this point in the history
Update / Port to SFML 2.1
  • Loading branch information
skidau committed Nov 26, 2014
2 parents 69bd156 + a93f863 commit b806680
Show file tree
Hide file tree
Showing 64 changed files with 7,433 additions and 4,242 deletions.
11 changes: 5 additions & 6 deletions CMakeLists.txt
Expand Up @@ -600,16 +600,15 @@ if(LIBUSB_FOUND)
include_directories(${LIBUSB_INCLUDE_DIR})
endif(LIBUSB_FOUND)

set(SFML_FIND_VERSION TRUE)
set(SFML_FIND_VERSION_MAJOR 1)
set(SFML_FIND_VERSION_MINOR 5)
set(SFML_REQD_VERSION 2.1)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND NOT ANDROID)
include(FindSFML OPTIONAL)
find_package(SFML ${SFML_REQD_VERSION} COMPONENTS network system)
endif()
if(SFML_FOUND AND NOT SFML_VERSION_MAJOR) # SFML 1.x doesn't define SFML_VERSION_MAJOR
if(SFML_FOUND)
message("Using shared SFML")
else()
message("Using static SFML ${SFML_FIND_VERSION_MAJOR}.${SFML_FIND_VERSION_MINOR} from Externals")
message("Using static SFML ${SFML_REQD_VERSION} from Externals")
add_definitions(-DSFML_STATIC)
add_subdirectory(Externals/SFML)
include_directories(BEFORE Externals/SFML/include)
endif()
Expand Down
112 changes: 76 additions & 36 deletions CMakeTests/FindSFML.cmake
@@ -1,20 +1,59 @@
# Locate the SFML library
# This script locates the SFML library
# ------------------------------------
#
# This module defines the following variables:
# - For each 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)
# 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 SFMLDIR CMake variable or environment variable
# 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 "")
Expand All @@ -26,26 +65,28 @@ endif()
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/
${SFMLDIR}
$ENV{SFMLDIR})


# will be set to false if one of the required modules is not found
set(SFML_FOUND TRUE)
set(SFML_VERSION_OK TRUE)
/opt/)

# check the version number
if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR AND NOT (SFML_INCLUDE_DIR STREQUAL "SFML_INCLUDE_DIR-NOTFOUND"))
set(SFML_VERSION_OK TRUE)
if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR)
# extract the major and minor version numbers from SFML/Config.hpp
FILE(READ "${SFML_INCLUDE_DIR}/SFML/Config.hpp" SFML_CONFIG_HPP_CONTENTS)
# 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}")
Expand All @@ -68,22 +109,21 @@ if(SFML_FIND_VERSION AND SFML_INCLUDE_DIR AND NOT (SFML_INCLUDE_DIR STREQUAL "SF
set(SFML_VERSION_MINOR x)
endif()
endif()
elseif(SFML_INCLUDE_DIR STREQUAL "SFML_INCLUDE_DIR-NOTFOUND")
set(SFML_FOUND FALSE)
set(FIND_SFML_MISSING "${FIND_SFML_MISSING} SFML_INCLUDE_DIR")
endif()

# find the requested modules
set(FIND_SFML_LIB_PATHS ~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr
/sw
/opt/local
/opt/csw
/opt
${SFMLDIR}
$ENV{SFMLDIR})
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)
Expand All @@ -109,7 +149,7 @@ foreach(FIND_SFML_COMPONENT ${SFML_FIND_COMPONENTS})
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}
Expand Down Expand Up @@ -165,5 +205,5 @@ endif()

# handle success
if(SFML_FOUND)
message("Found SFML: ${SFML_INCLUDE_DIR}")
message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR} in ${SFML_INCLUDE_DIR}")
endif()
36 changes: 23 additions & 13 deletions Externals/SFML/CMakeLists.txt
@@ -1,17 +1,27 @@
include_directories(BEFORE include)
include_directories(BEFORE include src)

set(SRCS src/SFML/Network/Ftp.cpp
src/SFML/Network/Http.cpp
src/SFML/Network/IPAddress.cpp
src/SFML/Network/Packet.cpp
src/SFML/Network/SelectorBase.cpp
src/SFML/Network/SocketTCP.cpp
src/SFML/Network/SocketUDP.cpp)
set(SRC_NETWORK
src/SFML/Network/Http.cpp
src/SFML/Network/IPAddress.cpp
src/SFML/Network/Packet.cpp
src/SFML/Network/Socket.cpp
src/SFML/Network/SocketSelector.cpp
src/SFML/Network/TcpListener.cpp
src/SFML/Network/TcpSocket.cpp
src/SFML/Network/UdpSocket.cpp
)

if(UNIX)
set(SRCS ${SRCS} src/SFML/Network/Unix/SocketHelper.cpp)
elseif(WIN32)
set(SRCS ${SRCS} src/SFML/Network/Win32/SocketHelper.cpp)
if(WIN32)
list(APPEND SRC_NETWORK src/SFML/Network/Win32/SocketImpl.cpp)
else()
list(APPEND SRC_NETWORK src/SFML/Network/Unix/SocketImpl.cpp)
endif()

add_library(sfml-network ${SRCS})
set(SRC_SYSTEM
src/SFML/System/Err.cpp
src/SFML/System/String.cpp
src/SFML/System/Time.cpp
)

add_library(sfml-network ${SRC_NETWORK})
add_library(sfml-system ${SRC_SYSTEM})
51 changes: 34 additions & 17 deletions Externals/SFML/build/vc2010/SFML_Network.vcxproj
Expand Up @@ -42,33 +42,50 @@
<Import Project="..\..\..\..\Source\VSProps\ClDisableAllWarnings.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\SFML\Network\Ftp.cpp" />
<ClCompile Include="..\..\src\SFML\Network\Http.cpp" />
<ClCompile Include="..\..\src\SFML\Network\IPAddress.cpp" />
<ClCompile Include="..\..\src\SFML\Network\Packet.cpp" />
<ClCompile Include="..\..\src\SFML\Network\SelectorBase.cpp" />
<ClCompile Include="..\..\src\SFML\Network\SocketTCP.cpp" />
<ClCompile Include="..\..\src\SFML\Network\SocketUDP.cpp" />
<ClCompile Include="..\..\src\SFML\Network\Win32\SocketHelper.cpp" />
<ClCompile Include="..\..\src\SFML\Network\Socket.cpp" />
<ClCompile Include="..\..\src\SFML\Network\SocketSelector.cpp" />
<ClCompile Include="..\..\src\SFML\Network\TcpListener.cpp" />
<ClCompile Include="..\..\src\SFML\Network\TcpSocket.cpp" />
<ClCompile Include="..\..\src\SFML\Network\UdpSocket.cpp" />
<ClCompile Include="..\..\src\SFML\Network\Win32\SocketImpl.cpp" />
<ClCompile Include="..\..\src\SFML\System\Err.cpp" />
<ClCompile Include="..\..\src\SFML\System\String.cpp" />
<ClCompile Include="..\..\src\SFML\System\Time.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\SFML\Network\Ftp.hpp" />
<ClInclude Include="..\..\include\SFML\Config.hpp" />
<ClInclude Include="..\..\include\SFML\Network.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Export.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Http.hpp" />
<ClInclude Include="..\..\include\SFML\Network\IPAddress.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Packet.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Selector.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SelectorBase.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SocketHelper.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Sockets.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SocketTCP.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SocketUDP.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Win32\SocketHelper.hpp" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\include\SFML\Network\Selector.inl" />
<ClInclude Include="..\..\include\SFML\Network\Socket.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SocketHandle.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SocketSelector.hpp" />
<ClInclude Include="..\..\include\SFML\Network\TcpListener.hpp" />
<ClInclude Include="..\..\include\SFML\Network\TcpSocket.hpp" />
<ClInclude Include="..\..\include\SFML\Network\UdpSocket.hpp" />
<ClInclude Include="..\..\include\SFML\System.hpp" />
<ClInclude Include="..\..\include\SFML\System\Err.hpp" />
<ClInclude Include="..\..\include\SFML\System\Export.hpp" />
<ClInclude Include="..\..\include\SFML\System\NonCopyable.hpp" />
<ClInclude Include="..\..\include\SFML\System\String.hpp" />
<ClInclude Include="..\..\include\SFML\System\Time.hpp" />
<ClInclude Include="..\..\include\SFML\System\Utf.hpp" />
<ClInclude Include="..\..\include\SFML\System\Utf.inl" />
<ClInclude Include="..\..\src\SFML\Network\SocketImpl.hpp" />
<ClInclude Include="..\..\src\SFML\Network\Win32\SocketImpl.hpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
46 changes: 29 additions & 17 deletions Externals/SFML/build/vc2010/SFML_Network.vcxproj.filters
@@ -1,38 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="..\..\src\SFML\Network\Ftp.cpp" />
<ClCompile Include="..\..\src\SFML\Network\Http.cpp" />
<ClCompile Include="..\..\src\SFML\Network\IPAddress.cpp" />
<ClCompile Include="..\..\src\SFML\Network\Packet.cpp" />
<ClCompile Include="..\..\src\SFML\Network\SelectorBase.cpp" />
<ClCompile Include="..\..\src\SFML\Network\SocketTCP.cpp" />
<ClCompile Include="..\..\src\SFML\Network\SocketUDP.cpp" />
<ClCompile Include="..\..\src\SFML\Network\Win32\SocketHelper.cpp">
<ClCompile Include="..\..\src\SFML\Network\Socket.cpp" />
<ClCompile Include="..\..\src\SFML\Network\SocketSelector.cpp" />
<ClCompile Include="..\..\src\SFML\Network\TcpListener.cpp" />
<ClCompile Include="..\..\src\SFML\Network\TcpSocket.cpp" />
<ClCompile Include="..\..\src\SFML\Network\UdpSocket.cpp" />
<ClCompile Include="..\..\src\SFML\Network\Win32\SocketImpl.cpp">
<Filter>Win32</Filter>
</ClCompile>
<ClCompile Include="..\..\src\SFML\System\Err.cpp" />
<ClCompile Include="..\..\src\SFML\System\String.cpp" />
<ClCompile Include="..\..\src\SFML\System\Time.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\SFML\Network\Ftp.hpp" />
<ClInclude Include="..\..\include\SFML\Config.hpp" />
<ClInclude Include="..\..\include\SFML\Network.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Export.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Http.hpp" />
<ClInclude Include="..\..\include\SFML\Network\IPAddress.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Packet.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Selector.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SelectorBase.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SocketHelper.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Sockets.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SocketTCP.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SocketUDP.hpp" />
<ClInclude Include="..\..\include\SFML\Network\Win32\SocketHelper.hpp">
<ClInclude Include="..\..\include\SFML\Network\Socket.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SocketHandle.hpp" />
<ClInclude Include="..\..\include\SFML\Network\SocketSelector.hpp" />
<ClInclude Include="..\..\include\SFML\Network\TcpListener.hpp" />
<ClInclude Include="..\..\include\SFML\Network\TcpSocket.hpp" />
<ClInclude Include="..\..\include\SFML\Network\UdpSocket.hpp" />
<ClInclude Include="..\..\include\SFML\System.hpp" />
<ClInclude Include="..\..\include\SFML\System\Err.hpp" />
<ClInclude Include="..\..\include\SFML\System\Export.hpp" />
<ClInclude Include="..\..\include\SFML\System\NonCopyable.hpp" />
<ClInclude Include="..\..\include\SFML\System\String.hpp" />
<ClInclude Include="..\..\include\SFML\System\Time.hpp" />
<ClInclude Include="..\..\include\SFML\System\Utf.hpp" />
<ClInclude Include="..\..\include\SFML\System\Utf.inl" />
<ClInclude Include="..\..\src\SFML\Network\SocketImpl.hpp" />
<ClInclude Include="..\..\src\SFML\Network\Win32\SocketImpl.hpp">
<Filter>Win32</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\include\SFML\Network\Selector.inl" />
</ItemGroup>
<ItemGroup>
<Filter Include="Win32">
<UniqueIdentifier>{8280ecca-24fc-48a2-b7f5-6aca41826b66}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>
</Project>

0 comments on commit b806680

Please sign in to comment.