diff --git a/.gitignore b/.gitignore index 60065df9a..91e33706d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ core /stats /modules /history.idx +/build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..b119b52cc --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,131 @@ +cmake_minimum_required(VERSION 2.9 FATAL_ERROR) + +set(FE_VERSION "v2.0.0") + +project(attract) + +# Default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + +# cmake module search path, prefer ours +set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) + +include(GNUInstallDirs) +include(InstallRequiredSystemLibraries) +include(GetGitRevisionDescription) +include(CheckIncludeFile) +include(TargetArch) + +target_architecture(CMAKE_TARGET_ARCHITECTURES) +string(TOUPPER ${CMAKE_SYSTEM_NAME} TARGET_SYSTEM) +string(CONCAT TARGET_SYSTEM TARGET_ ${TARGET_SYSTEM}) +string(TOUPPER ${CMAKE_TARGET_ARCHITECTURES} TARGET_ARCH) +string(CONCAT TARGET_ARCH TARGET_ ${TARGET_ARCH}) + +message(STATUS "Target: ${CMAKE_SYSTEM_NAME} ${CMAKE_TARGET_ARCHITECTURES}") + +#### BEGIN: Options #### +# All options mapped to config.h definitions + +option(NO_MOVIE "Disable movie support (ffmpeg)" OFF) +option(NO_NET "Disable network scraper support" OFF) +option(NO_SWF "Disable SWF support (gameswf)" OFF) +option(USE_FONTCONFIG "FontConfig support" ON) +option(USE_LIBARCHIVE "Archive library support" ON) +option(USE_XINERAMA "Xinerama support" ON) +option(USE_GLES "GLES instead of GL" OFF) +option(FE_DEBUG "Debug" OFF) +option(FE_RPI "Build for Raspberry PI" OFF) + +if(FE_RPI) + set(USE_GLES ON) +endif() + +if(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(FE_DEBUG ON) +endif() + +if(USE_XINERAMA AND NOT WIN32 AND NOT APPLE) + find_package(Xinerama) +endif() +set(USE_XINERAMA ${XINERAMA_FOUND}) + +if(USE_LIBARCHIVE) + find_package(LibArchive) +endif() +set(USE_LIBARCHIVE ${LibArchive_Found}) + +if(USE_FONTCONFIG AND NOT WIN32) + find_package(FontConfig) +endif() +set(USE_FONTCONFIG ${FONTCONFIG_FOUND}) + +#### END: Options #### + +#### BEGIN: Version #### +# parse VER_* definitions for config.h, prefer git, fallback to FE_VERSION + +git_describe(VER_TAG --tags --abbrev=0) +if("${VER_TAG}" STREQUAL "GIT-NOTFOUND") + set(VER_TAG ${FE_VERSION}) + set(VER_COUNT "0") +else() + git_revlist(VER_COUNT --count ${VER_TAG}..HEAD) +endif() +string(REGEX REPLACE "^v" "" RESULT ${VER_TAG}) +string(REGEX REPLACE "[-\\.]" ";" RESULT ${RESULT}) +list(GET RESULT 0 VER_MAJOR) +list(GET RESULT 1 VER_MINOR) +list(GET RESULT 2 VER_POINT) +git_describe(VER_DIRTY --dirty) +if(NOT "${VER_COUNT}" EQUAL "0") + set(VER_TAG "${VER_TAG}-${VER_COUNT}") +endif() +if("${VER_DIRTY}" MATCHES "-dirty") + set(VER_TAG "${VER_TAG}-dirty") +endif() +message(STATUS "Version Tag: ${VER_TAG}") + +#### END: Version #### + +#### BEGIN: Dependencies #### + +if(USE_FONTCONFIG) + find_package(EXPAT REQUIRED) +endif() + +# FFmpeg +if(NOT NO_MOVIE) + find_package(FFmpeg COMPONENTS avformat avcodec avutil swscale swresample) + if(NOT FFMPEG_FOUND) + find_package(FFmpeg COMPONENTS avformat avcodec avutil swscale avresample REQUIRED) + endif() +endif() + +#### END: Dependencies #### + +#### BEGIN: Misc #### + +# If ARM, assume GLES +if(NOT FE_RPI AND "${CMAKE_TARGET_ARCHITECTURES}" MATCHES "arm") + set(USE_GLES ON) + set(FE_RPI ON) + message(STATUS "ARM detected: FE_RPI and USE_GLES set") +endif() + +if(NOT WIN32) + set(DATA_PATH "${CMAKE_INSTALL_FULL_DATADIR}/${CMAKE_PROJECT_NAME}/") +endif() + +#### END: Misc #### + +configure_file("${PROJECT_SOURCE_DIR}/config.h.in" "${PROJECT_BINARY_DIR}/config.h") + +# process CMakeLists.txt in these folders +add_subdirectory(extlibs) +add_subdirectory(src) + +install(DIRECTORY config/ + DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}) diff --git a/Compile.md b/Compile.md index b75ab08b5..070067df4 100644 --- a/Compile.md +++ b/Compile.md @@ -13,27 +13,31 @@ distributions. Other distributions should have similar packages available. 1. Install the following libraries and related headers on your system: * Required: - - SFML SDK version 2.x () - - OpenAL - - zlib - - FreeType 2 - - The following FFmpeg libraries (required for videos): avformat, + - [cmake] 2.9+ + - [SFML] SDK version 2.x + - [OpenAL] + - [zlib] + - [FreeType] 2 + - The following [FFmpeg] libraries (required for videos): avformat, avcodec, swscale, avutil and either swresample or avresample. * Optional: - - Fontconfig (to assist with finding fonts). - - Xinerama (for multiple monitor support). - - libarchive (for .7z, .rar, .tar.gz and .tar.bz2 archive support). + - [Fontconfig] (to assist with finding fonts). + - [Xinerama] (for multiple monitor support). + - [libarchive] (for .7z, .rar, .tar.gz and .tar.bz2 archive support). 2. Extract the Attract-Mode source to your system. 3. From the directory you extracted the source into, run: + mkdir build + cd build + cmake .. make -j 3 or, if you are building on a Raspberry Pi, O-Droid or another embedded - system, you can build the OpenGL ES version with the following: + system, you can build the OpenGL ES version by adding an option to cmake: - make -j 3 USE_GLES=1 + cmake -DUSE_GLES=ON .. This step will create the "attract" executable file. @@ -52,19 +56,22 @@ distributions. Other distributions should have similar packages available. config directory. By default, this config directory is located in `$HOME/.attract` on Linux/FreeBSD systems. - NOTE: The Attract-Mode makefile tries to follow the GNU standards for - specifying installation directories: . + NOTE: The Attract-Mode tries to follow the [GNU standards for installation + directories][GNUInstallDirs]. If you want to change the location where Attract-Mode looks for its default - data from `/usr/local/share/attract` you should change these values - appropriately before running the `make` and `make install` commands. + data from `/usr/local/share/attract` you may change these values by running + `cmake` with the appropriate options. For example: + + cmake -DCMAKE_INSTALL_PREFIX=PATH:/usr/ \ + -DCMAKE_INSTALL_DATAROOTDIR=PATH:share OS X: ----- These instructions assume that you have X Code installed. -1. Install Homebrew (). This can be done by running the - following command at a terminal command prompt: +1. Install [Homebrew]. This can be done by running the following command at a + terminal command prompt: ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" @@ -78,6 +85,9 @@ These instructions assume that you have X Code installed. 4. From the directory you extracted the Attract-Mode source into, run: + mkdir build + cd build + cmake .. make -j 3 This step will create the "attract" executable file. @@ -100,11 +110,9 @@ Windows (cross-compile): ------------------------ The recommended way to build Windows binaries for Attract-Mode is to cross -compile on an OS that supports MXE () such as Linux, FreeBSD or -OS X. +compile on an OS that supports [MXE] such as Linux, FreeBSD or OS X. -1. Follow the steps in the mxe tutorial to set up mxe on your system: - +1. Follow the steps in the [mxe tutorial] to set up mxe on your system. 2. Make mxe's sfml, ffmpeg and libarchive packages: @@ -113,17 +121,21 @@ OS X. the above command will make 32-bit versions of ffmpeg and sfml (and anything else that they depend on). To make the 64-bit version use the following: - make MXE_TARGETS='x86_64-w64-mingw32.static' ffmpeg sfml + make MXE_TARGETS='x86_64-w64-mingw32.static' ffmpeg sfml libarchive 3. Extract the Attract-Mode source to your system. 4. From the directory you extracted the source into, run the following: - make -j 3 CROSS=1 TOOLCHAIN=i686-w64-mingw32.static WINDOWS_STATIC=1 + mkdir build + cd build + i686-w64-mingw32.static-cmake .. + make -j 3 to build the 32-bit version of Attract-Mode. To build 64-bit, run: - make -j 3 CROSS=1 TOOLCHAIN=x86_64-w64-mingw32.static WINDOWS_STATIC=1 + x86_64-w64-mingw32.static-cmake .. && make -j3 + make -j 3 This step will create the "attract.exe" executable file. @@ -134,8 +146,7 @@ OS X. Windows (native compile): ------------------------- -1. Install MSYS2 - +1. Install [MSYS2] 2. Launch the MSYS2 shell and update the system: @@ -148,15 +159,32 @@ Windows (native compile): 4. Install required packaged. (optionally use the mingw-w64-i686-toolchain instead for 32-bit windows architectures): - pacman -S git mingw-w64-x86_64-toolchain msys/make mingw64/mingw-w64-x86_64-sfml mingw64/mingw-w64-x86_64-ffmpeg mingw64/mingw-w64-x86_64-libarchive + pacman -S git cmake mingw-w64-x86_64-toolchain msys/make mingw64/mingw-w64-x86_64-sfml mingw64/mingw-w64-x86_64-ffmpeg mingw64/mingw-w64-x86_64-libarchive 5. Clone and make Attract-Mode git clone https://github.com/mickelson/attract attract - cd attract + mkdir attract/build + cd attract/build + cmake .. make -j 3 This builds a version of Attract-Mode with various .dll dependencies. To run the program, you will need to add `c:\msys64\mingw64\bin` to your path (for 64-bit systems) or copy the dependent .dlls from that directory into the same directory you will run Attract-Mode from. + +[cmake]: https://cmake.org/ +[SFML]: http://sfml-dev.org/ +[OpenAL]: https://www.openal.org/ +[zlib]: http://zlib.net/ +[FreeType]: http://freetype.org/ +[FFmpeg]: https://ffmpeg.org/ +[FontConfig]: http://fontconfig.org/ +[Xinerama]: https://en.wikipedia.org/wiki/Xinerama +[libarchive]: http://www.libarchive.org/ +[MXE]: http://mxe.cc +[mxe tutorial]: http://mxe.cc/#tutorial +[Homebrew]: http://brew.sh +[MSYS2]: https://msys2.github.io/ +[GNUInstallDirs]: https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html diff --git a/cmake/modules/FindFFmpeg.cmake b/cmake/modules/FindFFmpeg.cmake new file mode 100644 index 000000000..e2835c12a --- /dev/null +++ b/cmake/modules/FindFFmpeg.cmake @@ -0,0 +1,152 @@ +# +# This module defines the following variables: +# +# FFMPEG_FOUND - All required components and the core library were found +# FFMPEG_INCLUDE_DIRS - Combined list of all components include dirs +# FFMPEG_LIBRARIES - Combined list of all componenets libraries +# FFMPEG_STATIC_LIBRARIES +# FFMPEG_VERSION_STRING - Version of the first component requested +# +# For each requested component the following variables are defined: +# +# FFMPEG__FOUND - The component was found +# FFMPEG__INCLUDE_DIRS - The components include dirs +# FFMPEG__LIBRARIES - The components libraries +# FFMPEG__STATIC_LIBRARIES +# FFMPEG__VERSION_STRING - The components version string +# FFMPEG__VERSION_MAJOR - The components major version +# FFMPEG__VERSION_MINOR - The components minor version +# FFMPEG__VERSION_MICRO - The components micro version +# +# is the uppercase name of the component + + +find_package(PkgConfig) + +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(_lib_suffix 64) +else() + set(_lib_suffix 32) +endif() + +function(find_ffmpeg_library component header) + string(TOUPPER "${component}" component_u) + set(FFMPEG_${component_u}_FOUND FALSE PARENT_SCOPE) + set(FFmpeg_${component}_FOUND FALSE PARENT_SCOPE) + + pkg_check_modules(PC_FFMPEG_${component} lib${component} QUIET) + + find_path(FFMPEG_${component}_INCLUDE_DIR + NAMES + "lib${component}/${header}" "lib${component}/version.h" + HINTS + ENV FFmpegPath${_lib_suffix} + ENV FFmpegPath + ENV DepsPath${_lib_suffix} + ENV DepsPath + ${FFmpegPath${_lib_suffix}} + ${FFmpegPath} + ${DepsPath${_lib_suffix}} + ${DepsPath} + ${PC_FFMPEG_${component}_INCLUDE_DIRS} + PATH_SUFFIXES ffmpeg libav) + + find_library(FFMPEG_${component}_LIBRARY + NAMES + "${component}" "lib${component}" + HINTS + ENV FFmpegPath${_lib_suffix} + ENV FFmpegPath + ENV DepsPath${_lib_suffix} + ENV DepsPath + ${FFmpegPath${_lib_suffix}} + ${FFmpegPath} + ${DepsPath${_lib_suffix}} + ${DepsPath} + ${PC_FFMPEG_${component}_LIBRARY_DIRS} + PATH_SUFFIXES + lib${_lib_suffix} lib + libs${_lib_suffix} libs + bin${_lib_suffix} bin) + + set(FFMPEG_${component_u}_INCLUDE_DIRS ${FFMPEG_${component}_INCLUDE_DIR} PARENT_SCOPE) + set(FFMPEG_${component_u}_LIBRARIES ${FFMPEG_${component}_LIBRARY} PARENT_SCOPE) + set(FFMPEG_${component_u}_STATIC_LIBRARIES ${PC_FFMPEG_${component}_STATIC_LIBRARIES} PARENT_SCOPE) + + mark_as_advanced(FFMPEG_${component}_INCLUDE_DIR FFMPEG_${component}_LIBRARY) + + if(FFMPEG_${component}_INCLUDE_DIR AND FFMPEG_${component}_LIBRARY) + set(FFMPEG_${component_u}_FOUND TRUE PARENT_SCOPE) + set(FFmpeg_${component}_FOUND TRUE PARENT_SCOPE) + + list(APPEND FFMPEG_INCLUDE_DIRS ${FFMPEG_${component}_INCLUDE_DIR}) + list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS) + set(FFMPEG_INCLUDE_DIRS "${FFMPEG_INCLUDE_DIRS}" PARENT_SCOPE) + + list(APPEND FFMPEG_LIBRARIES ${FFMPEG_${component}_LIBRARY}) + list(APPEND FFMPEG_STATIC_LIBRARIES ${PC_FFMPEG_${component}_STATIC_LIBRARIES}) + list(REMOVE_DUPLICATES FFMPEG_LIBRARIES) + set(FFMPEG_LIBRARIES "${FFMPEG_LIBRARIES}" PARENT_SCOPE) + set(FFMPEG_STATIC_LIBRARIES "${FFMPEG_STATIC_LIBRARIES}" PARENT_SCOPE) + + set(FFMPEG_${component_u}_VERSION_STRING "unknown" PARENT_SCOPE) + set(_vfile "${FFMPEG_${component}_INCLUDE_DIR}/lib${component}/version.h") + + if(EXISTS "${_vfile}") + file(STRINGS "${_vfile}" _version_parse REGEX "^.*VERSION_(MAJOR|MINOR|MICRO)[ \t]+[0-9]+[ \t]*$") + string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _major "${_version_parse}") + string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _minor "${_version_parse}") + string(REGEX REPLACE ".*VERSION_MICRO[ \t]+([0-9]+).*" "\\1" _micro "${_version_parse}") + + set(FFMPEG_${component_u}_VERSION_MAJOR "${_major}" PARENT_SCOPE) + set(FFMPEG_${component_u}_VERSION_MINOR "${_minor}" PARENT_SCOPE) + set(FFMPEG_${component_u}_VERSION_MICRO "${_micro}" PARENT_SCOPE) + + set(FFMPEG_${component_u}_VERSION_STRING "${_major}.${_minor}.${_micro}" PARENT_SCOPE) + else() + message(STATUS "Failed parsing FFmpeg ${component} version") + endif() + endif() +endfunction() + +set(FFMPEG_INCLUDE_DIRS) +set(FFMPEG_LIBRARIES) +set(FFMPEG_STATIC_LIBRARIES) + +if(NOT FFmpeg_FIND_COMPONENTS) + message(FATAL_ERROR "No FFmpeg components requested") +endif() + +list(GET FFmpeg_FIND_COMPONENTS 0 _first_comp) +string(TOUPPER "${_first_comp}" _first_comp) + +foreach(component ${FFmpeg_FIND_COMPONENTS}) + if(component STREQUAL "avcodec") + find_ffmpeg_library("${component}" "avcodec.h") + elseif(component STREQUAL "avdevice") + find_ffmpeg_library("${component}" "avdevice.h") + elseif(component STREQUAL "avfilter") + find_ffmpeg_library("${component}" "avfilter.h") + elseif(component STREQUAL "avformat") + find_ffmpeg_library("${component}" "avformat.h") + elseif(component STREQUAL "avresample") + find_ffmpeg_library("${component}" "avresample.h") + elseif(component STREQUAL "avutil") + find_ffmpeg_library("${component}" "avutil.h") + elseif(component STREQUAL "postproc") + find_ffmpeg_library("${component}" "postprocess.h") + elseif(component STREQUAL "swresample") + find_ffmpeg_library("${component}" "swresample.h") + elseif(component STREQUAL "swscale") + find_ffmpeg_library("${component}" "swscale.h") + else() + message(FATAL_ERROR "Unknown FFmpeg component requested: ${component}") + endif() +endforeach() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FFmpeg + FOUND_VAR FFMPEG_FOUND + REQUIRED_VARS FFMPEG_${_first_comp}_LIBRARIES FFMPEG_${_first_comp}_STATIC_LIBRARIES FFMPEG_${_first_comp}_INCLUDE_DIRS + VERSION_VAR FFMPEG_${_first_comp}_VERSION_STRING + HANDLE_COMPONENTS) diff --git a/cmake/modules/FindFontConfig.cmake b/cmake/modules/FindFontConfig.cmake new file mode 100644 index 000000000..f01c6cd9e --- /dev/null +++ b/cmake/modules/FindFontConfig.cmake @@ -0,0 +1,37 @@ +# - Try to find the PANGO_CAIRO libraries +# Once done this will define +# +# FONTCONFIG_FOUND - system has cairo-xlib +# FONTCONFIG_INCLUDE_DIR - the glib2 include directory +# FONTCONFIG_LIBRARIES - glib2 library + +# Copyright (c) 2012 CSSlayer +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +if(FONTCONFIG_INCLUDE_DIR AND FONTCONFIG_LIBRARIES) + # Already in cache, be silent + set(FONTCONFIG_FIND_QUIETLY TRUE) +endif(FONTCONFIG_INCLUDE_DIR AND FONTCONFIG_LIBRARIES) + +find_package(PkgConfig) +pkg_check_modules(PC_FONTCONFIG QUIET fontconfig) + +find_path(FONTCONFIG_INCLUDE_DIR + NAMES fontconfig.h + HINTS ${PC_FONTCONFIG_INCLUDE_DIRS} + PATH_SUFFIXES fontconfig) + +find_library(FONTCONFIG_LIBRARY + NAMES fontconfig + HINTS ${PC_FONTCONFIG_LIBRARY_DIRS} +) + +set(FONTCONFIG_LIBRARIES ${FONTCONFIG_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FontConfig DEFAULT_MSG FONTCONFIG_LIBRARIES FONTCONFIG_INCLUDE_DIR) + +mark_as_advanced(FONTCONFIG_INCLUDE_DIR FONTCONFIG_LIBRARIES FONTCONFIG_LIBRARY) diff --git a/cmake/modules/FindFreetype.cmake b/cmake/modules/FindFreetype.cmake new file mode 100644 index 000000000..80b1ece4f --- /dev/null +++ b/cmake/modules/FindFreetype.cmake @@ -0,0 +1,164 @@ +#.rst: +# FindFreetype +# ------------ +# +# Locate FreeType library +# +# This module defines +# +# :: +# +# FREETYPE_LIBRARIES, the library to link against +# FREETYPE_FOUND, if false, do not try to link to FREETYPE +# FREETYPE_INCLUDE_DIRS, where to find headers. +# FREETYPE_VERSION_STRING, the version of freetype found (since CMake 2.8.8) +# This is the concatenation of the paths: +# FREETYPE_INCLUDE_DIR_ft2build +# FREETYPE_INCLUDE_DIR_freetype2 +# +# +# +# $FREETYPE_DIR is an environment variable that would correspond to the +# ./configure --prefix=$FREETYPE_DIR used in building FREETYPE. + +#============================================================================= +# Copyright 2007-2009 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# Created by Eric Wing. +# Modifications by Alexander Neundorf. +# This file has been renamed to "FindFreetype.cmake" instead of the correct +# "FindFreeType.cmake" in order to be compatible with the one from KDE4, Alex. + +# Ugh, FreeType seems to use some #include trickery which +# makes this harder than it should be. It looks like they +# put ft2build.h in a common/easier-to-find location which +# then contains a #include to a more specific header in a +# more specific location (#include ). +# Then from there, they need to set a bunch of #define's +# so you can do something like: +# #include FT_FREETYPE_H +# Unfortunately, using CMake's mechanisms like include_directories() +# wants explicit full paths and this trickery doesn't work too well. +# I'm going to attempt to cut out the middleman and hope +# everything still works. +find_path( + FREETYPE_INCLUDE_DIR_ft2build + ft2build.h + HINTS + ENV FREETYPE_DIR + PATHS + /usr/X11R6 + /usr/local/X11R6 + /usr/local/X11 + /usr/freeware + ENV GTKMM_BASEPATH + [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] + PATH_SUFFIXES + include/freetype2 + include + freetype2 +) + +find_path( + FREETYPE_INCLUDE_DIR_freetype2 + NAMES + freetype/config/ftheader.h + config/ftheader.h + HINTS + ENV FREETYPE_DIR + PATHS + /usr/X11R6 + /usr/local/X11R6 + /usr/local/X11 + /usr/freeware + ENV GTKMM_BASEPATH + [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] + PATH_SUFFIXES + include/freetype2 + include + freetype2 +) + +find_library(FREETYPE_LIBRARY + NAMES + freetype + libfreetype + freetype219 + HINTS + ENV FREETYPE_DIR + PATHS + /usr/X11R6 + /usr/local/X11R6 + /usr/local/X11 + /usr/freeware + ENV GTKMM_BASEPATH + [HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path] + [HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path] + PATH_SUFFIXES + lib +) + +# set the user variables +if(FREETYPE_INCLUDE_DIR_ft2build AND FREETYPE_INCLUDE_DIR_freetype2) + set(FREETYPE_INCLUDE_DIRS "${FREETYPE_INCLUDE_DIR_ft2build};${FREETYPE_INCLUDE_DIR_freetype2}") + list(REMOVE_DUPLICATES FREETYPE_INCLUDE_DIRS) +endif() +set(FREETYPE_LIBRARIES "${FREETYPE_LIBRARY}") + +if(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h") + set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype/freetype.h") +elseif(EXISTS "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h") + set(FREETYPE_H "${FREETYPE_INCLUDE_DIR_freetype2}/freetype.h") +endif() + +if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H) + file(STRINGS "${FREETYPE_H}" freetype_version_str + REGEX "^#[\t ]*define[\t ]+FREETYPE_(MAJOR|MINOR|PATCH)[\t ]+[0-9]+$") + + unset(FREETYPE_VERSION_STRING) + foreach(VPART MAJOR MINOR PATCH) + foreach(VLINE ${freetype_version_str}) + if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$") + set(FREETYPE_VERSION_PART "${CMAKE_MATCH_1}") + if(FREETYPE_VERSION_STRING) + set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_STRING}.${FREETYPE_VERSION_PART}") + else() + set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_PART}") + endif() + unset(FREETYPE_VERSION_PART) + endif() + endforeach() + endforeach() +endif() + + +# handle the QUIETLY and REQUIRED arguments and set FREETYPE_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) + +find_package_handle_standard_args( + Freetype + REQUIRED_VARS + FREETYPE_LIBRARY + FREETYPE_INCLUDE_DIRS + VERSION_VAR + FREETYPE_VERSION_STRING +) + +mark_as_advanced( + FREETYPE_LIBRARY + FREETYPE_INCLUDE_DIR_freetype2 + FREETYPE_INCLUDE_DIR_ft2build +) diff --git a/cmake/modules/FindOpenAL.cmake b/cmake/modules/FindOpenAL.cmake new file mode 100644 index 000000000..96984c14b --- /dev/null +++ b/cmake/modules/FindOpenAL.cmake @@ -0,0 +1,42 @@ +# - Try to find the OpenAL libraries +# Cmake included module does not include static deps +# +# Once done this will define +# +# OPENAL_FOUND +# OPENAL_INCLUDE_DIRS +# OPENAL_LIBRARIES +# OPENAL_CFLAGS +# +# OPENAL_INCLUDE_DIR +# OPENAL_LIBRARY + +# Copyright (c) 2016 Jeffrey Clark +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +find_package(PkgConfig) +pkg_check_modules(PC_OPENAL openal) + +find_path(OPENAL_INCLUDE_DIR + NAMES al.h + HINTS ${PC_OPENAL_LIBRARY_DIRS} + PATH_SUFFIXES include/AL include/OpenAL include + DOC "OpenAL include directory") + +find_library(OPENAL_LIBRARY + NAMES OpenAL al openal OpenAL32 + HINTS ${PC_OPENAL_LIBRARY_DIRS} + DOC "OpenAL library") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OpenAL DEFAULT_MSG OPENAL_LIBRARY OPENAL_INCLUDE_DIR) + +if(OPENAL_FOUND) + set(OPENAL_LIBRARIES ${PC_OPENAL_LIBRARIES}) + set(OPENAL_INCLUDE_DIRS ${OPENAL_INCLUDE_DIR}) + set(OPENAL_CFLAGS ${PC_OPENAL_CFLAGS_OTHER}) +endif() + +mark_as_advanced(OPENAL_INCLUDE_DIR OPENAL_LIBRARY OPENAL_CFLAGS) diff --git a/cmake/modules/FindOpenGLES.cmake b/cmake/modules/FindOpenGLES.cmake new file mode 100644 index 000000000..9f1d46df2 --- /dev/null +++ b/cmake/modules/FindOpenGLES.cmake @@ -0,0 +1,41 @@ +# - Try to find OpenGLES + +set(GLES_SEARCH_PATHS + ${GLES_SEARCH_PATHS} + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /opt + /opt/graphics/OpenGL + /opt/vc # Raspberry pi + /usr/openwin + /usr/shlib + /usr/X11R6/ +) + + +find_path(OPENGLES_INCLUDE_DIR + NAMES GLES/gl.h OpenGLES/ES1/gl.h + PATH_SUFFIXES include include/GLES GLES + PATHS ${GLES_SEARCH_PATHS} +) + +find_library(OPENGLES_LIBRARY + NAMES libGLESv1_CM GLESv1_CM libGLES_CM GLES_CM + PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 lib/x86_64-linux-gnu/mesa-egl + PATHS ${GLES_SEARCH_PATHS} +) + +if(OPENGLES_LIBRARY) + set(OPENGLES_LIBRARIES ${OPENGLES_LIBRARY}) +else() + message(ERROR "OPENGLES Library not found! debug FindOpenGLES.cmake!") +endif() + +# Handle the QUIETLY and REQUIRED arguments and set XXX_FOUND to TRUE if all listed variables are TRUE +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(OPENGLES DEFAULT_MSG OPENGLES_LIBRARIES OPENGLES_INCLUDE_DIR) diff --git a/cmake/modules/FindSFML.cmake b/cmake/modules/FindSFML.cmake new file mode 100644 index 000000000..09dabbffa --- /dev/null +++ b/cmake/modules/FindSFML.cmake @@ -0,0 +1,366 @@ +# 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 (i.e. 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 ...). +# Since you have to link yourself all the SFML dependencies when you link it statically, the following +# additional variables are defined: SFML_XXX_DEPENDENCIES and SFML_DEPENDENCIES (see their detailed +# description below). +# 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_XXX_DEPENDENCIES: the list of libraries the module depends on, in case of static linking +# - 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) +# - SFML_DEPENDENCIES: the list of libraries SFML depends on, in case of static linking +# +# 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() + +# define the list of search paths for headers and libraries +set(FIND_SFML_PATHS + ${SFML_ROOT} + $ENV{SFML_ROOT} + ~/Library/Frameworks + /Library/Frameworks + /usr/local + /usr + /sw + /opt/local + /opt/csw + /opt) + +# find the SFML include directory +find_path(SFML_INCLUDE_DIR SFML/Config.hpp + PATH_SUFFIXES include + PATHS ${FIND_SFML_PATHS}) + +# 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]+).*#define SFML_VERSION_PATCH ([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}") + STRING(REGEX REPLACE ".*#define SFML_VERSION_PATCH ([0-9]+).*" "\\1" SFML_VERSION_PATCH "${SFML_CONFIG_HPP_CONTENTS}") + math(EXPR SFML_REQUESTED_VERSION "${SFML_FIND_VERSION_MAJOR} * 10000 + ${SFML_FIND_VERSION_MINOR} * 100 + ${SFML_FIND_VERSION_PATCH}") + + # 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} * 10000 + ${SFML_VERSION_MINOR} * 100 + ${SFML_VERSION_PATCH}") + + # 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 10900) + set(SFML_VERSION_OK FALSE) + set(SFML_VERSION_MAJOR 1) + set(SFML_VERSION_MINOR x) + set(SFML_VERSION_PATCH 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 +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}) + + # no suffix for sfml-main, it is always a static library + if(FIND_SFML_COMPONENT_LOWER STREQUAL "main") + # release library + find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE + NAMES ${FIND_SFML_COMPONENT_NAME} + PATH_SUFFIXES lib64 lib + PATHS ${FIND_SFML_PATHS}) + + # debug library + find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG + NAMES ${FIND_SFML_COMPONENT_NAME}-d + PATH_SUFFIXES lib64 lib + PATHS ${FIND_SFML_PATHS}) + else() + # static release library + find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE + NAMES ${FIND_SFML_COMPONENT_NAME}-s + PATH_SUFFIXES lib64 lib + PATHS ${FIND_SFML_PATHS}) + + # static debug library + find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG + NAMES ${FIND_SFML_COMPONENT_NAME}-s-d + PATH_SUFFIXES lib64 lib + PATHS ${FIND_SFML_PATHS}) + + # dynamic release library + find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE + NAMES ${FIND_SFML_COMPONENT_NAME} + PATH_SUFFIXES lib64 lib + PATHS ${FIND_SFML_PATHS}) + + # dynamic debug library + find_library(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG + NAMES ${FIND_SFML_COMPONENT_NAME}-d + PATH_SUFFIXES lib64 lib + PATHS ${FIND_SFML_PATHS}) + + # choose the entries that fit the requested link type + if(SFML_STATIC_LIBRARIES) + if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE) + set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE}) + endif() + if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG) + set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG}) + endif() + else() + if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE) + set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_RELEASE ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE}) + endif() + if(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG) + set(SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DEBUG ${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG}) + endif() + endif() + endif() + + 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 + SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_RELEASE + SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_STATIC_DEBUG + SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_RELEASE + SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY_DYNAMIC_DEBUG) + + # add to the global list of libraries + set(SFML_LIBRARIES ${SFML_LIBRARIES} "${SFML_${FIND_SFML_COMPONENT_UPPER}_LIBRARY}") +endforeach() + +# in case of static linking, we must also define the list of all the dependencies of SFML libraries +if(SFML_STATIC_LIBRARIES) + + # detect the OS + if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") + set(FIND_SFML_OS_WINDOWS 1) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(FIND_SFML_OS_LINUX 1) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") + set(FIND_SFML_OS_FREEBSD 1) + elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(FIND_SFML_OS_MACOSX 1) + endif() + + # start with an empty list + set(SFML_DEPENDENCIES) + set(FIND_SFML_DEPENDENCIES_NOTFOUND) + + # macro that searches for a 3rd-party library + macro(find_sfml_dependency output friendlyname) + # No lookup in environment variables (PATH on Windows), as they may contain wrong library versions + find_library(${output} NAMES ${ARGN} PATHS ${FIND_SFML_PATHS} PATH_SUFFIXES lib NO_SYSTEM_ENVIRONMENT_PATH) + if(${${output}} STREQUAL "${output}-NOTFOUND") + unset(output) + set(FIND_SFML_DEPENDENCIES_NOTFOUND "${FIND_SFML_DEPENDENCIES_NOTFOUND} ${friendlyname}") + endif() + endmacro() + + # sfml-system + list(FIND SFML_FIND_COMPONENTS "system" FIND_SFML_SYSTEM_COMPONENT) + if(NOT ${FIND_SFML_SYSTEM_COMPONENT} EQUAL -1) + + # update the list -- these are only system libraries, no need to find them + if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD OR FIND_SFML_OS_MACOSX) + set(SFML_SYSTEM_DEPENDENCIES "pthread") + endif() + if(FIND_SFML_OS_LINUX) + set(SFML_SYSTEM_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} "rt") + endif() + if(FIND_SFML_OS_WINDOWS) + set(SFML_SYSTEM_DEPENDENCIES "winmm") + endif() + set(SFML_DEPENDENCIES ${SFML_SYSTEM_DEPENDENCIES} ${SFML_DEPENDENCIES}) + endif() + + # sfml-network + list(FIND SFML_FIND_COMPONENTS "network" FIND_SFML_NETWORK_COMPONENT) + if(NOT ${FIND_SFML_NETWORK_COMPONENT} EQUAL -1) + + # update the list -- these are only system libraries, no need to find them + if(FIND_SFML_OS_WINDOWS) + set(SFML_NETWORK_DEPENDENCIES "ws2_32") + endif() + set(SFML_DEPENDENCIES ${SFML_NETWORK_DEPENDENCIES} ${SFML_DEPENDENCIES}) + endif() + + # sfml-window + list(FIND SFML_FIND_COMPONENTS "window" FIND_SFML_WINDOW_COMPONENT) + if(NOT ${FIND_SFML_WINDOW_COMPONENT} EQUAL -1) + + # find libraries + if(FIND_SFML_OS_LINUX OR FIND_SFML_OS_FREEBSD) + find_sfml_dependency(X11_LIBRARY "X11" X11) + find_sfml_dependency(LIBXCB_LIBRARIES "XCB" xcb libxcb) + find_sfml_dependency(X11_XCB_LIBRARY "X11-xcb" X11-xcb libX11-xcb) + find_sfml_dependency(XCB_RANDR_LIBRARY "xcb-randr" xcb-randr libxcb-randr) + find_sfml_dependency(XCB_IMAGE_LIBRARY "xcb-image" xcb-image libxcb-image) + endif() + + if(FIND_SFML_OS_LINUX) + find_sfml_dependency(UDEV_LIBRARIES "UDev" udev libudev) + endif() + + # update the list + if(FIND_SFML_OS_WINDOWS) + set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "opengl32" "winmm" "gdi32") + elseif(FIND_SFML_OS_LINUX) + set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${LIBXCB_LIBRARIES} ${X11_XCB_LIBRARY} ${XCB_RANDR_LIBRARY} ${XCB_IMAGE_LIBRARY} ${UDEV_LIBRARIES}) + elseif(FIND_SFML_OS_FREEBSD) + set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "GL" ${X11_LIBRARY} ${LIBXCB_LIBRARIES} ${X11_XCB_LIBRARY} ${XCB_RANDR_LIBRARY} ${XCB_IMAGE_LIBRARY} "usbhid") + elseif(FIND_SFML_OS_MACOSX) + set(SFML_WINDOW_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} "-framework OpenGL -framework Foundation -framework AppKit -framework IOKit -framework Carbon") + endif() + set(SFML_DEPENDENCIES ${SFML_WINDOW_DEPENDENCIES} ${SFML_DEPENDENCIES}) + endif() + + # sfml-graphics + list(FIND SFML_FIND_COMPONENTS "graphics" FIND_SFML_GRAPHICS_COMPONENT) + if(NOT ${FIND_SFML_GRAPHICS_COMPONENT} EQUAL -1) + + # find libraries + find_sfml_dependency(FREETYPE_LIBRARY "FreeType" freetype) + find_sfml_dependency(JPEG_LIBRARY "libjpeg" jpeg) + + # update the list + set(SFML_GRAPHICS_DEPENDENCIES ${FREETYPE_LIBRARY} ${JPEG_LIBRARY}) + set(SFML_DEPENDENCIES ${SFML_GRAPHICS_DEPENDENCIES} ${SFML_DEPENDENCIES}) + endif() + + # sfml-audio + list(FIND SFML_FIND_COMPONENTS "audio" FIND_SFML_AUDIO_COMPONENT) + if(NOT ${FIND_SFML_AUDIO_COMPONENT} EQUAL -1) + + # find libraries + find_sfml_dependency(OPENAL_LIBRARY "OpenAL" openal openal32) + find_sfml_dependency(OGG_LIBRARY "Ogg" ogg) + find_sfml_dependency(VORBIS_LIBRARY "Vorbis" vorbis) + find_sfml_dependency(VORBISFILE_LIBRARY "VorbisFile" vorbisfile) + find_sfml_dependency(VORBISENC_LIBRARY "VorbisEnc" vorbisenc) + find_sfml_dependency(FLAC_LIBRARY "FLAC" FLAC flac) + + # update the list + set(SFML_AUDIO_DEPENDENCIES ${OPENAL_LIBRARY} ${FLAC_LIBRARY} ${VORBISENC_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY}) + set(SFML_DEPENDENCIES ${SFML_DEPENDENCIES} ${SFML_AUDIO_DEPENDENCIES}) + endif() + +endif() + +# 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}.${SFML_VERSION_PATCH})") + set(SFML_FOUND FALSE) +elseif(SFML_STATIC_LIBRARIES AND FIND_SFML_DEPENDENCIES_NOTFOUND) + set(FIND_SFML_ERROR "SFML found but some of its dependencies are missing (${FIND_SFML_DEPENDENCIES_NOTFOUND})") + 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 AND NOT SFML_FIND_QUIETLY) + message(STATUS "Found SFML ${SFML_VERSION_MAJOR}.${SFML_VERSION_MINOR}.${SFML_VERSION_PATCH} in ${SFML_INCLUDE_DIR}") +endif() diff --git a/cmake/modules/FindXML2.cmake b/cmake/modules/FindXML2.cmake new file mode 100644 index 000000000..9d0eebe14 --- /dev/null +++ b/cmake/modules/FindXML2.cmake @@ -0,0 +1,55 @@ +############################################################################ +# FindXML2.txt +# Copyright (C) 2015 Belledonne Communications, Grenoble France +# +############################################################################ +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +############################################################################ +# +# - Find the libxml2 include file and library +# +# XML2_FOUND - system has libxml2 +# XML2_INCLUDE_DIRS - the libxml2 include directory +# XML2_LIBRARIES - The libraries needed to use libxml2 + +set(_XML2_ROOT_PATHS + ${CMAKE_INSTALL_PREFIX} +) + +find_path(XML2_INCLUDE_DIRS + NAMES libxml/xmlreader.h + HINTS _XML2_ROOT_PATHS + PATH_SUFFIXES include/libxml2 +) + +if(XML2_INCLUDE_DIRS) + set(HAVE_LIBXML_XMLREADER_H 1) +endif() + +find_library(XML2_LIBRARIES + NAMES xml2 + HINTS ${_XML2_ROOT_PATHS} + PATH_SUFFIXES bin lib +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(XML2 + DEFAULT_MSG + XML2_INCLUDE_DIRS XML2_LIBRARIES +) + +mark_as_advanced(XML2_INCLUDE_DIRS XML2_LIBRARIES) diff --git a/cmake/modules/FindXinerama.cmake b/cmake/modules/FindXinerama.cmake new file mode 100644 index 000000000..b43158b12 --- /dev/null +++ b/cmake/modules/FindXinerama.cmake @@ -0,0 +1,45 @@ +# - Try to find the Xinerama libraries +# Once done this will define +# +# XINERAMA_FOUND +# XINERAMA_INCLUDE_DIRS +# XINERAMA_LIBRARIES +# +# XINERAMA_INCLUDE_DIR +# XINERAMA_LIBRARY + +# Copyright (c) 2016 Jeffrey Clark +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +if(XINERAMA_INCLUDE_DIR AND XINERAMA_LIBRARY) + # Already in cache, be silent + set(XINERAMA_FIND_QUIETLY TRUE) +endif(XINERAMA_INCLUDE_DIR AND XINERAMA_LIBRARY) + +find_package(PkgConfig) +pkg_check_modules(PC_XINERAMA QUIET xinerama) + +find_path(XINERAMA_INCLUDE_DIR + NAMES Xinerama.h + HINTS ${PC_XINERAMA_INCLUDE_DIRS} + PATH_SUFFIXES X11/extensions + DOC "Xinerama include directory") + +find_library(XINERAMA_LIBRARY + NAMES Xinerama xinerama + HINTS ${PC_XINERAMA_LIBRARY_DIRS} + DOC "Xinerama library" +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Xinerama DEFAULT_MSG XINERAMA_LIBRARY XINERAMA_INCLUDE_DIR) + +if(XINERAMA_FOUND) + set(XINERAMA_LIBRARIES ${XINERAMA_LIBRARY}) + set(XINERAMA_INCLUDE_DIRS ${XINERAMA_INCLUDE_DIR}) +endif() + +mark_as_advanced(XINERAMA_INCLUDE_DIR XINERAMA_LIBRARY) diff --git a/cmake/modules/GetGitRevisionDescription.cmake b/cmake/modules/GetGitRevisionDescription.cmake new file mode 100644 index 000000000..0af2fce3b --- /dev/null +++ b/cmake/modules/GetGitRevisionDescription.cmake @@ -0,0 +1,159 @@ +# - Returns a version string from Git +# +# These functions force a re-configure on each git commit so that you can +# trust the values of the variables in your build system. +# +# get_git_head_revision( [ ...]) +# +# Returns the refspec and sha hash of the current head revision +# +# git_describe( [ ...]) +# +# Returns the results of git describe on the source tree, and adjusting +# the output so that it tests false if an error occurs. +# +# git_get_exact_tag( [ ...]) +# +# Returns the results of git describe --exact-match on the source tree, +# and adjusting the output so that it tests false if there was no exact +# matching tag. +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +if(__get_git_revision_description) + return() +endif() +set(__get_git_revision_description YES) + +# We must run the following at "include" time, not at function call time, +# to find the path to this module rather than the path to a calling list file +get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH) + +function(get_git_head_revision _refspecvar _hashvar) + set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}") + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories + set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}") + get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH) + if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT) + # We have reached the root directory, we are not in git + set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE) + return() + endif() + set(GIT_DIR "${GIT_PARENT_DIR}/.git") + endwhile() + # check if this is a submodule + if(NOT IS_DIRECTORY ${GIT_DIR}) + file(READ ${GIT_DIR} submodule) + string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule}) + get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH) + get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE) + endif() + set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data") + if(NOT EXISTS "${GIT_DATA}") + file(MAKE_DIRECTORY "${GIT_DATA}") + endif() + + if(NOT EXISTS "${GIT_DIR}/HEAD") + return() + endif() + set(HEAD_FILE "${GIT_DATA}/HEAD") + configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY) + + configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in" + "${GIT_DATA}/grabRef.cmake" + @ONLY) + include("${GIT_DATA}/grabRef.cmake") + + set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE) + set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE) +endfunction() + +function(git_describe _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + if(NOT hash) + set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE) + return() + endif() + + # TODO sanitize + #if((${ARGN}" MATCHES "&&") OR + # (ARGN MATCHES "||") OR + # (ARGN MATCHES "\\;")) + # message("Please report the following error to the project!") + # message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}") + #endif() + + #message(STATUS "Arguments to execute_process: ${ARGN}") + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + describe + ${hash} + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_get_exact_tag _var) + git_describe(out --exact-match ${ARGN}) + set(${_var} "${out}" PARENT_SCOPE) +endfunction() + +function(git_revlist _var) + if(NOT GIT_FOUND) + find_package(Git QUIET) + endif() + get_git_head_revision(refspec hash) + if(NOT GIT_FOUND) + set(${_var} "GIT-NOTFOUND" PARENT_SCOPE) + return() + endif() + + execute_process(COMMAND + "${GIT_EXECUTABLE}" + rev-list + ${ARGN} + WORKING_DIRECTORY + "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE + res + OUTPUT_VARIABLE + out + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT res EQUAL 0) + set(out "${out}-${res}-NOTFOUND") + endif() + + set(${_var} "${out}" PARENT_SCOPE) +endfunction() diff --git a/cmake/modules/GetGitRevisionDescription.cmake.in b/cmake/modules/GetGitRevisionDescription.cmake.in new file mode 100644 index 000000000..6d8b708ef --- /dev/null +++ b/cmake/modules/GetGitRevisionDescription.cmake.in @@ -0,0 +1,41 @@ +# +# Internal file for GetGitRevisionDescription.cmake +# +# Requires CMake 2.6 or newer (uses the 'function' command) +# +# Original Author: +# 2009-2010 Ryan Pavlik +# http://academic.cleardefinition.com +# Iowa State University HCI Graduate Program/VRAC +# +# Copyright Iowa State University 2009-2010. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +set(HEAD_HASH) + +file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024) + +string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS) +if(HEAD_CONTENTS MATCHES "ref") + # named branch + string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}") + if(EXISTS "@GIT_DIR@/${HEAD_REF}") + configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY) + else() + configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY) + file(READ "@GIT_DATA@/packed-refs" PACKED_REFS) + if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}") + set(HEAD_HASH "${CMAKE_MATCH_1}") + endif() + endif() +else() + # detached HEAD + configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY) +endif() + +if(NOT HEAD_HASH) + file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024) + string(STRIP "${HEAD_HASH}" HEAD_HASH) +endif() diff --git a/cmake/modules/TargetArch.cmake b/cmake/modules/TargetArch.cmake new file mode 100644 index 000000000..87b36e794 --- /dev/null +++ b/cmake/modules/TargetArch.cmake @@ -0,0 +1,136 @@ +# Based on the Qt 5 processor detection code, so should be very accurate +# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h +# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, mips, and ppc (32/64) + +# Regarding POWER/PowerPC, just as is noted in the Qt source, +# "There are many more known variants/revisions that we do not handle/detect." + +set(archdetect_c_code " +#if defined(__arm__) || defined(__TARGET_ARCH_ARM) + #if defined(__ARM_ARCH_7__) \\ + || defined(__ARM_ARCH_7A__) \\ + || defined(__ARM_ARCH_7R__) \\ + || defined(__ARM_ARCH_7M__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) + #error cmake_ARCH armv7 + #elif defined(__ARM_ARCH_6__) \\ + || defined(__ARM_ARCH_6J__) \\ + || defined(__ARM_ARCH_6T2__) \\ + || defined(__ARM_ARCH_6Z__) \\ + || defined(__ARM_ARCH_6K__) \\ + || defined(__ARM_ARCH_6ZK__) \\ + || defined(__ARM_ARCH_6M__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) + #error cmake_ARCH armv6 + #elif defined(__ARM_ARCH_5TEJ__) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) + #error cmake_ARCH armv5 + #else + #error cmake_ARCH arm + #endif +#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) + #error cmake_ARCH i386 +#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) + #error cmake_ARCH x86_64 +#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) + #error cmake_ARCH ia64 +#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\ + || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\ + || defined(_M_MPPC) || defined(_M_PPC) + #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) + #error cmake_ARCH ppc64 + #else + #error cmake_ARCH ppc + #endif +#elif defined(__mips__) + #error cmake_ARCH mips +#endif + +#error cmake_ARCH unknown +") + +# Set ppc_support to TRUE before including this file or ppc and ppc64 +# will be treated as invalid architectures since they are no longer supported by Apple + +function(target_architecture output_var) + if(APPLE AND CMAKE_OSX_ARCHITECTURES) + # On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set + # First let's normalize the order of the values + + # Note that it's not possible to compile PowerPC applications if you are using + # the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we + # disable it by default + # See this page for more information: + # http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4 + + # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. + # On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. + + foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) + if("${osx_arch}" STREQUAL "ppc" AND ppc_support) + set(osx_arch_ppc TRUE) + elseif("${osx_arch}" STREQUAL "i386") + set(osx_arch_i386 TRUE) + elseif("${osx_arch}" STREQUAL "x86_64") + set(osx_arch_x86_64 TRUE) + elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) + set(osx_arch_ppc64 TRUE) + else() + message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}") + endif() + endforeach() + + # Now add all the architectures in our normalized order + if(osx_arch_ppc) + list(APPEND ARCH ppc) + endif() + + if(osx_arch_i386) + list(APPEND ARCH i386) + endif() + + if(osx_arch_x86_64) + list(APPEND ARCH x86_64) + endif() + + if(osx_arch_ppc64) + list(APPEND ARCH ppc64) + endif() + else() + file(WRITE "${CMAKE_BINARY_DIR}/arch.c" "${archdetect_c_code}") + + enable_language(C) + + # Detect the architecture in a rather creative way... + # This compiles a small C program which is a series of ifdefs that selects a + # particular #error preprocessor directive whose message string contains the + # target architecture. The program will always fail to compile (both because + # file is not a valid C program, and obviously because of the presence of the + # #error preprocessor directives... but by exploiting the preprocessor in this + # way, we can detect the correct target architecture even when cross-compiling, + # since the program itself never needs to be run (only the compiler/preprocessor) + try_run( + run_result_unused + compile_result_unused + "${CMAKE_BINARY_DIR}" + "${CMAKE_BINARY_DIR}/arch.c" + COMPILE_OUTPUT_VARIABLE ARCH + CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES} + ) + + # Parse the architecture name from the compiler output + string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}") + + # Get rid of the value marker leaving just the architecture name + string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}") + + # If we are compiling with an unknown architecture this variable should + # already be set to "unknown" but in the case that it's empty (i.e. due + # to a typo in the code), then set it to unknown + if (NOT ARCH) + set(ARCH unknown) + endif() + endif() + + set(${output_var} "${ARCH}" PARENT_SCOPE) +endfunction() diff --git a/config.h.in b/config.h.in new file mode 100644 index 000000000..4820981b6 --- /dev/null +++ b/config.h.in @@ -0,0 +1,25 @@ +#define FE_VERSION_MAJOR @VER_MAJOR@ +#define FE_VERSION_MINOR @VER_MINOR@ +#define FE_VERSION_POINT @VER_POINT@ +#define FE_VERSION_COUNT @VER_COUNT@ +#define FE_VERSION_NUM @VER_MAJOR@@VER_MINOR@@VER_POINT@ +#define FE_VERSION_D "@VER_TAG@" + +#define @TARGET_SYSTEM@ +#define @TARGET_ARCH@ + +#define SFML_NO_DEPRECATED_WARNINGS + +#cmakedefine NO_MOVIE +#cmakedefine NO_NET +#cmakedefine NO_SWF +#cmakedefine USE_FONTCONFIG +#cmakedefine USE_LIBARCHIVE +#cmakedefine USE_XINERAMA +#cmakedefine USE_GLES +#cmakedefine FE_DEBUG +#cmakedefine FE_RPI + +#define DATA_PATH "@DATA_PATH@" + +#define FE_NAME_D "Attract-Mode" diff --git a/extlibs/CMakeLists.txt b/extlibs/CMakeLists.txt new file mode 100644 index 000000000..e2fc6f63d --- /dev/null +++ b/extlibs/CMakeLists.txt @@ -0,0 +1,13 @@ +if(NOT NO_MOVIE) + add_subdirectory(audio) +endif() + +add_subdirectory(squirrel) + +if(NOT EXPAT_FOUND) + add_subdirectory(expat) +endif() + +if(NOT NO_SWF) + add_subdirectory(gameswf) +endif() diff --git a/extlibs/audio/CMakeLists.txt b/extlibs/audio/CMakeLists.txt new file mode 100644 index 000000000..4522f0f2a --- /dev/null +++ b/extlibs/audio/CMakeLists.txt @@ -0,0 +1,21 @@ +find_package(OpenAL REQUIRED) + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${OPENAL_INCLUDE_DIR} + ${SFML_INCLUDE_DIR} +) + +set(audio_SOURCES + Audio/ALCheck.cpp + Audio/AudioDevice.cpp + Audio/Listener.cpp + Audio/SoundSource.cpp + Audio/SoundStream.cpp +) + +add_definitions(${OPENAL_CFLAGS}) +add_library(audiolib STATIC ${audio_SOURCES}) + +target_link_libraries(audiolib PUBLIC ${OPENAL_LIBRARIES}) +target_include_directories(audiolib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/extlibs/expat/CMakeLists.txt b/extlibs/expat/CMakeLists.txt new file mode 100644 index 000000000..1eb6b2732 --- /dev/null +++ b/extlibs/expat/CMakeLists.txt @@ -0,0 +1,20 @@ +include(CheckFunctionExists) + +check_function_exists(memmove MEMMOVE_EXISTS) +if(MEMMOVE_EXISTS) + add_definitions("-DHAVE_MEMMOVE") +else() + message(FATAL_ERROR "memmove not supported") +endif() + +set(expat_SOURCES + xmlparse.c + xmlrole.c + xmlrole.h + xmltok.c + xmltok.h +) + +add_library(expat STATIC ${expat_SOURCES}) + +target_include_directories(expat PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/extlibs/expat/xmlparse.c b/extlibs/expat/xmlparse.c index f35aa36ba..e9221ca18 100644 --- a/extlibs/expat/xmlparse.c +++ b/extlibs/expat/xmlparse.c @@ -1565,7 +1565,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) else { switch (ps_parsing) { case XML_SUSPENDED: - result = XML_STATUS_SUSPENDED; + result = (enum XML_Error) XML_STATUS_SUSPENDED; break; case XML_INITIALIZED: case XML_PARSING: @@ -1575,7 +1575,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) } /* fall through */ default: - result = XML_STATUS_OK; + result = (enum XML_Error) XML_STATUS_OK; } } @@ -1605,7 +1605,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) parseEndPtr = bufferEnd; eventPtr = bufferPtr; eventEndPtr = bufferPtr; - return result; + return (enum XML_Status) result; } #endif /* not defined XML_CONTEXT_BYTES */ else { diff --git a/extlibs/gameswf/CMakeLists.txt b/extlibs/gameswf/CMakeLists.txt new file mode 100644 index 000000000..eb9536ca1 --- /dev/null +++ b/extlibs/gameswf/CMakeLists.txt @@ -0,0 +1,116 @@ +if(USE_GLES) + find_package(OpenGLES REQUIRED) +else() + find_package(OpenGL REQUIRED) +endif() + +find_package(JPEG REQUIRED) +find_package(ZLIB REQUIRED) +find_package(OpenAL REQUIRED) +find_package(Threads REQUIRED) + +if(NOT APPLE) + find_package(Freetype REQUIRED) +endif() + +# Missing gameswf_xml.[cpp|h] +#find_package( XML2 ) +# +#if ( XML2_FOUND ) +# add_definitions( -DHAVE_LIBXML ) +#endif() + +set(base_SOURCES + base/container.cpp + base/cschema.h + base/ear_clip_triangulate_float.cpp + base/ear_clip_triangulate_sint16.cpp + base/file_util.cpp + base/image.cpp + base/image_filters.cpp + base/jpeg.cpp + base/logger.cpp + base/membuf.cpp + base/postscript.cpp + base/triangulate_float.cpp + base/triangulate_sint32.cpp + base/tu_file.cpp + base/tu_gc_singlethreaded_marksweep.cpp + base/tu_loadlib.cpp + base/tu_random.cpp + base/tu_timer.cpp + base/tu_types.cpp + base/utf8.cpp + base/utility.cpp + base/zlib_adapter.cpp +) + +file(GLOB_RECURSE gameswf_as_SOURCES gameswf/gameswf_as_classes/*.cpp gameswf/gameswf_as_classes/*.h) + +set(gameswf_SOURCES + ${gameswf_as_SOURCES} + gameswf/gameswf_abc.cpp + gameswf/gameswf_action.cpp + gameswf/gameswf_avm2.cpp + gameswf/gameswf_as_sprite.cpp + gameswf/gameswf_button.cpp + gameswf/gameswf_canvas.cpp + gameswf/gameswf_character.cpp + gameswf/gameswf_disasm.cpp + gameswf/gameswf_dlist.cpp + gameswf/gameswf_environment.cpp + gameswf/gameswf_filters.cpp + gameswf/gameswf_font.cpp + gameswf/gameswf_function.cpp + gameswf/gameswf_impl.cpp + gameswf/gameswf_listener.cpp + gameswf/gameswf_log.cpp + gameswf/gameswf_morph2.cpp + gameswf/gameswf_movie_def.cpp + gameswf/gameswf_object.cpp + gameswf/gameswf_player.cpp + gameswf/gameswf_render.cpp + gameswf/gameswf_root.cpp + gameswf/gameswf_shape.cpp + gameswf/gameswf_sound.cpp + gameswf/gameswf_sprite.cpp + gameswf/gameswf_sprite_def.cpp + gameswf/gameswf_stream.cpp + gameswf/gameswf_styles.cpp + gameswf/gameswf_tesselate.cpp + gameswf/gameswf_text.cpp + gameswf/gameswf_tools.cpp + gameswf/gameswf_types.cpp + gameswf/gameswf_value.cpp + gameswf/gameswf_video_impl.cpp + gameswf/gameswf_sound_handler_openal.cpp + gameswf/gameswf_mutex.cpp +) + +if(USE_GLES) + if(NO_MOVIE) + message(FATAL_ERROR "SWF OpenGLES requires FFmpeg support") + endif() + list(APPEND gameswf_SOURCES gameswf/gameswf_render_handler_ogles.cpp) + include_directories(${OPENGLES_INCLUDE_DIR}) +else() + list(APPEND gameswf_SOURCES gameswf/gameswf_render_handler_ogl.cpp) + include_directories(${OPENGL_INCLUDE_DIR}) +endif() + +if(FREETYPE_FOUND) + list(APPEND gameswf_SOURCES gameswf/gameswf_freetype.cpp) + include_directories(${FREETYPE_INCLUDE_DIRS}) +else() + list(APPEND gameswf_SOURCES gameswf/gameswf_fontlib.cpp) +endif() + +add_definitions(${OPENAL_CFLAGS}) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/base ${OPENAL_INCLUDE_DIR}) + +add_library(gameswf STATIC ${base_SOURCES} ${gameswf_SOURCES}) +set_target_properties(gameswf PROPERTIES COMPILE_FLAGS -Wno-deprecated) + +target_link_libraries(gameswf PUBLIC ${OPENGL_LIBRARIES} ${OPENGLES_LIBRARIES} ${JPEG_LIBRARY} ${ZLIB_LIBRARY} ${OPENAL_LIBRARIES} ${FREETYPE_LIBRARIES} ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) +target_include_directories(gameswf PUBLIC ${OPENGL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${FREETYPE_INCLUDE_DIRS}) diff --git a/extlibs/gameswf/gameswf/gameswf_sprite.cpp b/extlibs/gameswf/gameswf/gameswf_sprite.cpp index c3e66fe4b..9ad922dfa 100644 --- a/extlibs/gameswf/gameswf/gameswf_sprite.cpp +++ b/extlibs/gameswf/gameswf/gameswf_sprite.cpp @@ -49,7 +49,7 @@ namespace gameswf m_as_environment.set_target(this); // Initialize the flags for init action executed. - m_init_actions_executed.resize(m_def->get_frame_count(), 0 ); + m_init_actions_executed.resize(m_def->get_frame_count()); m_player->set_alive(this); set_ctor(as_global_movieclip_ctor); diff --git a/extlibs/squirrel/CMakeLists.txt b/extlibs/squirrel/CMakeLists.txt new file mode 100644 index 000000000..0d5be9680 --- /dev/null +++ b/extlibs/squirrel/CMakeLists.txt @@ -0,0 +1,13 @@ +set(INCLUDE_DIRS + "${CMAKE_CURRENT_LIST_DIR}/include" + "${CMAKE_CURRENT_LIST_DIR}/../sqrat/include" + "${CMAKE_CURRENT_LIST_DIR}/../miniz" +) + +file(GLOB_RECURSE squirrel_SOURCES *.cpp *.h) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti -fno-strict-aliasing") + +add_library(squirrel STATIC ${squirrel_SOURCES}) + +target_include_directories(squirrel PUBLIC ${INCLUDE_DIRS}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..dcca4f333 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,170 @@ +include_directories( + ${PROJECT_BINARY_DIR} + ${SFML_INCLUDE_DIR} +) + +set(attract_SOURCES + fe_base.cpp + fe_base.hpp + fe_cmdline.cpp + fe_util.cpp + fe_util.hpp + fe_util_sq.cpp + fe_util_sq.hpp + fe_info.cpp + fe_info.hpp + fe_input.cpp + fe_input.hpp + fe_romlist.cpp + fe_romlist.hpp + scraper_general.cpp + scraper_net.cpp + scraper_xml.cpp + scraper_xml.hpp + fe_settings.cpp + fe_settings.hpp + fe_config.cpp + fe_config.hpp + fe_presentable.cpp + fe_presentable.hpp + fe_present.cpp + fe_present.hpp + sprite.cpp + sprite.hpp + fe_image.cpp + fe_image.hpp + fe_sound.cpp + fe_sound.hpp + fe_shader.cpp + fe_shader.hpp + fe_overlay.cpp + fe_overlay.hpp + fe_window.cpp + fe_window.hpp + tp.cpp + tp.hpp + fe_text.cpp + fe_text.hpp + fe_listbox.cpp + fe_listbox.hpp + fe_vm.cpp + fe_vm.hpp + zip.cpp + zip.hpp + main.cpp +) + +#### BEGIN: Required + +set(attract_LIBS squirrel) + +# SFML +set(sfmlcomponents graphics window system network) +if(NO_NET) + list(REMOVE_ITEM sfmlcomponents network) +endif() +if(NO_MOVIE) + list(APPEND sfmlcomponents audio) +endif() +if(WIN32) + # Flags are set by MXE cmake toolchain + if(LIBTYPE_STATIC OR NOT BUILD_SHARED_LIBS) + set(SFML_STATIC_LIBRARIES TRUE) + endif() + if(${CMAKE_BUILD_TYPE} STREQUAL "Release") + list(APPEND sfmlcomponents main) + endif() +endif() +find_package(SFML 2 COMPONENTS ${sfmlcomponents} REQUIRED) + +if(SFML_STATIC_LIBRARIES) + list(APPEND attract_LIBS ${SFML_LIBRARIES} ${SFML_DEPENDENCIES}) +else() + list(APPEND attract_LIBS ${SFML_LIBRARIES}) +endif() + +#### END: Required + +#### BEGIN: Features + +# System FontConfig, Expat or included Expat? +if(USE_FONTCONFIG) + list(APPEND attract_LIBS ${FONTCONFIG_LIBRARIES}) + include_directories(${FONTCONFIG_INCLUDE_DIR}) +endif() + +if(EXPAT_FOUND) + list(APPEND attract_LIBS ${EXPAT_LIBRARIES}) + include_directories(${EXPAT_INCLUDE_DIR}) +else() + list(APPEND attract_LIBS expat) +endif() + +# FFMPEG support +if(NOT NO_MOVIE) + if(FFMPEG_SWRESAMPLE_FOUND) + add_definitions(-DUSE_SWRESAMPLE) + elseif(FFMPEG_AVRESAMPLE_FOUND) + add_definitions(-DUSE_AVRESAMPLE) + endif() + list(APPEND attract_SOURCES media.hpp media.cpp) + include_directories(${FFMPEG_INCLUDE_DIRS}) + if(WIN32) + list(APPEND attract_LIBS audiolib ${FFMPEG_STATIC_LIBRARIES}) + else() + list(APPEND attract_LIBS audiolib ${FFMPEG_LIBRARIES}) + endif() + set_source_files_properties(media.cpp PROPERTIES COMPILE_FLAGS -D__STDC_CONSTANT_MACROS) +endif() + +# Network support +if (NOT NO_NET) + list(APPEND attract_SOURCES fe_net.cpp fe_net.hpp) +endif() + +# SWF support +if(NOT NO_SWF) + list(APPEND attract_SOURCES swf.cpp swf.hpp) + list(APPEND attract_LIBS gameswf) + set_source_files_properties(swf.cpp PROPERTIES COMPILE_FLAGS -Wno-deprecated) +endif() + +# LibArchive support +if(USE_LIBARCHIVE) + list(APPEND attract_LIBS ${LibArchive_LIBRARIES}) + include_directories(${LibArchive_INCLUDE_DIRS}) +else() + include_directories(${CMAKE_SOURCE_DIR}/extlibs/miniz) +endif() + +# Xinerama support +if(USE_XINERAMA) + list(APPEND attract_LIBS ${XINERAMA_LIBRARIES} X11) + include_directories(${XINERAMA_INCLUDE_DIRS}) +endif() + +#### END: Features #### + +#### BEGIN: Platforms #### + +if(APPLE) + list(APPEND attract_SOURCES fe_util_osx.mm fe_util_osx.hpp) + set_source_files_properties(fe_util_osx.mm PROPERTIES LANGUAGE C) + find_library(COCOA_LIBRARY Cocoa REQUIRED) + list(APPEND attract_LIBS ${COCOA_LIBRARY}) +endif() + +if(WIN32) + enable_language(RC) + list(APPEND attract_SOURCES attract.rc) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mconsole") + set(CMAKE_EXE_LINKER_FLAGS "-static") +endif() + +#### END: Platforms #### + +add_executable(attract ${attract_SOURCES}) +target_link_libraries(attract ${attract_LIBS}) + +install(TARGETS attract + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/attract.rc b/src/attract.rc index df6ddf334..d5561d332 100644 --- a/src/attract.rc +++ b/src/attract.rc @@ -1,3 +1,5 @@ +#include "config.h" + #define STRINGIZE_HELPER(...) #__VA_ARGS__ #define STRINGIZE(x) STRINGIZE_HELPER(x) diff --git a/src/fe_base.cpp b/src/fe_base.cpp index cf3db3551..547614a19 100644 --- a/src/fe_base.cpp +++ b/src/fe_base.cpp @@ -24,8 +24,7 @@ #include "fe_util.hpp" #include #include - -#define FE_NAME_D "Attract-Mode" +#include "config.h" const char *FE_NAME = FE_NAME_D; const char *FE_COPYRIGHT = FE_NAME_D " " FE_VERSION_D \ diff --git a/src/fe_cmdline.cpp b/src/fe_cmdline.cpp index 36397d168..63721c0a0 100644 --- a/src/fe_cmdline.cpp +++ b/src/fe_cmdline.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_settings.hpp" #include "fe_util.hpp" #include diff --git a/src/fe_config.cpp b/src/fe_config.cpp index 519d5f4e2..ef1cfbe92 100644 --- a/src/fe_config.cpp +++ b/src/fe_config.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_config.hpp" #include "fe_info.hpp" #include "fe_settings.hpp" diff --git a/src/fe_image.cpp b/src/fe_image.cpp index 4d1424435..2c85cb781 100644 --- a/src/fe_image.cpp +++ b/src/fe_image.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_image.hpp" #include "fe_util.hpp" #include "fe_settings.hpp" diff --git a/src/fe_info.cpp b/src/fe_info.cpp index 840c023ab..1c1f3bee8 100644 --- a/src/fe_info.cpp +++ b/src/fe_info.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_info.hpp" #include "fe_util.hpp" #include diff --git a/src/fe_overlay.cpp b/src/fe_overlay.cpp index 69bbbb19a..5501162d0 100644 --- a/src/fe_overlay.cpp +++ b/src/fe_overlay.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_overlay.hpp" #include "fe_settings.hpp" #include "fe_config.hpp" diff --git a/src/fe_present.cpp b/src/fe_present.cpp index d0cc777d6..94cbccda4 100644 --- a/src/fe_present.cpp +++ b/src/fe_present.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_present.hpp" #include "fe_util.hpp" #include "fe_image.hpp" diff --git a/src/fe_settings.cpp b/src/fe_settings.cpp index 925b17e1f..d3730ecda 100644 --- a/src/fe_settings.cpp +++ b/src/fe_settings.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_settings.hpp" #include "fe_util.hpp" #include "zip.hpp" @@ -35,7 +36,7 @@ #include #ifdef USE_FONTCONFIG -#include +#include #endif #ifndef NO_MOVIE @@ -96,12 +97,7 @@ const char *FE_FONT_EXTENSIONS[] = NULL }; -#ifdef DATA_PATH const char *FE_DATA_PATH = DATA_PATH; -#else -const char *FE_DATA_PATH = NULL; -#endif - const char *FE_CFG_FILE = "attract.cfg"; const char *FE_STATE_FILE = "attract.am"; const char *FE_SCREENSAVER_FILE = "screensaver.nut"; diff --git a/src/fe_shader.cpp b/src/fe_shader.cpp index da7691de9..2972bd16f 100644 --- a/src/fe_shader.cpp +++ b/src/fe_shader.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_shader.hpp" #include "fe_presentable.hpp" #include "fe_image.hpp" diff --git a/src/fe_sound.cpp b/src/fe_sound.cpp index fb07fcdc1..483cc4239 100644 --- a/src/fe_sound.cpp +++ b/src/fe_sound.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_sound.hpp" #include "fe_settings.hpp" #include "fe_present.hpp" diff --git a/src/fe_util.cpp b/src/fe_util.cpp index 6c2b2b47a..ade8e8aae 100644 --- a/src/fe_util.cpp +++ b/src/fe_util.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_util.hpp" #include "fe_base.hpp" #include "fe_input.hpp" diff --git a/src/fe_vm.cpp b/src/fe_vm.cpp index d7da6acd3..a69be8b55 100644 --- a/src/fe_vm.cpp +++ b/src/fe_vm.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_vm.hpp" #include "fe_settings.hpp" #include "fe_present.hpp" @@ -485,11 +486,7 @@ bool FeVM::on_new_layout() .Const( _SC("OS"), get_OS_string() ) .Const( _SC("ShadersAvailable"), sf::Shader::isAvailable() ) .Const( _SC("FeConfigDirectory"), m_feSettings->get_config_dir().c_str() ) -#ifdef DATA_PATH .Const( _SC("FeDataDirectory"), DATA_PATH ) -#else - .Const( _SC("FeDataDirectory"), "" ) -#endif .Enum( _SC("Style"), Enumeration() .Const( _SC("Regular"), sf::Text::Regular ) diff --git a/src/fe_window.cpp b/src/fe_window.cpp index 74cfea0e2..4d107fa60 100644 --- a/src/fe_window.cpp +++ b/src/fe_window.cpp @@ -20,7 +20,7 @@ * */ - +#include "config.h" #include "fe_window.hpp" #include "fe_settings.hpp" #include "fe_util.hpp" diff --git a/src/main.cpp b/src/main.cpp index 066963b88..89644fa09 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "fe_settings.hpp" #include "fe_present.hpp" #include "fe_overlay.hpp" diff --git a/src/media.cpp b/src/media.cpp index 748ccdc1a..543f25d70 100644 --- a/src/media.cpp +++ b/src/media.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "media.hpp" #include "zip.hpp" #include diff --git a/src/swf.cpp b/src/swf.cpp index 77371a9c1..63b0ec4b7 100644 --- a/src/swf.cpp +++ b/src/swf.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "swf.hpp" #include "zip.hpp" diff --git a/src/tp.cpp b/src/tp.cpp index df56be506..deea4a5d5 100644 --- a/src/tp.cpp +++ b/src/tp.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "tp.hpp" #include diff --git a/src/zip.cpp b/src/zip.cpp index d871e0350..8b2e3c665 100644 --- a/src/zip.cpp +++ b/src/zip.cpp @@ -20,6 +20,7 @@ * */ +#include "config.h" #include "zip.hpp" #include "fe_util.hpp" #include