Skip to content

Commit

Permalink
[sfml] Support Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Apr 30, 2018
1 parent 286c400 commit 827c893
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 135 deletions.
2 changes: 1 addition & 1 deletion ports/freeglut/CONTROL
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Source: freeglut
Version: 3.0.0-3
Version: 3.0.0-4
Description: Open source implementation of GLUT with source and binary backwards compatibility.
12 changes: 9 additions & 3 deletions ports/freeglut/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ vcpkg_download_distfile(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
file(READ ${SOURCE_PATH}/CMakeLists.txt FREEGLUT_CMAKELISTS)
string(REPLACE "SET( CMAKE_DEBUG_POSTFIX \"d\" )"
Expand Down Expand Up @@ -41,9 +45,11 @@ string(REPLACE "pragma comment (lib, \"freeglutd.lib\")"
file(WRITE ${CURRENT_PACKAGES_DIR}/include/GL/freeglut_std.h "${FREEGLUT_STDH}")

# Rename static lib (otherwise it's incompatible with FindGLUT.cmake)
if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
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)
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
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()

# Clean
Expand Down
30 changes: 19 additions & 11 deletions ports/libflac/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,22 @@ if(NOT DEFINED LIBFLAC_ARCHITECTURE)
message(FATAL_ERROR "Target architecture not specified")
endif()

file(GLOB LIBFLAC_SOURCES
${PROJECT_SOURCE_DIR}/src/libFLAC/*.c
${PROJECT_SOURCE_DIR}/src/share/win_utf8_io/win_utf8_io.c)
file(GLOB LIBFLAC_SOURCES src/libFLAC/*.c)

file(GLOB LIBFLACXX_SOURCES
${PROJECT_SOURCE_DIR}/src/libFLAC++/*.cpp)
if(WIN32)
list(APPEND LIBFLAC_SOURCES src/share/win_utf8_io/win_utf8_io.c)
else()
list(FILTER LIBFLAC_SOURCES EXCLUDE REGEX "windows[^/]*$")

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/config.h "#include <inttypes.h>")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DHAVE_CONFIG_H)
endif()

file(GLOB LIBFLACXX_SOURCES src/libFLAC++/*.cpp)

include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/src/libFLAC/include)
include_directories(include)
include_directories(src/libFLAC/include)

if(NOT LIBFLAC_ARCHITECTURE MATCHES arm)
add_definitions(-DFLAC__SSE_OS)
Expand Down Expand Up @@ -44,14 +51,15 @@ endif()
add_definitions(-DPACKAGE_VERSION="1.3.2")
add_definitions(-DFLAC__HAS_OGG)
add_definitions(-DFLAC__ALIGN_MALLOC_DATA) # 32 byte boundary
add_definitions(-DHAVE_LROUND)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS)

add_library(libFLAC ${LIBFLAC_SOURCES})
add_library(libFLACXX ${LIBFLACXX_SOURCES})

set_target_properties(libFLAC PROPERTIES OUTPUT_NAME flac)
set_target_properties(libFLACXX PROPERTIES OUTPUT_NAME flac++)
set_target_properties(libFLAC PROPERTIES OUTPUT_NAME FLAC)
set_target_properties(libFLACXX PROPERTIES OUTPUT_NAME FLAC++)

find_library(OGG_LIBRARY ogg)
find_path(OGG_INCLUDE_DIR ogg/ogg.h)
Expand All @@ -73,10 +81,10 @@ install(TARGETS libFLAC libFLACXX
LIBRARY DESTINATION lib)

if(NOT DEFINED LIBFLAC_SKIP_HEADERS)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/FLAC/
install(DIRECTORY include/FLAC/
DESTINATION include/FLAC
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/FLAC++/
install(DIRECTORY include/FLAC++/
DESTINATION include/FLAC++
FILES_MATCHING PATTERN "*.h")
endif()
2 changes: 1 addition & 1 deletion ports/libflac/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: libflac
Version: 1.3.2-4
Version: 1.3.2-5
Description: Library for manipulating FLAC files
Build-Depends: libogg
2 changes: 1 addition & 1 deletion ports/openal-soft/CONTROL
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
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.
16 changes: 12 additions & 4 deletions ports/openal-soft/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ else()
set(OPENAL_LIBTYPE "STATIC")
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(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
Expand All @@ -36,7 +44,7 @@ vcpkg_configure_cmake(
-DALSOFT_CONFIG=OFF
-DALSOFT_HRTF_DEFS=OFF
-DALSOFT_AMBDEC_PRESETS=OFF
-DALSOFT_BACKEND_ALSA=OFF
-DALSOFT_BACKEND_ALSA=${ALSOFT_REQUIRE_LINUX}
-DALSOFT_BACKEND_OSS=OFF
-DALSOFT_BACKEND_SOLARIS=OFF
-DALSOFT_BACKEND_SNDIO=OFF
Expand All @@ -47,9 +55,9 @@ vcpkg_configure_cmake(
-DALSOFT_BACKEND_JACK=OFF
-DALSOFT_BACKEND_OPENSL=OFF
-DALSOFT_BACKEND_WAVE=ON
-DALSOFT_REQUIRE_WINMM=ON
-DALSOFT_REQUIRE_DSOUND=ON
-DALSOFT_REQUIRE_MMDEVAPI=ON
-DALSOFT_REQUIRE_WINMM=${ALSOFT_REQUIRE_WINDOWS}
-DALSOFT_REQUIRE_DSOUND=${ALSOFT_REQUIRE_WINDOWS}
-DALSOFT_REQUIRE_MMDEVAPI=${ALSOFT_REQUIRE_WINDOWS}
)

vcpkg_install_cmake()
Expand Down
115 changes: 14 additions & 101 deletions ports/sfml/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 2.6)
project(SFML)

include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_SOURCE_DIR}/src)
include_directories(include)
include_directories(src)

if(NOT BUILD_SHARED_LIBS)
add_definitions(-DSFML_STATIC)
Expand All @@ -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

set(VERSION_MAJOR 2)
set(SFML_OS_WINDOWS ON)
include(cmake/Config.cmake)
set(SFML_GENERATE_PDB ON)
include(cmake/macros.cmake)
include(cmake/Macros.cmake)
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
${PROJECT_SOURCE_DIR}/src/SFML/System/*.cpp
${PROJECT_SOURCE_DIR}/src/SFML/System/Win32/*cpp)

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})
if(WIN32)
set(LIB_SUFFIX /manual-link)
add_subdirectory(src/SFML/Main)
unset(LIB_SUFFIX)
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)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ DESTINATION include)
install(DIRECTORY include/ DESTINATION include)
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})
4 changes: 2 additions & 2 deletions ports/sfml/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: sfml
Version: 2.4.2-2
Version: 2.4.2-3
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)
29 changes: 18 additions & 11 deletions ports/sfml/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@

include(vcpkg_common_functions)
vcpkg_from_github(OUT_SOURCE_PATH SOURCE_PATH
REPO "sfml/sfml"
REF "2.4.2"
REPO SFML/SFML
REF 2.4.2
HEAD_REF master
SHA512 8acfdf320939c953a9a3413398f82d02d68a56a337f1366c2677c14ce032baa8ba059113ac3c91bb6e6fc22eef119369a265be7ef6894526e6a97a01f37e1972)

SHA512 8acfdf320939c953a9a3413398f82d02d68a56a337f1366c2677c14ce032baa8ba059113ac3c91bb6e6fc22eef119369a265be7ef6894526e6a97a01f37e1972
)

file(REMOVE_RECURSE ${SOURCE_PATH}/extlibs)
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(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS_DEBUG
-DSFML_SKIP_HEADERS=ON)
OPTIONS_DEBUG
-DSFML_SKIP_HEADERS=ON
)

vcpkg_install_cmake()
vcpkg_copy_pdbs()
Expand All @@ -24,13 +29,15 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
endif()

# move sfml-main to manual link dir
file(COPY ${CURRENT_PACKAGES_DIR}/lib/sfml-main.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib/manual-link)
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/sfml-main.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)
if(EXISTS ${CURRENT_PACKAGES_DIR}/lib/sfml-main.lib)
file(COPY ${CURRENT_PACKAGES_DIR}/lib/sfml-main.lib DESTINATION ${CURRENT_PACKAGES_DIR}/lib/manual-link)
file(REMOVE ${CURRENT_PACKAGES_DIR}/lib/sfml-main.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
if (VCPKG_HEAD_VERSION)
if(VCPKG_HEAD_VERSION)
file(INSTALL ${SOURCE_PATH}/license.md DESTINATION ${CURRENT_PACKAGES_DIR}/share/sfml RENAME copyright)
else()
file(INSTALL ${SOURCE_PATH}/license.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/sfml RENAME copyright)
Expand Down

0 comments on commit 827c893

Please sign in to comment.