Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sfml: Test suport for SFML 3 rc1 #25305

Draft
wants to merge 38 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
17fd413
First sketch towards SFML 3 support
AbrilRBS Sep 16, 2024
488cafa
Get the test running
AbrilRBS Sep 16, 2024
ef2cfcc
graphics
AbrilRBS Sep 17, 2024
0ce76fa
network
AbrilRBS Sep 17, 2024
ed26e50
Missing system requirement
AbrilRBS Sep 17, 2024
a8fa14f
Add missing file
AbrilRBS Sep 17, 2024
d8916b9
Fix android configure()
AbrilRBS Sep 17, 2024
fafc9cb
Fix android name scheme
AbrilRBS Sep 17, 2024
447786a
Try to fix Android lib locations
AbrilRBS Sep 17, 2024
1c60a0f
Typo
AbrilRBS Sep 17, 2024
388f247
Address main always being static
AbrilRBS Sep 17, 2024
c6fb6d1
Audio
AbrilRBS Sep 17, 2024
a76811e
Cleanup
AbrilRBS Sep 17, 2024
e6d1a9a
Use android_abi instead of changing upstream
AbrilRBS Sep 17, 2024
67a53a2
Experimental: Android missing system_libs
AbrilRBS Sep 17, 2024
9fb2cf0
Experimental: Do you even fail?
AbrilRBS Sep 17, 2024
e33bc49
Revert "Experimental: Do you even fail?"
AbrilRBS Sep 17, 2024
874fd36
Experimental: EGL, GLES for Android
AbrilRBS Sep 17, 2024
1fee5cb
Cleanup, usbhid support in FreeBSD
AbrilRBS Sep 17, 2024
8cdb92e
Add missing system requires for audio & network
AbrilRBS Sep 17, 2024
724f347
Component name check
AbrilRBS Sep 17, 2024
bd4ddc0
Remove check_components_exist
AbrilRBS Sep 18, 2024
1999139
Revert unintended flac change
AbrilRBS Sep 18, 2024
d8f6b2a
Cleanup comments
AbrilRBS Sep 18, 2024
d5f4d57
Gcc 7 min
AbrilRBS Sep 18, 2024
2e8de73
Missing version
AbrilRBS Sep 18, 2024
07c0706
Enable examples for easier testing for now, fix macos isssues
AbrilRBS Sep 18, 2024
cb9b513
Disable cocoa example in Macos
AbrilRBS Sep 18, 2024
0137dc2
Gcc 9
AbrilRBS Sep 18, 2024
7963589
Remove test_v1_package from SFML 3
AbrilRBS Sep 23, 2024
6921b7c
Cleanup
AbrilRBS Sep 23, 2024
57f79f2
Merge branch 'master' into ar/smfl3-rc1
AbrilRBS Sep 23, 2024
456839b
Add C++17 to tests
AbrilRBS Sep 24, 2024
4b81904
Back to gcc9
AbrilRBS Sep 24, 2024
4c68d24
Add missing Core framework
AbrilRBS Sep 24, 2024
330faad
Merge branch 'ar/smfl3-rc1' of github.com:AbrilRBS/conan-center-index…
AbrilRBS Sep 24, 2024
1bc7a1d
Cleanup diff
AbrilRBS Oct 14, 2024
4ae0940
ooops
AbrilRBS Oct 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions recipes/sfml/3.x/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
sources:
"3.0.0-rc.1":
url: "https://github.com/SFML/SFML/archive/refs/tags/3.0.0-rc.1.tar.gz"
sha256: "680da7f4398a5766787ea9ca69dd1c9a4871cf3c4834ddfad922425c6f792dc8"
patches:
"3.0.0-rc.1":
- patch_file: "patches/3.0.0-0001-use-zlib-bzip-freetype-conan.patch"
patch_description: "use zlib bzip2 and freetype from conan"
patch_type: "conan"
# TODO: Delete this one when this gets released in a future rc or final version
- patch_file: "patches/3.0.0-0002-windows-arm-build.patch"
patch_description: "fix windows arm build"
patch_type: "backport"

Check warning on line 13 in recipes/sfml/3.x/conandata.yml

View workflow job for this annotation

GitHub Actions / Lint changed files (YAML files)

conandata.yml schema warning

