Added support for the CMake build system

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2@1550 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-08-19 15:59:24 +00:00
parent aa612ec63a
commit a991fe8e4d
144 changed files with 2086 additions and 7033 deletions

View file

@ -31,14 +31,8 @@
#include <SFML/Config.hpp>
#include <iostream>
#include <string>
#if defined(SFML_SYSTEM_MACOS)
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
#else
#include <AL/al.h>
#include <AL/alc.h>
#endif
#include <al.h>
#include <alc.h>
namespace sf

View file

@ -0,0 +1,47 @@
set(INCROOT ${CMAKE_SOURCE_DIR}/include/SFML/Audio)
set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/Audio)
# all source files
set(SRC
${SRCROOT}/ALCheck.cpp
${SRCROOT}/ALCheck.hpp
${SRCROOT}/AudioDevice.cpp
${SRCROOT}/AudioDevice.hpp
${SRCROOT}/Listener.cpp
${INCROOT}/Listener.hpp
${SRCROOT}/Music.cpp
${INCROOT}/Music.hpp
${SRCROOT}/Sound.cpp
${INCROOT}/Sound.hpp
${SRCROOT}/SoundBuffer.cpp
${INCROOT}/SoundBuffer.hpp
${SRCROOT}/SoundBufferRecorder.cpp
${INCROOT}/SoundBufferRecorder.hpp
${SRCROOT}/SoundFile.cpp
${SRCROOT}/SoundFile.hpp
${SRCROOT}/SoundRecorder.cpp
${INCROOT}/SoundRecorder.hpp
${SRCROOT}/SoundSource.cpp
${INCROOT}/SoundSource.hpp
${SRCROOT}/SoundStream.cpp
${INCROOT}/SoundStream.hpp
)
# let CMake know about our additional audio libraries paths (on Windows)
if(WINDOWS)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/extlibs/headers/AL")
endif()
# find external libraries
find_package(OpenAL REQUIRED)
find_package(Sndfile REQUIRED)
# add include paths of external libraries
include_directories(${OPENAL_INCLUDE_DIR} ${SNDFILE_INCLUDE_DIR})
# define the sfml-audio target
sfml_add_library(sfml-audio
SOURCES ${SRC}
DEPENDS sfml-system
EXTERNAL_LIBS ${OPENAL_LIBRARY} ${SNDFILE_LIBRARY})

35
src/SFML/CMakeLists.txt Normal file
View file

@ -0,0 +1,35 @@
# include the SFML specific macros
include(${CMAKE_SOURCE_DIR}/cmake/Macros.cmake)
# let CMake know about our additional libraries paths (on Windows)
if (WINDOWS)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/extlibs/headers")
if(COMPILER_GCC)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${CMAKE_SOURCE_DIR}/extlibs/libs-mingw")
elseif(COMPILER_MSVC)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "${CMAKE_SOURCE_DIR}/extlibs/libs-msvc")
endif()
endif()
# add the SFML sources path
include_directories(${CMAKE_SOURCE_DIR}/src)
# define the path of our additional CMake modules
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/")
# set the output directory for SFML libraries
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
# define the export symbol
add_definitions(-DSFML_EXPORTS)
# add the modules subdirectories
add_subdirectory(System)
add_subdirectory(Window)
add_subdirectory(Network)
add_subdirectory(Graphics)
add_subdirectory(Audio)
if(WINDOWS)
add_subdirectory(Main)
endif()

View file

