imagelol: fix darwin and use system libpng (#454413)
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
fetchFromGitHub,
|
||||
fetchpatch,
|
||||
cmake,
|
||||
libpng,
|
||||
stb,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
@@ -25,10 +27,11 @@ stdenv.mkDerivation rec {
|
||||
url = "https://github.com/MCredstoner2004/ImageLOL/commit/013fb1f901d88f5fd21a896bfab47c7fff0737d7.patch";
|
||||
hash = "sha256-RVaG2xbUqE4CxqI2lhvug2qihT6A8vN+pIfK58CXLDw=";
|
||||
includes = [ "imagelol/ImageLOL.inl" ];
|
||||
# change lib/ for imagelol
|
||||
stripLen = 2;
|
||||
extraPrefix = "imagelol/";
|
||||
})
|
||||
# use system libraries instead of bundled versions
|
||||
./use-system-libs.patch
|
||||
];
|
||||
|
||||
# fix for case-sensitive filesystems
|
||||
@@ -36,28 +39,28 @@ stdenv.mkDerivation rec {
|
||||
postPatch = ''
|
||||
mv imagelol src
|
||||
substituteInPlace CMakeLists.txt \
|
||||
--replace 'add_subdirectory("imagelol")' 'add_subdirectory("src")'
|
||||
--replace-fail 'add_subdirectory("imagelol")' 'add_subdirectory("src")'
|
||||
|
||||
substituteInPlace External/zlib-no-examples/CMakeLists.txt \
|
||||
--replace-fail "cmake_minimum_required(VERSION 2.4.4)" "cmake_minimum_required(VERSION 3.10)"
|
||||
substituteInPlace External/libpng/CMakeLists.txt \
|
||||
--replace-fail "cmake_minimum_required(VERSION 3.1)" "cmake_minimum_required(VERSION 3.10)" \
|
||||
--replace-fail "cmake_policy(VERSION 3.1)" "cmake_policy(VERSION 3.10)"
|
||||
# use system stb headers
|
||||
substituteInPlace External/stb_image-cmake/CMakeLists.txt \
|
||||
--replace-fail '"''${CMAKE_CURRENT_SOURCE_DIR}/../stb"' '"${stb}/include/stb"'
|
||||
|
||||
# remove bundled libraries
|
||||
rm -r External/zlib External/zlib-no-examples External/libpng External/stb
|
||||
'';
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp ./ImageLOL $out/bin
|
||||
'';
|
||||
buildInputs = [
|
||||
libpng
|
||||
stb
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
(lib.cmakeFeature "CMAKE_C_FLAGS" "-std=gnu90")
|
||||
]
|
||||
++ lib.optional (
|
||||
stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64
|
||||
) "-DPNG_ARM_NEON=off";
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dm755 ImageLOL -t $out/bin
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/MCredstoner2004/ImageLOL";
|
||||
@@ -65,7 +68,6 @@ stdenv.mkDerivation rec {
|
||||
license = licenses.mit;
|
||||
maintainers = [ ];
|
||||
platforms = platforms.unix;
|
||||
broken = stdenv.hostPlatform.isDarwin;
|
||||
mainProgram = "ImageLOL";
|
||||
};
|
||||
}
|
||||
|
||||
32
pkgs/by-name/im/imagelol/use-system-libs.patch
Normal file
32
pkgs/by-name/im/imagelol/use-system-libs.patch
Normal file
@@ -0,0 +1,32 @@
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -3,26 +3,12 @@
|
||||
project(ImageLOL VERSION 0.0)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
-include_directories("External/zlib" "External/libpng")
|
||||
add_subdirectory("External/stb_image-cmake")
|
||||
|
||||
-set(SKIP_INSTALL_ALL ON CACHE BOOL "")
|
||||
-add_subdirectory("External/zlib-no-examples")
|
||||
-
|
||||
-set(PNG_BUILD_ZLIB ON CACHE BOOL "")
|
||||
-link_libraries(zlibstatic)
|
||||
-get_target_property(ZLIB_INCLUDE_DIRECTORIES zlibstatic INCLUDE_DIRECTORIES)
|
||||
-include_directories(${ZLIB_INCLUDE_DIRECTORIES})
|
||||
-set(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRECTORIES} CACHE PATH "")
|
||||
-set(PNG_SHARED OFF CACHE BOOL "")
|
||||
-set(PNG_EXECUTABLES OFF CACHE BOOL "")
|
||||
-add_subdirectory("External/libpng")
|
||||
-add_dependencies(png_static zlibstatic zlib)
|
||||
-add_dependencies(genfiles zlibstatic)
|
||||
-unset(SKIP_INSTALL_ALL CACHE)
|
||||
-get_target_property(LIBPNG_INCLUDE_DIRECTORIES png_static INCLUDE_DIRECTORIES)
|
||||
+find_package(PNG REQUIRED)
|
||||
+set(LIBPNG_INCLUDE_DIRECTORIES ${PNG_INCLUDE_DIRS})
|
||||
|
||||
add_subdirectory("imagelol")
|
||||
add_executable(ImageLOL main.cpp)
|
||||
target_include_directories(ImageLOL PRIVATE ${LIBPNG_INCLUDE_DIRECTORIES})
|
||||
-target_link_libraries(ImageLOL PRIVATE stb_image png_static zlibstatic libimagelol)
|
||||
+target_link_libraries(ImageLOL PRIVATE stb_image PNG::PNG libimagelol)
|
||||
Reference in New Issue
Block a user