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_image] Fix static sdl_image with shared sdl #22575

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
5 changes: 5 additions & 0 deletions recipes/sdl_image/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ sources:
"2.0.5":
url: "https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.tar.gz"
sha256: "bdd5f6e026682f7d7e1be0b6051b209da2f402a2dd8bd1c4bd9c25ad263108d0"
patches:
"2.6.3":
- patch_file: "patches/0001-set-sdl-version-directly.patch"
patch_type: "conan"
patch_description: "Set SDL version directly in CMake rather than parsing a header"
6 changes: 5 additions & 1 deletion recipes/sdl_image/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from conan.errors import ConanInvalidConfiguration
from conan.tools.apple import is_apple_os
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import copy, get, rmdir
from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rmdir
from conan.tools.scm import Version
import os

Expand Down Expand Up @@ -67,6 +67,7 @@ class SDLImageConan(ConanFile):
}

def export_sources(self):
export_conandata_patches(self)
if Version(self.version) < "2.6":
copy(self, "CMakeLists.txt", src=self.recipe_folder, dst=self.export_sources_folder)

Expand Down Expand Up @@ -165,11 +166,14 @@ def generate(self):
tc.variables["SDL2IMAGE_XV"] = self.options.xv
tc.variables["SDL2IMAGE_BACKEND_WIC"] = self.options.get_safe("wic")
tc.variables["SDL2IMAGE_BACKEND_IMAGEIO"] = self.options.get_safe("imageio")
if not is_apple_os(self):
tc.variables["CMAKE_SHARED_LINKER_FLAGS_INIT"] = '-Wl,--as-needed'
Ahajha marked this conversation as resolved.
Show resolved Hide resolved
tc.generate()
cd = CMakeDeps(self)
cd.generate()

def build(self):
apply_conandata_patches(self)
rmdir(self, os.path.join(self.source_folder, "external"))
cmake = CMake(self)
if Version(self.version) < "2.6":
Expand Down
21 changes: 21 additions & 0 deletions recipes/sdl_image/all/patches/0001-set-sdl-version-directly.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/cmake/FindPrivateSDL2.cmake b/cmake/FindPrivateSDL2.cmake
index 0314170..185f352 100644
--- a/cmake/FindPrivateSDL2.cmake
+++ b/cmake/FindPrivateSDL2.cmake
@@ -17,7 +17,7 @@ find_path(SDL2_INCLUDE_DIR
)

set(SDL2_VERSION)
-if(SDL2_INCLUDE_DIR)
+if(FALSE)
file(READ "${SDL2_INCLUDE_DIR}/SDL_version.h" _sdl_version_h)
string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl2_major_re "${_sdl_version_h}")
set(_sdl2_major "${CMAKE_MATCH_1}")
@@ -29,6 +29,7 @@ if(SDL2_INCLUDE_DIR)
set(SDL2_VERSION "${_sdl2_major}.${_sdl2_minor}.${_sdl2_patch}")
endif()
endif()
+set(SDL2_VERSION ${SDL2_VERSION_STRING})

find_package_handle_standard_args(PrivateSDL2
REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR
Loading