[sfml] Support Linux

This commit is contained in:
Robert Schumacher 2018-04-27 03:15:17 -07:00
parent 286c400417
commit 827c893b8e
9 changed files with 77 additions and 135 deletions

View File

@ -1,3 +1,3 @@
Source: freeglut Source: freeglut
Version: 3.0.0-3 Version: 3.0.0-4
Description: Open source implementation of GLUT with source and binary backwards compatibility. Description: Open source implementation of GLUT with source and binary backwards compatibility.

View File

@ -7,6 +7,10 @@ vcpkg_download_distfile(ARCHIVE
) )
vcpkg_extract_source_archive(${ARCHIVE}) vcpkg_extract_source_archive(${ARCHIVE})
if(VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
message("Freeglut currently requires the following libraries from the system package manager:\n opengl\n glu\n libx11\n\nThese can be installed on Ubuntu systems via apt-get install libxi-dev libgl1-mesa-dev libglu1-mesa-dev mesa-common-dev")
endif()
# disable debug suffix, because FindGLUT.cmake from CMake 3.8 doesn't support it # disable debug suffix, because FindGLUT.cmake from CMake 3.8 doesn't support it
file(READ ${SOURCE_PATH}/CMakeLists.txt FREEGLUT_CMAKELISTS) file(READ ${SOURCE_PATH}/CMakeLists.txt FREEGLUT_CMAKELISTS)
string(REPLACE "SET( CMAKE_DEBUG_POSTFIX \"d\" )" string(REPLACE "SET( CMAKE_DEBUG_POSTFIX \"d\" )"
@ -41,9 +45,11 @@ string(REPLACE "pragma comment (lib, \"freeglutd.lib\")"
file(WRITE ${CURRENT_PACKAGES_DIR}/include/GL/freeglut_std.h "${FREEGLUT_STDH}") file(WRITE ${CURRENT_PACKAGES_DIR}/include/GL/freeglut_std.h "${FREEGLUT_STDH}")
# Rename static lib (otherwise it's incompatible with FindGLUT.cmake) # Rename static lib (otherwise it's incompatible with FindGLUT.cmake)
if (VCPKG_LIBRARY_LINKAGE STREQUAL static) if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
file(RENAME ${CURRENT_PACKAGES_DIR}/lib/freeglut_static.lib ${CURRENT_PACKAGES_DIR}/lib/freeglut.lib) if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/freeglut_static.lib ${CURRENT_PACKAGES_DIR}/debug/lib/freeglut.lib) file(RENAME ${CURRENT_PACKAGES_DIR}/lib/freeglut_static.lib ${CURRENT_PACKAGES_DIR}/lib/freeglut.lib)
file(RENAME ${CURRENT_PACKAGES_DIR}/debug/lib/freeglut_static.lib ${CURRENT_PACKAGES_DIR}/debug/lib/freeglut.lib)
endif()
endif() endif()
# Clean # Clean

View File

@ -7,15 +7,22 @@ if(NOT DEFINED LIBFLAC_ARCHITECTURE)
message(FATAL_ERROR "Target architecture not specified") message(FATAL_ERROR "Target architecture not specified")
endif() endif()
file(GLOB LIBFLAC_SOURCES file(GLOB LIBFLAC_SOURCES src/libFLAC/*.c)
${PROJECT_SOURCE_DIR}/src/libFLAC/*.c
${PROJECT_SOURCE_DIR}/src/share/win_utf8_io/win_utf8_io.c)
file(GLOB LIBFLACXX_SOURCES if(WIN32)
${PROJECT_SOURCE_DIR}/src/libFLAC++/*.cpp) list(APPEND LIBFLAC_SOURCES src/share/win_utf8_io/win_utf8_io.c)
else()
list(FILTER LIBFLAC_SOURCES EXCLUDE REGEX "windows[^/]*$")
include_directories(${PROJECT_SOURCE_DIR}/include) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/config.h "#include <inttypes.h>")
include_directories(${PROJECT_SOURCE_DIR}/src/libFLAC/include) include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DHAVE_CONFIG_H)
endif()
file(GLOB LIBFLACXX_SOURCES src/libFLAC++/*.cpp)
include_directories(include)
include_directories(src/libFLAC/include)
if(NOT LIBFLAC_ARCHITECTURE MATCHES arm) if(NOT LIBFLAC_ARCHITECTURE MATCHES arm)
add_definitions(-DFLAC__SSE_OS) add_definitions(-DFLAC__SSE_OS)
@ -44,14 +51,15 @@ endif()
add_definitions(-DPACKAGE_VERSION="1.3.2") add_definitions(-DPACKAGE_VERSION="1.3.2")
add_definitions(-DFLAC__HAS_OGG) add_definitions(-DFLAC__HAS_OGG)
add_definitions(-DFLAC__ALIGN_MALLOC_DATA) # 32 byte boundary add_definitions(-DFLAC__ALIGN_MALLOC_DATA) # 32 byte boundary
add_definitions(-DHAVE_LROUND)
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)
add_library(libFLAC ${LIBFLAC_SOURCES}) add_library(libFLAC ${LIBFLAC_SOURCES})
add_library(libFLACXX ${LIBFLACXX_SOURCES}) add_library(libFLACXX ${LIBFLACXX_SOURCES})
set_target_properties(libFLAC PROPERTIES OUTPUT_NAME flac) set_target_properties(libFLAC PROPERTIES OUTPUT_NAME FLAC)
set_target_properties(libFLACXX PROPERTIES OUTPUT_NAME flac++) set_target_properties(libFLACXX PROPERTIES OUTPUT_NAME FLAC++)
find_library(OGG_LIBRARY ogg) find_library(OGG_LIBRARY ogg)
find_path(OGG_INCLUDE_DIR ogg/ogg.h) find_path(OGG_INCLUDE_DIR ogg/ogg.h)
@ -73,10 +81,10 @@ install(TARGETS libFLAC libFLACXX
LIBRARY DESTINATION lib) LIBRARY DESTINATION lib)
if(NOT DEFINED LIBFLAC_SKIP_HEADERS) if(NOT DEFINED LIBFLAC_SKIP_HEADERS)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/FLAC/ install(DIRECTORY include/FLAC/
DESTINATION include/FLAC DESTINATION include/FLAC
FILES_MATCHING PATTERN "*.h") FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/FLAC++/ install(DIRECTORY include/FLAC++/
DESTINATION include/FLAC++ DESTINATION include/FLAC++
FILES_MATCHING PATTERN "*.h") FILES_MATCHING PATTERN "*.h")
endif() endif()

View File

@ -1,4 +1,4 @@
Source: libflac Source: libflac
Version: 1.3.2-4 Version: 1.3.2-5
Description: Library for manipulating FLAC files Description: Library for manipulating FLAC files
Build-Depends: libogg Build-Depends: libogg

View File

@ -1,3 +1,3 @@
Source: openal-soft Source: openal-soft
Version: 1.18.2-1 Version: 1.18.2-2
Description: OpenAL Soft is an LGPL-licensed, cross-platform, software implementation of the OpenAL 3D audio API. Description: OpenAL Soft is an LGPL-licensed, cross-platform, software implementation of the OpenAL 3D audio API.

View File

@ -24,6 +24,14 @@ else()
set(OPENAL_LIBTYPE "STATIC") set(OPENAL_LIBTYPE "STATIC")
endif() endif()
if(VCPKG_CMAKE_SYSTEM_NAME)
set(ALSOFT_REQUIRE_WINDOWS OFF)
set(ALSOFT_REQUIRE_LINUX ON)
else()
set(ALSOFT_REQUIRE_WINDOWS ON)
set(ALSOFT_REQUIRE_LINUX OFF)
endif()
vcpkg_configure_cmake( vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH} SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA PREFER_NINJA
@ -36,7 +44,7 @@ vcpkg_configure_cmake(
-DALSOFT_CONFIG=OFF -DALSOFT_CONFIG=OFF
-DALSOFT_HRTF_DEFS=OFF -DALSOFT_HRTF_DEFS=OFF
-DALSOFT_AMBDEC_PRESETS=OFF -DALSOFT_AMBDEC_PRESETS=OFF
-DALSOFT_BACKEND_ALSA=OFF -DALSOFT_BACKEND_ALSA=${ALSOFT_REQUIRE_LINUX}
-DALSOFT_BACKEND_OSS=OFF -DALSOFT_BACKEND_OSS=OFF
-DALSOFT_BACKEND_SOLARIS=OFF -DALSOFT_BACKEND_SOLARIS=OFF
-DALSOFT_BACKEND_SNDIO=OFF -DALSOFT_BACKEND_SNDIO=OFF
@ -47,9 +55,9 @@ vcpkg_configure_cmake(
-DALSOFT_BACKEND_JACK=OFF -DALSOFT_BACKEND_JACK=OFF
-DALSOFT_BACKEND_OPENSL=OFF -DALSOFT_BACKEND_OPENSL=OFF
-DALSOFT_BACKEND_WAVE=ON -DALSOFT_BACKEND_WAVE=ON
-DALSOFT_REQUIRE_WINMM=ON -DALSOFT_REQUIRE_WINMM=${ALSOFT_REQUIRE_WINDOWS}
-DALSOFT_REQUIRE_DSOUND=ON -DALSOFT_REQUIRE_DSOUND=${ALSOFT_REQUIRE_WINDOWS}
-DALSOFT_REQUIRE_MMDEVAPI=ON -DALSOFT_REQUIRE_MMDEVAPI=${ALSOFT_REQUIRE_WINDOWS}
) )
vcpkg_install_cmake() vcpkg_install_cmake()

View File

@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 2.6) cmake_minimum_required(VERSION 2.6)
project(SFML) project(SFML)
include_directories(${PROJECT_SOURCE_DIR}/include) include_directories(include)
include_directories(${PROJECT_SOURCE_DIR}/src) include_directories(src)
if(NOT BUILD_SHARED_LIBS) if(NOT BUILD_SHARED_LIBS)
add_definitions(-DSFML_STATIC) add_definitions(-DSFML_STATIC)
@ -13,110 +13,23 @@ add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
# import SFML's 'sfml_add_library' macro and find_package utils # import SFML's 'sfml_add_library' macro and find_package utils
set(VERSION_MAJOR 2) set(VERSION_MAJOR 2)
set(SFML_OS_WINDOWS ON) include(cmake/Config.cmake)
set(SFML_GENERATE_PDB ON) set(SFML_GENERATE_PDB ON)
include(cmake/macros.cmake) include(cmake/Macros.cmake)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules/) set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules/)
# system module add_subdirectory(src/SFML/System)
add_subdirectory(src/SFML/Window)
add_subdirectory(src/SFML/Network)
add_subdirectory(src/SFML/Audio)
add_subdirectory(src/SFML/Graphics)
file(GLOB SFML_SYSTEM_SOURCES if(WIN32)
${PROJECT_SOURCE_DIR}/src/SFML/System/*.cpp set(LIB_SUFFIX /manual-link)
${PROJECT_SOURCE_DIR}/src/SFML/System/Win32/*cpp) add_subdirectory(src/SFML/Main)
unset(LIB_SUFFIX)
sfml_add_library(sfml-system
SOURCES ${SFML_SYSTEM_SOURCES}
EXTERNAL_LIBS winmm)
# window module
file(GLOB SFML_WINDOW_SOURCES
${PROJECT_SOURCE_DIR}/src/SFML/Window/*.cpp
${PROJECT_SOURCE_DIR}/src/SFML/Window/Win32/*cpp)
list(REMOVE_ITEM SFML_WINDOW_SOURCES
${PROJECT_SOURCE_DIR}/src/SFML/Window/EGLCheck.cpp
${PROJECT_SOURCE_DIR}/src/SFML/Window/EglContext.cpp)
sfml_add_library(sfml-window
SOURCES ${SFML_WINDOW_SOURCES}
DEPENDS sfml-system
EXTERNAL_LIBS winmm gdi32 opengl32)
# network module
file(GLOB SFML_NETWORK_SOURCES
${PROJECT_SOURCE_DIR}/src/SFML/Network/*.cpp
${PROJECT_SOURCE_DIR}/src/SFML/Network/Win32/*cpp)
sfml_add_library(sfml-network
SOURCES ${SFML_NETWORK_SOURCES}
DEPENDS sfml-system
EXTERNAL_LIBS ws2_32)
# audio module
file(GLOB SFML_AUDIO_SOURCES
${PROJECT_SOURCE_DIR}/src/SFML/Audio/*.cpp)
find_package(OpenAL REQUIRED)
find_package(Vorbis REQUIRED)
find_package(FLAC REQUIRED)
sfml_add_library(sfml-audio
SOURCES ${SFML_AUDIO_SOURCES}
DEPENDS sfml-system
EXTERNAL_LIBS ${OPENAL_LIBRARY} ${VORBIS_LIBRARIES} ${FLAC_LIBRARY})
target_include_directories(sfml-audio SYSTEM PRIVATE ${OPENAL_INCLUDE_DIR})
target_include_directories(sfml-audio SYSTEM PRIVATE ${VORBIS_INCLUDE_DIRS})
target_include_directories(sfml-audio SYSTEM PRIVATE ${FLAC_INCLUDE_DIR})
# graphics module
file(GLOB SFML_GRAPHICS_SOURCES
${PROJECT_SOURCE_DIR}/src/SFML/Graphics/*.cpp)
find_package(JPEG REQUIRED)
find_package(Freetype REQUIRED) # fails to find debug lib
if(CMAKE_BUILD_TYPE MATCHES Debug)
find_library(FREETYPE_DEBUG_LIBRARY freetyped)
set(FREETYPE_ACTUAL_LIBRARY ${FREETYPE_DEBUG_LIBRARY})
else()
set(FREETYPE_ACTUAL_LIBRARY ${FREETYPE_LIBRARY})
endif() endif()
find_path(STB_HEADERS stb_image.h)
sfml_add_library(sfml-graphics
SOURCES ${SFML_GRAPHICS_SOURCES}
DEPENDS sfml-system sfml-window
EXTERNAL_LIBS ${FREETYPE_ACTUAL_LIBRARY} ${JPEG_LIBRARY} opengl32)
target_include_directories(sfml-graphics SYSTEM PRIVATE ${STB_HEADERS})
target_include_directories(sfml-graphics SYSTEM PRIVATE ${FREETYPE_INCLUDE_DIRS})
target_include_directories(sfml-graphics SYSTEM PRIVATE ${JPEG_INCLUDE_DIR})
set_target_properties(sfml-graphics PROPERTIES COMPILE_FLAGS -DSTBI_FAILURE_USERMSG)
# main module
add_library(sfml-main STATIC ${PROJECT_SOURCE_DIR}/src/SFML/Main/MainWin32.cpp)
set_target_properties(sfml-main PROPERTIES DEBUG_POSTFIX -d)
install(TARGETS sfml-main ARCHIVE DESTINATION lib)
# headers
if(NOT DEFINED SFML_SKIP_HEADERS) if(NOT DEFINED SFML_SKIP_HEADERS)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include) install(DIRECTORY include/ DESTINATION include)
endif() endif()
# log linked libraries
message(STATUS "Link-time dependencies:")
message(STATUS " " ${VORBIS_LIBRARY})
message(STATUS " " ${VORBISFILE_LIBRARY})
message(STATUS " " ${VORBISENC_LIBRARY})
message(STATUS " " ${OGG_LIBRARY})
message(STATUS " " ${OPENAL_LIBRARY})
message(STATUS " " ${FLAC_LIBRARY})
message(STATUS " " ${FREETYPE_ACTUAL_LIBRARY})
message(STATUS " " ${JPEG_LIBRARY})

View File

@ -1,4 +1,4 @@
Source: sfml Source: sfml
Version: 2.4.2-2 Version: 2.4.2-3
Description: Simple and fast multimedia library Description: Simple and fast multimedia library
Build-Depends: freetype, libflac, libjpeg-turbo, libogg, libvorbis, openal-soft, stb Build-Depends: freetype, libflac, libjpeg-turbo, libogg, libvorbis, openal-soft, stb, freeglut (!uwp&&!windows)

View File

@ -1,19 +1,24 @@
include(vcpkg_common_functions) include(vcpkg_common_functions)
vcpkg_from_github(OUT_SOURCE_PATH SOURCE_PATH vcpkg_from_github(OUT_SOURCE_PATH SOURCE_PATH
REPO "sfml/sfml" REPO SFML/SFML
REF "2.4.2" REF 2.4.2
HEAD_REF master HEAD_REF master
SHA512 8acfdf320939c953a9a3413398f82d02d68a56a337f1366c2677c14ce032baa8ba059113ac3c91bb6e6fc22eef119369a265be7ef6894526e6a97a01f37e1972) SHA512 8acfdf320939c953a9a3413398f82d02d68a56a337f1366c2677c14ce032baa8ba059113ac3c91bb6e6fc22eef119369a265be7ef6894526e6a97a01f37e1972
)
file(REMOVE_RECURSE ${SOURCE_PATH}/extlibs) file(REMOVE_RECURSE ${SOURCE_PATH}/extlibs)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
if(VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
message("SFML currently requires the following libraries from the system package manager:\n libudev\n libx11\n libxrandr\n opengl\n\nThese can be installed on Ubuntu systems via apt-get install libx11-dev libxrandr-dev libxi-dev libudev-dev mesa-common-dev")
endif()
vcpkg_configure_cmake( vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH} SOURCE_PATH ${SOURCE_PATH}
OPTIONS_DEBUG OPTIONS_DEBUG
-DSFML_SKIP_HEADERS=ON) -DSFML_SKIP_HEADERS=ON
)
vcpkg_install_cmake() vcpkg_install_cmake()
vcpkg_copy_pdbs() vcpkg_copy_pdbs()
@ -24,13 +29,15 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
endif() endif()
# move sfml-main to manual link dir # move sfml-main to manual link dir
file(COPY ${CURRENT_PACKAGES_DIR}/lib/sfml-main.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib/manual-link) if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/sfml-main.lib)
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/sfml-main.lib) file(COPY ${CURRENT_PACKAGES_DIR}/lib/sfml-main.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib/manual-link)
file(COPY ${CURRENT_PACKAGES_DIR}/debug/lib/sfml-main-d.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link) file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/sfml-main.lib)
file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/lib/sfml-main-d.lib) file(COPY ${CURRENT_PACKAGES_DIR}/debug/lib/sfml-main-d.lib DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib/manual-link)
file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/lib/sfml-main-d.lib)
endif()
# At the time of writing, HEAD has license.md instead of license.txt # At the time of writing, HEAD has license.md instead of license.txt
if (VCPKG_HEAD_VERSION) if(VCPKG_HEAD_VERSION)
file(INSTALL ${SOURCE_PATH}/license.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/sfml RENAME copyright) file(INSTALL ${SOURCE_PATH}/license.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/sfml RENAME copyright)
else() else()
file(INSTALL ${SOURCE_PATH}/license.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/sfml RENAME copyright) file(INSTALL ${SOURCE_PATH}/license.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/sfml RENAME copyright)