Schema outlined in https://github.com/conan-io/conan-center-index/blob/master/docs/adding_packages/conandata_yml_format.md#patches-fields is not followed. found arbitrary text in patch_type: backport ^ (line: 13)
patch_source: "https://github.com/SFML/SFML/pull/3229"
- patch_file: "patches/3.0.0-0003-conan-choose-osx-deplyment-target.patch"
patch_description: "let conan choose osx deployment target"
patch_type: "conan"
333 changes: 333 additions & 0 deletions recipes/sfml/3.x/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,333 @@
from conan import ConanFile
from conan.errors import ConanInvalidConfiguration
from conan.tools.android import android_abi
from conan.tools.build import check_min_cppstd
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.env import VirtualBuildEnv
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, rmdir, copy, replace_in_file
from conan.tools.microsoft import is_msvc_static_runtime
from conan.tools.scm import Version
import os

required_conan_version = ">=1.53.0"


class SfmlConan(ConanFile):
name = "sfml"
description = "Simple and Fast Multimedia Library."
license = "Zlib"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://www.sfml-dev.org"
topics = ("multimedia", "games", "graphics", "audio")
package_type = "library"
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
# modules
"window": [True, False],
"graphics": [True, False],
"network": [True, False],
"audio": [True, False],
# window module options
"opengl": ["es", "desktop"],
"use_drm": [True, False], # Linux only
# "use_mesa3d": [True, False], # Windows only, not available in CCI

}
default_options = {
"shared": False,
"fPIC": True,
"window": True,
"graphics": True,
"network": True,
"audio": True,
"opengl": "desktop",
"use_drm": False,
# "use_mesa3d": False,
}

# TODO: Fill as needed, can't find an official source,
# going by compilation failures right now
@property
def _min_compiler_versions(self):
return {
"gcc": 9
}

@property
def _min_cppstd(self):
return 17

def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
else:
pass
# TODO: Handle mesa3d
# del self.options.use_mesa3d

# As per CMakeLists.txt#L44, Android is always shared
if self.settings.os == "Android":
del self.options.shared
del self.options.fPIC
self.package_type = "shared-library"

def configure(self):
if self.options.get_safe("shared"):
self.options.rm_safe("fPIC")

if not self.options.window:
del self.options.opengl
del self.options.use_drm
elif self.settings.os != "Linux":
del self.options.use_drm # For Window module but only available on Linux

def layout(self):
cmake_layout(self, src_folder="src")

def requirements(self):
if self.options.window:
if self.settings.os in ["Linux", "FreeBSD"]:
if self.options.get_safe("use_drm"):
self.requires("libdrm/2.4.120")
# TODO, for now this branch is validate()ed out
# self.requires("libgbm/20.3.0") # Missing in CCI?
else:
self.requires("xorg/system")
if self.settings.os == "Linux":
self.requires("libudev/system")

if self.settings.os not in ("iOS", "Android"): # Handled as a framework
self.requires("opengl/system")

if self.options.graphics:
if self.settings.os == "Android" or self.settings.os == "iOS":
self.requires("zlib/[>=1.2.11 <2]")
if self.settings.os == "iOS":
self.requires("bzip2/1.0.8")
self.requires("freetype/2.13.2")

if self.options.audio:
self.requires("vorbis/1.3.7")
self.requires("flac/1.4.3")

def build_requirements(self):
self.tool_requires("cmake/[>=3.24 <4]")

def validate(self):
if self.settings.compiler.cppstd:
check_min_cppstd(self, self._min_cppstd)

compiler_version = self._min_compiler_versions.get(str(self.settings.compiler))
if compiler_version and (Version(self.settings.compiler.version) < compiler_version):
raise ConanInvalidConfiguration(f"{self.name} requires C++{self._min_cppstd} with {self.settings.compiler} {compiler_version} or newer")

if self.options.graphics and not self.options.window:
raise ConanInvalidConfiguration(f"-o={self.ref}:graphics=True requires -o={self.ref}:window=True")

if self.options.get_safe("shared") and is_msvc_static_runtime(self):
raise ConanInvalidConfiguration(f"{self.ref} does not support shared libraries with static runtime")

if self.settings.os not in ["Windows", "Linux", "FreeBSD", "Android", "Macos", "iOS"]:
raise ConanInvalidConfiguration(f"{self.ref} not supported on {self.settings.os}")

# TODO: Mesa support, or another way to get gbm
if self.options.get_safe("use_drm"):
raise ConanInvalidConfiguration(f"{self.ref} does not support -o=use_drm=True, contributions are welcome")

def validate_build(self):
if self.settings.os == "Macos" and self.settings.compiler != "apple-clang":
raise ConanInvalidConfiguration(f"{self.ref} is not supported on {self.settings.os} with {self.settings.compiler}")

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
venv = VirtualBuildEnv(self)
venv.generate()
tc = CMakeToolchain(self)

