Skip to content

Commit

Permalink
sdl2: fix libiconv on macos
Browse files Browse the repository at this point in the history
  • Loading branch information
jcar87 committed Apr 9, 2023
1 parent 3b8112e commit 3bec507
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
3 changes: 3 additions & 0 deletions recipes/sdl/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ sources:
"2.24.0":
url: "https://www.libsdl.org/release/SDL2-2.24.0.tar.gz"
sha256: "91e4c34b1768f92d399b078e171448c6af18cafda743987ed2064a28954d6d97"
"2.0.20":
url: "https://www.libsdl.org/release/SDL2-2.0.20.tar.gz"
sha256: "c56aba1d7b5b0e7e999e4a7698c70b63a3394ff9704b5f6e1c57e0c16f04dd06"
patches:
"2.0.20":
- patch_file: "patches/0004-2.0.20-ndk.patch"
Expand Down
20 changes: 15 additions & 5 deletions recipes/sdl/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ class SDLConan(ConanFile):
"xvm": True,
"wayland": True,
"directfb": False,
"iconv": True,
"video_rpi": False,
"sdl2main": True,
"opengl": True,
Expand Down Expand Up @@ -101,6 +100,12 @@ def export_sources(self):
export_conandata_patches(self)

def config_options(self):
# Don't depend on iconv on macOS by default
# SDL2 depends on many system freamworks,
# which depend on the system-provided iconv
# and can conflict with the Conan provided one
self.options.iconv = self.settings.os != "Macos"

if self.settings.os == "Windows":
del self.options.fPIC
if is_msvc(self):
Expand Down Expand Up @@ -154,9 +159,6 @@ def requirements(self):
self.requires("libunwind/1.6.2")

def validate(self):
if self.settings.os == "Macos" and not self.options.iconv:
raise ConanInvalidConfiguration("On macOS iconv can't be disabled")

# SDL>=2.0.18 requires xcode 12 or higher because it uses CoreHaptics.
if Version(self.version) >= "2.0.18" and is_apple_os(self) and Version(self.settings.compiler.version) < "12":
raise ConanInvalidConfiguration("{}/{} requires xcode 12 or higher".format(self.name, self.version))
Expand Down Expand Up @@ -195,7 +197,15 @@ def source(self):
def _patch_sources(self):
apply_conandata_patches(self)

replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
cmakelists = os.path.join(self.source_folder, "CMakeLists.txt")
if self.settings.os == "Macos" and not self.options.iconv:
# Avoid falling back to system provided libiconv
replace_in_file(self, cmakelists,
"check_library_exists(iconv",
"#check_library_exists(iconv")

# TODO: a comment is needed clarifying the motivation for this
replace_in_file(self, cmakelists,
'check_library_exists(c iconv_open "" HAVE_BUILTIN_ICONV)',
'# check_library_exists(c iconv_open "" HAVE_BUILTIN_ICONV)')

Expand Down

0 comments on commit 3bec507

Please sign in to comment.