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

sdl_ttf: fix android build in 2.0.18 & allow msvc shared since 2.20.0 #15560

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 11 additions & 4 deletions recipes/sdl_ttf/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ sources:
url: "https://github.com/libsdl-org/SDL_ttf/archive/refs/tags/release-2.0.18.tar.gz"
sha256: "6b61544441b72bdfa1ced89034c6396fe80228eff201eb72c5f78e500bb80bd0"
"2.0.15":
url: "https://github.com/libsdl-org/SDL_ttf/archive/refs/tags/release-2.0.15.tar.gz"
sha256: "02e887b560faf398cbd60f56ce0a1cbaf96012dd4ddaa455f8307cb4911c86cc"
url: "https://github.com/libsdl-org/SDL_ttf/releases/download/release-2.0.15/SDL2_ttf-2.0.15.tar.gz"
sha256: "a9eceb1ad88c1f1545cd7bd28e7cbc0b2c14191d40238f531a15b01b1b22cd33"
patches:
"2.20.1":
- patch_file: "patches/2.20.1-0001-fix-cmake-min-version.patch"
patch_description: "Disable useless .pc file install to avoid relying on CMake 3.21 features"
patch_type: "conan"
"2.0.18":
- patch_file: "patches/cmake-fix-link-target-2.0.18.patch"
- patch_file: "patches/2.0.18-0001-cmake-fix-link-target.patch"
patch_description: "correct target name, disable PIC fixed"
patch_type: "portability"
- patch_file: "patches/2.0.18-0002-fix-android.patch"
patch_description: "Fix Android build"
patch_type: "portability"
"2.0.15":
- patch_file: "patches/cmake-fix-link-target-2.0.15.patch"
- patch_file: "patches/2.0.15-0001-cmake-fix-link-target.patch"
patch_description: "correct target name"
patch_type: "portability"
24 changes: 13 additions & 11 deletions recipes/sdl_ttf/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from conan.tools.scm import Version
import os

required_conan_version = ">=1.53.0"
required_conan_version = ">=1.54.0"


class SdlttfConan(ConanFile):
Expand Down Expand Up @@ -35,15 +35,16 @@ def export_sources(self):
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
if Version(self.version) < "2.20.0":
del self.options.with_harfbuzz

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

if Version(self.version) < "2.20.0":
del self.options.with_harfbuzz
if Version(self.version) >= "2.20.0":
self.options["sdl"].shared = self.options.shared

def layout(self):
cmake_layout(self, src_folder="src")
Expand All @@ -55,25 +56,26 @@ def requirements(self):
self.requires("harfbuzz/6.0.0")

def validate(self):
if is_msvc(self) and self.info.options.shared:
raise ConanInvalidConfiguration("sdl_ttf shared is not supported with Visual Studio")
if Version(self.version).major != Version(self.dependencies["sdl"].ref.version).major:
raise ConanInvalidConfiguration("sdl & sdl_ttf must have the same major version")

if Version(self.version) >= "2.20.0" and self.options.shared != self.dependencies["sdl"].options.shared:
raise ConanInvalidConfiguration("sdl & sdl_ttf must be build with the same options(shared or static)")
if Version(self.version) >= "2.20.0":
if self.options.shared != self.dependencies["sdl"].options.shared:
raise ConanInvalidConfiguration("sdl & sdl_ttf must be built with the same 'shared' option value")
else:
if is_msvc(self) and self.options.shared:
raise ConanInvalidConfiguration(f"{self.ref} shared is not supported with Visual Studio")

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

def generate(self):
tc = CMakeToolchain(self)
if Version(self.version) >= "2.20.0":
tc.variables["CMAKE_POSITION_INDEPENDENT_CODE"] = self.options.get_safe("fPIC", True)
tc.variables["SDL2TTF_SAMPLES"] = False
tc.variables["SDL2TTF_VENDORED"] = False
tc.variables["SDL2TTF_HARFBUZZ"] = self.options.with_harfbuzz
tc.variables["SDL2TTF_DEBUG_POSTFIX"] = ""
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
tc.generate()
deps = CMakeDeps(self)
Expand Down
11 changes: 11 additions & 0 deletions recipes/sdl_ttf/all/patches/2.0.18-0002-fix-android.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,7 +12,7 @@ endif()
cmake_minimum_required(VERSION 3.0)
project(SDL_ttf C)

-if (ANDROID)
+if (0)
option(TTF_WITH_HARFBUZZ "use harfbuzz to improve text shaping" OFF)

add_library(SDL2_ttf SHARED)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -325,7 +325,7 @@ if(SDL2TTF_INSTALL)
COMPONENT devel
)

- if(SDL2TTF_BUILD_SHARED_LIBS)
+ if(0)
# Only create a .pc file for a shared SDL2_ttf
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")