diff --git a/recipes/sdl/all/conandata.yml b/recipes/sdl/all/conandata.yml index 24d42d4c8fad2..091076bcd4337 100644 --- a/recipes/sdl/all/conandata.yml +++ b/recipes/sdl/all/conandata.yml @@ -14,31 +14,8 @@ sources: "2.0.20": url: "https://www.libsdl.org/release/SDL2-2.0.20.tar.gz" sha256: "c56aba1d7b5b0e7e999e4a7698c70b63a3394ff9704b5f6e1c57e0c16f04dd06" - "2.0.18": - url: "https://www.libsdl.org/release/SDL2-2.0.18.tar.gz" - sha256: "94d40cd73dbfa10bb6eadfbc28f355992bb2d6ef6761ad9d4074eff95ee5711c" - "2.0.16": - url: "https://www.libsdl.org/release/SDL2-2.0.16.tar.gz" - sha256: "65be9ff6004034b5b2ce9927b5a4db1814930f169c4b2dae0a1e4697075f287b" - "2.0.14": - url: "https://www.libsdl.org/release/SDL2-2.0.14.tar.gz" - sha256: "d8215b571a581be1332d2106f8036fcb03d12a70bae01e20f424976d275432bc" patches: "2.0.20": - patch_file: "patches/0004-2.0.20-ndk.patch" patch_type: "conan" patch_description: "ndk patch" - "2.0.16": - - patch_file: "patches/0003-2.0.16-wayland-scanner-buildrequires.patch" - patch_type: "conan" - patch_description: "wayland scanner buildrequires" - "2.0.14": - - patch_file: "patches/0001-fix-cmake-ios-tvos.patch" - patch_type: "conan" - patch_description: "fix cmake ios tvos" - - patch_file: "patches/0002-mingw-improvements.patch" - patch_type: "conan" - patch_description: "mingw improvements" - - patch_file: "patches/0003-2.0.14-wayland-scanner-buildrequires.patch" - patch_type: "conan" - patch_description: "wayland scanner buildrequires" diff --git a/recipes/sdl/all/conanfile.py b/recipes/sdl/all/conanfile.py index 3e8e5233fd108..6d8d882403cbd 100644 --- a/recipes/sdl/all/conanfile.py +++ b/recipes/sdl/all/conanfile.py @@ -20,11 +20,8 @@ class SDLConan(ConanFile): url = "https://github.com/conan-io/conan-center-index" homepage = "https://www.libsdl.org" license = "Zlib" - + package_type = "library" settings = "os", "arch", "compiler", "build_type" - - generators = "CMakeDeps", "PkgConfigDeps", "VirtualBuildEnv" - options = { "shared": [True, False], "fPIC": [True, False], @@ -62,7 +59,7 @@ class SDLConan(ConanFile): "jack": False, "pulse": True, "sndio": False, - "nas": True, + "nas": False, "esd": False, "arts": False, "x11": True, @@ -75,7 +72,6 @@ class SDLConan(ConanFile): "xvm": True, "wayland": True, "directfb": False, - "iconv": True, "video_rpi": False, "sdl2main": True, "opengl": True, @@ -83,7 +79,8 @@ class SDLConan(ConanFile): "vulkan": True, "libunwind": True, } - + generators = "CMakeDeps", "PkgConfigDeps", "VirtualBuildEnv" + def layout(self): cmake_layout(self, src_folder="src") @@ -103,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): @@ -147,7 +150,7 @@ def requirements(self): if self.options.opengl: self.requires("opengl/system") if self.options.nas: - self.requires("nas/1.9.4") + self.requires("nas/1.9.5") if self.options.wayland: self.requires("wayland/1.21.0") self.requires("xkbcommon/1.4.1") @@ -156,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)) @@ -184,11 +184,11 @@ def build_requirements(self): # set. This could be because you are using a Mac OS X version less than 10.5 # or because CMake's platform configuration is corrupt. # FIXME: Remove once CMake on macOS/M1 CI runners is upgraded. - self.build_requires("cmake/3.22.0") + self.tool_requires("cmake/3.25.3") if self.settings.os == "Linux" and not self.conf.get("tools.gnu:pkg_config", check_type=str): self.tool_requires("pkgconf/1.9.3") if hasattr(self, "settings_build") and self.options.get_safe("wayland"): - self.build_requires("wayland/1.20.0") # Provides wayland-scanner + self.build_requires("wayland/1.21.0") # Provides wayland-scanner def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True, @@ -197,18 +197,30 @@ 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": + if self.options.iconv: + # If using conan-provided iconv, search for the symbol "libiconv_open" + replace_check = "check_library_exists(iconv libiconv_open" + else: + # When no tusing conan-provided icon, don't check for iconv at all + replace_check = "#check_library_exists(iconv iconv_open" + replace_in_file(self, cmakelists, "check_library_exists(iconv iconv_open", + replace_check) + + # Avoid assuming iconv is available if it is provided by the C runtime, + # and let SDL build the fallback implementation + replace_in_file(self, cmakelists, 'check_library_exists(c iconv_open "" HAVE_BUILTIN_ICONV)', '# check_library_exists(c iconv_open "" HAVE_BUILTIN_ICONV)') # Ensure to find wayland-scanner from wayland recipe in build requirements (or requirements if 1 profile) if self.options.get_safe("wayland") and Version(self.version) >= "2.0.18": - wayland_bin_path = " ".join("\"{}\"".format(path) for path in self.deps_env_info["wayland"].PATH) replace_in_file(self, - os.path.join(self.source_folder, "cmake", "sdlchecks.cmake"), - "find_program(WAYLAND_SCANNER NAMES wayland-scanner REQUIRED)", - "find_program(WAYLAND_SCANNER NAMES wayland-scanner REQUIRED PATHS {} NO_DEFAULT_PATH)".format(wayland_bin_path), - ) + os.path.join(self.source_folder, "cmake", "sdlchecks.cmake"), + "find_program(WAYLAND_SCANNER NAMES wayland-scanner REQUIRED)", + 'find_program(WAYLAND_SCANNER NAMES wayland-scanner REQUIRED PATHS "${WAYLAND_BIN_DIR}" NO_DEFAULT_PATH)', + ) def define_toolchain(self): tc = CMakeToolchain(self) @@ -230,143 +242,79 @@ def define_toolchain(self): tc.variables["HAVE_LIBC"] = True tc.variables["SDL_SHARED"] = self.options.shared tc.variables["SDL_STATIC"] = not self.options.shared + tc.variables["SDL_OPENGL"] = self.options.opengl + tc.variables["SDL_OPENGLES"] = self.options.opengles + tc.variables["SDL_VULKAN"] = self.options.vulkan + if self.settings.os == "Linux": + # See https://github.com/bincrafters/community/issues/696 + tc.variables["SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS"] = 1 - if Version(self.version) < "2.0.18": - tc.variables["VIDEO_OPENGL"] = self.options.opengl - tc.variables["VIDEO_OPENGLES"] = self.options.opengles - tc.variables["VIDEO_VULKAN"] = self.options.vulkan - if self.settings.os == "Linux": - # See https://github.com/bincrafters/community/issues/696 - tc.variables["SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS"] = 1 - - tc.variables["ALSA"] = self.options.alsa - if self.options.alsa: - tc.variables["ALSA_SHARED"] = self.options["libalsa"].shared - tc.variables["HAVE_ASOUNDLIB_H"] = True - tc.variables["HAVE_LIBASOUND"] = True - tc.variables["JACK"] = self.options.jack - if self.options.jack: - tc.variables["JACK_SHARED"] = self.options["jack"].shared - tc.variables["ESD"] = self.options.esd - if self.options.esd: - tc.variables["ESD_SHARED"] = self.options["esd"].shared - tc.variables["PULSEAUDIO"] = self.options.pulse - if self.options.pulse: - tc.variables["PULSEAUDIO_SHARED"] = self.options["pulseaudio"].shared - tc.variables["SNDIO"] = self.options.sndio - if self.options.sndio: - tc.variables["SNDIO_SHARED"] = self.options["sndio"].shared - tc.variables["NAS"] = self.options.nas - if self.options.nas: - cmake_extra_ldflags += ["-lXau"] # FIXME: SDL sources doesn't take into account transitive dependencies - cmake_required_includes += self.dependencies["nas"].cpp_info.includedirs - tc.variables["NAS_SHARED"] = self.options["nas"].shared - tc.variables["VIDEO_X11"] = self.options.x11 - if self.options.x11: - tc.variables["HAVE_XEXT_H"] = True - tc.variables["VIDEO_X11_XCURSOR"] = self.options.xcursor - if self.options.xcursor: - tc.variables["HAVE_XCURSOR_H"] = True - tc.variables["VIDEO_X11_XINERAMA"] = self.options.xinerama - if self.options.xinerama: - tc.variables["HAVE_XINERAMA_H"] = True - tc.variables["VIDEO_X11_XINPUT"] = self.options.xinput - if self.options.xinput: - tc.variables["HAVE_XINPUT_H"] = True - tc.variables["VIDEO_X11_XRANDR"] = self.options.xrandr - if self.options.xrandr: - tc.variables["HAVE_XRANDR_H"] = True - tc.variables["VIDEO_X11_XSCRNSAVER"] = self.options.xscrnsaver - if self.options.xscrnsaver: - tc.variables["HAVE_XSS_H"] = True - tc.variables["VIDEO_X11_XSHAPE"] = self.options.xshape - if self.options.xshape: - tc.variables["HAVE_XSHAPE_H"] = True - tc.variables["VIDEO_X11_XVM"] = self.options.xvm - if self.options.xvm: - tc.variables["HAVE_XF86VM_H"] = True - tc.variables["VIDEO_WAYLAND"] = self.options.wayland - if self.options.wayland: - # FIXME: Otherwise 2.0.16 links with system wayland (from egl/system requirement) - cmake_extra_ldflags += ["-L{}".format(it) for it in self.dependencies["wayland"].cpp_info.libdirs] - tc.variables["WAYLAND_SHARED"] = self.options["wayland"].shared - tc.variables["WAYLAND_SCANNER_1_15_FOUND"] = 1 # FIXME: Check actual build-requires version - - tc.variables["VIDEO_DIRECTFB"] = self.options.directfb - tc.variables["VIDEO_RPI"] = self.options.video_rpi - tc.variables["HAVE_LIBUNWIND_H"] = self.options.libunwind - elif self.settings.os == "Windows": - tc.variables["DIRECTX"] = self.options.directx - else: - tc.variables["SDL_OPENGL"] = self.options.opengl - tc.variables["SDL_OPENGLES"] = self.options.opengles - tc.variables["SDL_VULKAN"] = self.options.vulkan - if self.settings.os == "Linux": - # See https://github.com/bincrafters/community/issues/696 - tc.variables["SDL_VIDEO_DRIVER_X11_SUPPORTS_GENERIC_EVENTS"] = 1 - - tc.variables["SDL_ALSA"] = self.options.alsa - if self.options.alsa: - tc.variables["SDL_ALSA_SHARED"] = self.options["libalsa"].shared - tc.variables["HAVE_ASOUNDLIB_H"] = True - tc.variables["HAVE_LIBASOUND"] = True - tc.variables["SDL_JACK"] = self.options.jack - if self.options.jack: - tc.variables["SDL_JACK_SHARED"] = self.options["jack"].shared - tc.variables["SDL_ESD"] = self.options.esd - if self.options.esd: - tc.variables["SDL_ESD_SHARED"] = self.options["esd"].shared - tc.variables["SDL_PULSEAUDIO"] = self.options.pulse - if self.options.pulse: - tc.variables["SDL_PULSEAUDIO_SHARED"] = self.options["pulseaudio"].shared - for component in self.dependencies["pulseaudio"].cpp_info.components: - if self.dependencies["pulseaudio"].cpp_info.components[component].libs: - cmake_extra_libs += self.dependencies["pulseaudio"].cpp_info.components[component].libs - cmake_extra_ldflags += ["-L{}".format(it) for it in self.dependencies["pulseaudio"].cpp_info.components[component].libdirs] - cmake_extra_ldflags += ["-lxcb", "-lrt"] # FIXME: SDL sources doesn't take into account transitive dependencies - tc.variables["SDL_SNDIO"] = self.options.sndio - if self.options.sndio: - tc.variables["SDL_SNDIO_SHARED"] = self.options["sndio"].shared - tc.variables["SDL_NAS"] = self.options.nas - if self.options.nas: - cmake_extra_ldflags += ["-lXau"] # FIXME: SDL sources doesn't take into account transitive dependencies - cmake_required_includes += self.dependencies["nas"].cpp_info.includedirs - tc.variables["SDL_NAS_SHARED"] = self.options["nas"].shared - tc.variables["SDL_X11"] = self.options.x11 - if self.options.x11: - tc.variables["HAVE_XEXT_H"] = True - tc.variables["SDL_X11_XCURSOR"] = self.options.xcursor - if self.options.xcursor: - tc.variables["HAVE_XCURSOR_H"] = True - tc.variables["SDL_X11_XINERAMA"] = self.options.xinerama - if self.options.xinerama: - tc.variables["HAVE_XINERAMA_H"] = True - tc.variables["SDL_X11_XINPUT"] = self.options.xinput - if self.options.xinput: - tc.variables["HAVE_XINPUT_H"] = True - tc.variables["SDL_X11_XRANDR"] = self.options.xrandr - if self.options.xrandr: - tc.variables["HAVE_XRANDR_H"] = True - tc.variables["SDL_X11_XSCRNSAVER"] = self.options.xscrnsaver - if self.options.xscrnsaver: - tc.variables["HAVE_XSS_H"] = True - tc.variables["SDL_X11_XSHAPE"] = self.options.xshape - if self.options.xshape: - tc.variables["HAVE_XSHAPE_H"] = True - tc.variables["SDL_X11_XVM"] = self.options.xvm - if self.options.xvm: - tc.variables["HAVE_XF86VM_H"] = True - tc.variables["SDL_WAYLAND"] = self.options.wayland - if self.options.wayland: - # FIXME: Otherwise 2.0.16 links with system wayland (from egl/system requirement) - cmake_extra_ldflags += ["-L{}".format(it) for it in self.dependencies["wayland"].cpp_info.libdirs] - tc.variables["SDL_WAYLAND_SHARED"] = self.options["wayland"].shared - - tc.variables["SDL_DIRECTFB"] = self.options.directfb - tc.variables["SDL_RPI"] = self.options.video_rpi - tc.variables["HAVE_LIBUNWIND_H"] = self.options.libunwind - elif self.settings.os == "Windows": - tc.variables["SDL_DIRECTX"] = self.options.directx + tc.variables["SDL_ALSA"] = self.options.alsa + if self.options.alsa: + tc.variables["SDL_ALSA_SHARED"] = self.dependencies["libalsa"].options.shared + tc.variables["HAVE_ASOUNDLIB_H"] = True + tc.variables["HAVE_LIBASOUND"] = True + tc.variables["SDL_JACK"] = self.options.jack + if self.options.jack: + tc.variables["SDL_JACK_SHARED"] = self.options["jack"].shared + tc.variables["SDL_ESD"] = self.options.esd + if self.options.esd: + tc.variables["SDL_ESD_SHARED"] = self.options["esd"].shared + tc.variables["SDL_PULSEAUDIO"] = self.options.pulse + if self.options.pulse: + tc.variables["SDL_PULSEAUDIO_SHARED"] = self.dependencies["pulseaudio"].options.shared + for component in self.dependencies["pulseaudio"].cpp_info.components: + if self.dependencies["pulseaudio"].cpp_info.components[component].libs: + cmake_extra_libs += self.dependencies["pulseaudio"].cpp_info.components[component].libs + cmake_extra_ldflags += ["-L{}".format(it) for it in self.dependencies["pulseaudio"].cpp_info.components[component].libdirs] + cmake_extra_ldflags += ["-lxcb", "-lrt"] # FIXME: SDL sources doesn't take into account transitive dependencies + tc.variables["SDL_SNDIO"] = self.options.sndio + if self.options.sndio: + tc.variables["SDL_SNDIO_SHARED"] = self.options["sndio"].shared + tc.variables["SDL_NAS"] = self.options.nas + if self.options.nas: + cmake_extra_ldflags += ["-lXau"] # FIXME: SDL sources doesn't take into account transitive dependencies + cmake_required_includes += self.dependencies["nas"].cpp_info.includedirs + tc.variables["SDL_NAS_SHARED"] = self.dependencies["nas"].options.shared + tc.variables["SDL_X11"] = self.options.x11 + if self.options.x11: + tc.variables["HAVE_XEXT_H"] = True + tc.variables["SDL_X11_XCURSOR"] = self.options.xcursor + if self.options.xcursor: + tc.variables["HAVE_XCURSOR_H"] = True + tc.variables["SDL_X11_XINERAMA"] = self.options.xinerama + if self.options.xinerama: + tc.variables["HAVE_XINERAMA_H"] = True + tc.variables["SDL_X11_XINPUT"] = self.options.xinput + if self.options.xinput: + tc.variables["HAVE_XINPUT_H"] = True + tc.variables["SDL_X11_XRANDR"] = self.options.xrandr + if self.options.xrandr: + tc.variables["HAVE_XRANDR_H"] = True + tc.variables["SDL_X11_XSCRNSAVER"] = self.options.xscrnsaver + if self.options.xscrnsaver: + tc.variables["HAVE_XSS_H"] = True + tc.variables["SDL_X11_XSHAPE"] = self.options.xshape + if self.options.xshape: + tc.variables["HAVE_XSHAPE_H"] = True + tc.variables["SDL_X11_XVM"] = self.options.xvm + if self.options.xvm: + tc.variables["HAVE_XF86VM_H"] = True + tc.variables["SDL_WAYLAND"] = self.options.wayland + if self.options.wayland: + # FIXME: Otherwise 2.0.16 links with system wayland (from egl/system requirement) + cmake_extra_ldflags += ["-L{}".format(it) for it in self.dependencies["wayland"].cpp_info.libdirs] + tc.variables["SDL_WAYLAND_SHARED"] = self.dependencies["wayland"].options.shared + + wayland = self.dependencies["wayland"] if not hasattr(self, "settings_build") else self.dependencies.build["wayland"] + wayland_bin_dir = wayland.cpp_info.bindirs[0] # for wayland scanner + tc.variables["WAYLAND_BIN_DIR"] = wayland_bin_dir + + tc.variables["SDL_DIRECTFB"] = self.options.directfb + tc.variables["SDL_RPI"] = self.options.video_rpi + tc.variables["HAVE_LIBUNWIND_H"] = self.options.libunwind + elif self.settings.os == "Windows": + tc.variables["SDL_DIRECTX"] = self.options.directx if Version(self.version) >= "2.0.22": tc.variables["SDL2_DISABLE_SDL2MAIN"] = not self.options.sdl2main @@ -387,11 +335,9 @@ def build(self): def package(self): cmake = CMake(self) - if self.version >= "2.0.16": - copy(self, pattern="LICENSE.txt", src=os.path.join(self.source_folder), dst=os.path.join(self.package_folder, "licenses")) - else: - copy(self, pattern="COPYING.txt", src=os.path.join(self.source_folder), dst=os.path.join(self.package_folder, "licenses")) cmake.install() + + copy(self, pattern="LICENSE.txt", src=os.path.join(self.source_folder), dst=os.path.join(self.package_folder, "licenses")) rm(self, "sdl2-config", os.path.join(self.package_folder, "bin")) rmdir(self, os.path.join(self.package_folder, "cmake")) rmdir(self, os.path.join(self.package_folder, "lib", "cmake")) @@ -464,24 +410,18 @@ def package_info(self): "CoreVideo", "CoreAudio", "AudioToolbox", "AVFoundation", "Foundation", "QuartzCore", ] - add_core_haptics = False if self.settings.os == "Macos": self.cpp_info.components["libsdl2"].frameworks.extend(["Cocoa", "Carbon", "IOKit", "ForceFeedback"]) - if Version(self.version) >= "2.0.18": - self.cpp_info.components["libsdl2"].frameworks.append("GameController") + self.cpp_info.components["libsdl2"].frameworks.append("GameController") elif self.settings.os in ["iOS", "tvOS", "watchOS"]: self.cpp_info.components["libsdl2"].frameworks.extend([ "UIKit", "OpenGLES", "GameController", "CoreMotion", "CoreGraphics", "CoreBluetooth", ]) - add_core_haptics = True - if Version(self.version) >= "2.0.14": - self.cpp_info.components["libsdl2"].frameworks.append("Metal") - if Version(self.version) >= "2.0.18": - add_core_haptics = True - if add_core_haptics: - self.cpp_info.components["libsdl2"].sharedlinkflags.append("-Wl,-weak_framework,CoreHaptics") - self.cpp_info.components["libsdl2"].exelinkflags.append("-Wl,-weak_framework,CoreHaptics") + + self.cpp_info.components["libsdl2"].frameworks.append("Metal") + self.cpp_info.components["libsdl2"].sharedlinkflags.append("-Wl,-weak_framework,CoreHaptics") + self.cpp_info.components["libsdl2"].exelinkflags.append("-Wl,-weak_framework,CoreHaptics") elif self.settings.os == "Windows": self.cpp_info.components["libsdl2"].system_libs = ["user32", "gdi32", "winmm", "imm32", "ole32", "oleaut32", "version", "uuid", "advapi32", "setupapi", "shell32"] if self.settings.compiler == "gcc": @@ -490,7 +430,6 @@ def package_info(self): self.cpp_info.components["libsdl2"].system_libs.extend(["android", "dl", "log"]) if self.options.opengles: self.cpp_info.components["libsdl2"].system_libs.extend(["GLESv1_CM", "GLESv2"]) - if Version(self.version) >= "2.0.16": self.cpp_info.components["libsdl2"].system_libs.append("OpenSLES") # SDL2main diff --git a/recipes/sdl/config.yml b/recipes/sdl/config.yml index 130fce619991a..211e5780e8908 100644 --- a/recipes/sdl/config.yml +++ b/recipes/sdl/config.yml @@ -9,9 +9,3 @@ versions: folder: all "2.0.20": folder: all - "2.0.18": - folder: all - "2.0.16": - folder: all - "2.0.14": - folder: all