@ -0,0 +1,104 @@
set(INCROOT ${CMAKE_SOURCE_DIR}/include/SFML/Graphics)
set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/Graphics)
# all source files
set(SRC
${SRCROOT}/Arial.hpp
${SRCROOT}/Color.cpp
${INCROOT}/Color.hpp
${SRCROOT}/Drawable.cpp
${INCROOT}/Drawable.hpp
${SRCROOT}/Font.cpp
${INCROOT}/Font.hpp
${INCROOT}/Glyph.hpp
${SRCROOT}/GLCheck.cpp
${SRCROOT}/GLCheck.hpp
${SRCROOT}/Image.cpp
${INCROOT}/Image.hpp
${SRCROOT}/ImageLoader.cpp
${SRCROOT}/ImageLoader.hpp
${SRCROOT}/Matrix3.cpp
${INCROOT}/Matrix3.hpp
${INCROOT}/Matrix3.inl
${INCROOT}/Rect.hpp
${INCROOT}/Rect.inl
${SRCROOT}/Renderer.cpp
${INCROOT}/Renderer.hpp
${SRCROOT}/RenderImage.cpp
${INCROOT}/RenderImage.hpp
${SRCROOT}/RenderImageImpl.cpp
${SRCROOT}/RenderImageImpl.hpp
${SRCROOT}/RenderImageImplFBO.cpp
${SRCROOT}/RenderImageImplFBO.hpp
${SRCROOT}/RenderImageImplPBuffer.hpp
${SRCROOT}/RenderTarget.cpp
${INCROOT}/RenderTarget.hpp
${SRCROOT}/RenderWindow.cpp
${INCROOT}/RenderWindow.hpp
${SRCROOT}/Shader.cpp
${INCROOT}/Shader.hpp
${SRCROOT}/Shape.cpp
${INCROOT}/Shape.hpp
${SRCROOT}/Sprite.cpp
${INCROOT}/Sprite.hpp
${SRCROOT}/Text.cpp
${INCROOT}/Text.hpp
${SRCROOT}/View.cpp
${INCROOT}/View.hpp
${SRCROOT}/stb_image/stb_image.h
${SRCROOT}/stb_image/stb_image_write.h
)
# add platform specific sources
if(WINDOWS)
set(SRC
${SRC}
${SRCROOT}/Win32/RenderImageImplPBuffer.cpp
${SRCROOT}/Win32/RenderImageImplPBuffer.hpp
)
else()
set(SRC
${SRC}
${SRCROOT}/Linux/RenderImageImplPBuffer.cpp
${SRCROOT}/Linux/RenderImageImplPBuffer.hpp
)
endif()
# let CMake know about our additional graphics libraries paths (on Windows)
if (WINDOWS)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/extlibs/headers/freetype")
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/extlibs/headers/GL")
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/extlibs/headers/jpeg")
endif()
# find external libraries
find_package(OpenGL REQUIRED)
find_package(Freetype REQUIRED)
find_package(GLEW REQUIRED)
find_package(JPEG REQUIRED)
if(LINUX)
find_package(X11 REQUIRED)
endif()
# add include paths of external libraries
include_directories(${FREETYPE_INCLUDE_DIRS} ${GLEW_INCLUDE_PATH} ${JPEG_INCLUDE_DIR})
# build the list of libraries to link
# GL and X11 are only needed for shared build, as they are already linked by sfml-window
set(GRAPHICS_EXT_LIBS ${FREETYPE_LIBRARY} ${GLEW_LIBRARY} ${JPEG_LIBRARY})
if(BUILD_SHARED_LIBS)
set(GRAPHICS_EXT_LIBS ${GRAPHICS_EXT_LIBS} ${OPENGL_gl_LIBRARY})
if(LINUX)
set(GRAPHICS_EXT_LIBS ${GRAPHICS_EXT_LIBS} ${X11_LIBRARIES})
endif()
endif()
# add preprocessor symbols
add_definitions(-DGLEW_STATIC -DSTBI_FAILURE_USERMSG)
# define the sfml-graphics target
sfml_add_library(sfml-graphics
SOURCES ${SRC}
DEPENDS sfml-window sfml-system
EXTERNAL_LIBS ${GRAPHICS_EXT_LIBS})

View file

@ -0,0 +1,9 @@
# define the sfml-main target
add_library(sfml-main STATIC ${CMAKE_SOURCE_DIR}/src/SFML/Main/SFML_Main.cpp)
# set the debug suffix
set_target_properties(sfml-main PROPERTIES DEBUG_POSTFIX -d)
# insert the major version number in the output filename
set_target_properties(${target} PROPERTIES OUTPUT_NAME "sfml${VERSION_MAJOR}-main")

View file