tc.variables["SFML_BUILD_WINDOW"] = self.options.window
tc.variables["SFML_BUILD_GRAPHICS"] = self.options.graphics
tc.variables["SFML_BUILD_NETWORK"] = self.options.network
tc.variables["SFML_BUILD_AUDIO"] = self.options.audio

if self.options.window:
tc.variables["SFML_OPENGL_ES"] = True if self.options.opengl == "es" else False

if self.settings.os == "Linux":
tc.variables["SFML_USE_DRM"] = self.options.use_drm

tc.variables["SFML_GENERATE_PDB"] = False # PDBs not allowed in CCI

if self.settings.os == "Windows":
tc.cache_variables["SFML_USE_STATIC_STD_LIBS"] = is_msvc_static_runtime(self)

tc.cache_variables["SFML_USE_SYSTEM_DEPS"] = True

if self.settings.os == "Windows":
tc.cache_variables["SFML_USE_MESA3D"] = False # self.options.use_mesa3d

tc.variables["SFML_INSTALL_PKGCONFIG_FILES"] = False
tc.cache_variables["SFML_WARNINGS_AS_ERRORS"] = False

# Tip: You can use this locally to test the extras when adding a new version,
# uncomment both to build examples, or run them manually
# tc.variables["SFML_CONFIGURE_EXTRAS"] = True
# tc.variables["SFML_BUILD_EXAMPLES"] = True

# TODO: Remove in Conan 2
if not self.settings.compiler.cppstd:
tc.cache_variables["CMAKE_CXX_STANDARD"] = self._min_cppstd

tc.generate()
deps = CMakeDeps(self)
deps.set_property("flac", "cmake_file_name", "FLAC")
deps.generate()

def _patch_sources(self):
apply_conandata_patches(self)
# Remove cocoa example - xcode needed
# TODO: Remove once we no longer build examples
replace_in_file(self, os.path.join(self.source_folder, "examples", "CMakeLists.txt"),
"add_subdirectory(cocoa)", "")

def build(self):
self._patch_sources()
cmake = CMake(self)
cmake.configure()
cmake.build()

def package(self):
copy(self, "license.md", self.source_folder, os.path.join(self.package_folder, "licenses"))
cmake = CMake(self)
cmake.install()

rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
rmdir(self, os.path.join(self.package_folder, "share"))

def _default_module(self, name):
self.cpp_info.components[name].set_property("cmake_target_name", f"SFML::{name.capitalize()}")

libname = f"sfml-{name}"
# main is always static as per SFML/Main/CMakeLists.txt#L16 STATIC definition
if name != "main" and (self.options.get_safe("shared") or self.settings.os == "Android"):
if self.settings.build_type == "Debug":
libname += "-d"
if self.settings.os == "Windows":
# TODO: Windows shared does set_target_properties(${target} PROPERTIES SUFFIX "-${PROJECT_VERSION_MAJOR}${CMAKE_SHARED_LIBRARY_SUFFIX}")
# Should we handle it here? It compiles either way
pass
else:
libname += "-s"
self.cpp_info.components[name].defines = ["SFML_STATIC"]
if self.settings.build_type == "Debug":
libname += "-d"
self.cpp_info.components[name].libs = [libname]

# CMakeLists.txt#L87 - Android libs are in lib/<CMAKE_ANDROID_ARCH_ABI>
if self.settings.os == "Android":
self.cpp_info.components[name].libdirs = [os.path.join("lib", android_abi(self))]

def package_info(self):
self.cpp_info.set_property("cmake_file_name", "SFML")
self.cpp_info.set_property("pkg_config_name", "sfml-all")

# if self.options.get_safe("opengl") == "desktop":
# -DSFML_OPENGL_ES
# -DGL_GLEXT_PROTOTYPES

# TODO: libatomic when gcc for graphics and audio, but only if not available?
# code says: (e.g. Raspberry Pi 3 armhf), GCC requires linking libatomic to use <atomic> features

modules = ["system"]
if self.settings.os in ["Windows", "iOS", "Android"]:
modules.append("main")

modules.extend(module for module in ["window", "graphics", "network", "audio"] if self.options.get_safe(module))

for module in modules:
self._default_module(module)
if hasattr(self, f"_{module}_module"):
getattr(self, f"_{module}_module")()

# TODO: to remove in conan v2 once cmake_find_package* & pkg_config generators removed
self.cpp_info.names["cmake_find_package"] = "SFML"
self.cpp_info.names["cmake_find_package_multi"] = "SFML"
self.cpp_info.names["pkgconfig"] = "sfml-all"