@ -0,0 +1,54 @@
set(INCROOT ${CMAKE_SOURCE_DIR}/include/SFML/Network)
set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/Network)
# all source files
set(SRC
${SRCROOT}/Ftp.cpp
${INCROOT}/Ftp.hpp
${SRCROOT}/Http.cpp
${INCROOT}/Http.hpp
${SRCROOT}/IpAddress.cpp
${INCROOT}/IpAddress.hpp
${SRCROOT}/Packet.cpp
${INCROOT}/Packet.hpp
${SRCROOT}/Socket.cpp
${INCROOT}/Socket.hpp
${SRCROOT}/SocketImpl.hpp
${INCROOT}/SocketHandle.hpp
${SRCROOT}/SocketSelector.cpp
${INCROOT}/SocketSelector.hpp
${SRCROOT}/TcpListener.cpp
${INCROOT}/TcpListener.hpp
${SRCROOT}/TcpSocket.cpp
${INCROOT}/TcpSocket.hpp
${SRCROOT}/UdpSocket.cpp
${INCROOT}/UdpSocket.hpp
)
# add platform specific sources
if(WINDOWS)
set(SRC
${SRC}
${SRCROOT}/Win32/SocketImpl.cpp
${SRCROOT}/Win32/SocketImpl.hpp
)
else()
set(SRC
${SRC}
${SRCROOT}/Unix/SocketImpl.cpp
${SRCROOT}/Unix/SocketImpl.hpp
)
endif()
# build the list of external libraries to link
set(NETWORK_EXT_LIBS)
if(WINDOWS)
set(NETWORK_EXT_LIBS ${NETWORK_EXT_LIBS} ws2_32)
endif()
# define the sfml-network target
sfml_add_library(sfml-network
SOURCES ${SRC}
DEPENDS sfml-system
EXTERNAL_LIBS ${NETWORK_EXT_LIBS})

View file

@ -327,7 +327,7 @@ Ftp::Response Ftp::Upload(const std::string& localFile, const std::string& remot
return Response(Response::InvalidFile);
file.seekg(0, std::ios::end);
std::size_t length = file.tellg();
std::size_t length = static_cast<std::size_t>(file.tellg());
file.seekg(0, std::ios::beg);
std::vector<char> fileData(length);
if (length > 0)

View file

@ -0,0 +1,77 @@
set(INCROOT ${CMAKE_SOURCE_DIR}/include/SFML/System)
set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/System)
# all source files
set(SRC
${SRCROOT}/Clock.cpp
${INCROOT}/Clock.hpp
${SRCROOT}/Err.cpp
${INCROOT}/Err.hpp
${SRCROOT}/Lock.cpp
${INCROOT}/Lock.hpp
${SRCROOT}/Mutex.cpp
${INCROOT}/Mutex.hpp
${INCROOT}/NonCopyable.hpp
${SRCROOT}/Platform.hpp
${SRCROOT}/Randomizer.cpp
${INCROOT}/Randomizer.hpp
${INCROOT}/Resource.hpp
${INCROOT}/Resource.inl
${INCROOT}/ResourcePtr.inl
${SRCROOT}/Sleep.cpp
${INCROOT}/Sleep.hpp
${SRCROOT}/String.cpp
${INCROOT}/String.hpp
${SRCROOT}/Thread.cpp
${INCROOT}/Thread.hpp
${SRCROOT}/ThreadLocal.cpp
${INCROOT}/ThreadLocal.hpp
${INCROOT}/ThreadLocalPtr.hpp
${INCROOT}/ThreadLocalPtr.inl
${SRCROOT}/Utf.cpp
${INCROOT}/Utf.hpp
${INCROOT}/Utf.inl
${INCROOT}/Vector2.hpp
${INCROOT}/Vector2.inl
${INCROOT}/Vector3.hpp
${INCROOT}/Vector3.inl
)
# add platform specific sources
if(WINDOWS)
set(SRC
${SRC}
${SRCROOT}/Win32/MutexImpl.cpp
${SRCROOT}/Win32/MutexImpl.hpp
${SRCROOT}/Win32/Platform.cpp
${SRCROOT}/Win32/Platform.hpp
${SRCROOT}/Win32/ThreadImpl.cpp
${SRCROOT}/Win32/ThreadImpl.hpp
${SRCROOT}/Win32/ThreadLocalImpl.cpp
${SRCROOT}/Win32/ThreadLocalImpl.hpp
)
else()
set(SRC
${SRC}
${SRCROOT}/Unix/MutexImpl.cpp
${SRCROOT}/Unix/MutexImpl.hpp
${SRCROOT}/Unix/Platform.cpp
${SRCROOT}/Unix/Platform.hpp
${SRCROOT}/Unix/ThreadImpl.cpp
${SRCROOT}/Unix/ThreadImpl.hpp
${SRCROOT}/Unix/ThreadLocalImpl.cpp
${SRCROOT}/Unix/ThreadLocalImpl.hpp
)
endif()
# build the list of external libraries to link
set(SYSTEM_EXT_LIBS)
if(UNIX)
set(SYSTEM_EXT_LIBS ${SYSTEM_EXT_LIBS} pthread)
endif()
# define the sfml-system target
sfml_add_library(sfml-system
SOURCES ${SRC}
EXTERNAL_LIBS ${SYSTEM_EXT_LIBS})