def _system_module(self):
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["system"].system_libs = ["pthread", "rt"]
elif self.settings.os == "Windows":
self.cpp_info.components["system"].system_libs = ["winmm"]
elif self.settings.os == "Android":
self.cpp_info.components["system"].system_libs = ["log", "android"]

def _window_module(self):
if self.options.window:
self.cpp_info.components["window"].requires = ["system"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.components["window"].system_libs.append("dl")
if self.options.get_safe("use_drm"):
self.cpp_info.components["window"].requires.append("libdrm::libdrm")
# TODO
# self.cpp_info.components["window"].requires.append("libgbm::libgbm")
else:
self.cpp_info.components["window"].requires.extend(["xorg::x11", "xorg::xrandr", "xorg::xcursor", "xorg::xi"])

if self.settings.os == "iOS":
self.cpp_info.components["window"].frameworks = ["OpenGLES"]
elif self.settings.os == "Android":
self.cpp_info.components["window"].system_libs.extend(["egl", "GLESv2"])
else:
self.cpp_info.components["window"].requires.append("opengl::opengl")

if self.settings.os == "Linux":
self.cpp_info.components["window"].requires.append("libudev::libudev")
elif self.settings.os == "Windows":
self.cpp_info.components["window"].system_libs.extend(["gdi32", "winmm"])
elif self.settings.os == "FreeBSD":
self.cpp_info.components["window"].system_libs.append("usbhid")
elif self.settings.os == "Macos":
# CoreServices is pulled from Carbon, even if it does not show up in the upstream CMakeLists.txt
self.cpp_info.components["window"].frameworks = ["Foundation", "AppKit", "IOKit", "Carbon", "CoreServices"]
elif self.settings.os == "iOS":
self.cpp_info.components["window"].frameworks = ["Foundation", "UIKit", "CoreGraphics", "QuartzCore", "CoreMotion"]
elif self.settings.os == "Android":
self.cpp_info.components["window"].system_libs = ["android"]

def _graphics_module(self):
if self.options.graphics:
self.cpp_info.components["graphics"].requires = ["window"]
if self.settings.os == "Android" or self.settings.os == "iOS":
self.cpp_info.components["graphics"].requires.append("zlib::zlib")
if self.settings.os == "iOS":
self.cpp_info.components["graphics"].requires.append("bzip2::bzip2")
self.cpp_info.components["graphics"].requires.append("freetype::freetype")
# TODO: Atomic

def _network_module(self):
if self.options.network:
self.cpp_info.components["network"].requires = ["system"]

if self.settings.os == "Windows":
self.cpp_info.components["network"].system_libs = ["ws2_32"]

def _audio_module(self):
if self.options.audio:
self.cpp_info.components["audio"].requires = ["vorbis::vorbis", "flac::flac", "system"]
if self.settings.os == "iOS":
self.cpp_info.components["audio"].frameworks = ["Foundation", "CoreFoundation", "CoreAudio", "AudioToolbox", "AVFoundation"]
else:
self.cpp_info.components["audio"].requires.extend(["vorbis::vorbisfile", "vorbis::vorbisenc"])

if self.settings.os == "Android":
self.cpp_info.components["audio"].system_libs = ["android", "OpenSLES"]

if self.settings.os == "Linux":
self.cpp_info.components["audio"].system_libs = ["dl"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/src/SFML/Graphics/CMakeLists.txt b/src/SFML/Graphics/CMakeLists.txt
index 1e77eec..42bcbd5 100644
--- a/src/SFML/Graphics/CMakeLists.txt
+++ b/src/SFML/Graphics/CMakeLists.txt
@@ -111,13 +111,16 @@ endif()

# find external libraries
if(SFML_OS_ANDROID)
- target_link_libraries(sfml-graphics PRIVATE z)
+ find_package(ZLIB REQUIRED)
+ target_link_libraries(sfml-graphics PRIVATE ZLIB::ZLIB)
elseif(SFML_OS_IOS)
- target_link_libraries(sfml-graphics PRIVATE z bz2)
+ find_package(ZLIB REQUIRED)
+ find_package(BZip2 REQUIRED)
+ target_link_libraries(sfml-graphics PRIVATE ZLIB::ZLIB BZip2::BZip2)
endif()

-find_package(Freetype REQUIRED)
-target_link_libraries(sfml-graphics PRIVATE Freetype::Freetype)
+find_package(freetype REQUIRED)
+target_link_libraries(sfml-graphics PRIVATE freetype)

# add preprocessor symbols
target_compile_definitions(sfml-graphics PRIVATE "STBI_FAILURE_USERMSG")
Loading
Loading