View file

@ -0,0 +1,83 @@
set(INCROOT ${CMAKE_SOURCE_DIR}/include/SFML/Window)
set(SRCROOT ${CMAKE_SOURCE_DIR}/src/SFML/Window)
# all source files
set(SRC
${SRCROOT}/Context.cpp
${INCROOT}/Context.hpp
${SRCROOT}/GlContext.cpp
${SRCROOT}/GlContext.hpp
${INCROOT}/ContextSettings.hpp
${INCROOT}/Event.hpp
${SRCROOT}/Input.cpp
${INCROOT}/Input.hpp
${SRCROOT}/Joystick.hpp
${SRCROOT}/VideoMode.cpp
${INCROOT}/VideoMode.hpp
${SRCROOT}/VideoModeImpl.hpp
${SRCROOT}/Window.cpp
${INCROOT}/Window.hpp
${INCROOT}/WindowHandle.hpp
${SRCROOT}/WindowImpl.cpp
${SRCROOT}/WindowImpl.hpp
${INCROOT}/WindowStyle.hpp
)
# add platform specific sources
if(WINDOWS)
set(SRC
${SRC}
${SRCROOT}/Win32/WglContext.cpp
${SRCROOT}/Win32/WglContext.hpp
${SRCROOT}/Win32/Joystick.cpp
${SRCROOT}/Win32/Joystick.hpp
${SRCROOT}/Win32/VideoModeImpl.cpp
${SRCROOT}/Win32/WindowImplWin32.cpp
${SRCROOT}/Win32/WindowImplWin32.hpp
)
elseif(LINUX)
set(SRC
${SRC}
${SRCROOT}/Linux/GlxContext.cpp
${SRCROOT}/Linux/GlxContext.hpp
${SRCROOT}/Linux/Joystick.cpp
${SRCROOT}/Linux/Joystick.hpp
${SRCROOT}/Linux/VideoModeImpl.cpp
${SRCROOT}/Linux/WindowImplX11.cpp
${SRCROOT}/Linux/WindowImplX11.hpp
)
else()
set(SRC
${SRC}
${SRCROOT}/Cocoa/AppController.h
${SRCROOT}/Cocoa/AppController.mm
${SRCROOT}/Cocoa/GLKit.h
${SRCROOT}/Cocoa/GLKit.mm
${SRCROOT}/Cocoa/Joystick.cpp
${SRCROOT}/Cocoa/Joystick.hpp
${SRCROOT}/Cocoa/VideoModeImpl.cpp
${SRCROOT}/Cocoa/WindowImplCocoa.cpp
${SRCROOT}/Cocoa/WindowImplCocoa.mm
)
endif()
# find external libraries
find_package(OpenGL REQUIRED)
if(LINUX)
find_package(X11 REQUIRED)
endif()
# build the list of external libraries to link
set(WINDOW_EXT_LIBS ${OPENGL_gl_LIBRARY})
if(WINDOWS)
set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} winmm)
else(LINUX)
set(WINDOW_EXT_LIBS ${WINDOW_EXT_LIBS} ${X11_X11_LIB} ${X11_Xrandr_LIB})
endif()
# define the sfml-window target
sfml_add_library(sfml-window
SOURCES ${SRC}
DEPENDS sfml-system
EXTERNAL_LIBS ${WINDOW_EXT_LIBS})