-
-
Notifications
You must be signed in to change notification settings - Fork 12.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
48 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ class Leptonica < Formula | |
sha256 cellar: :any_skip_relocation, x86_64_linux: "9b2c01e724c093ba4b4bf19bdd65edcc3ff70dbc5071e5e801f07b9f24cc2d63" | ||
end | ||
|
||
depends_on "cmake" => :build | ||
depends_on "pkg-config" => :build | ||
depends_on "giflib" | ||
depends_on "jpeg-turbo" | ||
|
@@ -24,24 +25,60 @@ class Leptonica < Formula | |
|
||
uses_from_macos "zlib" | ||
|
||
patch :DATA | ||
|
||
def install | ||
Check failure on line 30 in Formula/l/leptonica.rb GitHub Actions / Linux`brew install --verbose --formula --build-bottle leptonica` failed on Linux!
|
||
system "./configure", "--with-libwebp", "--with-libopenjpeg", *std_configure_args | ||
system "make", "install" | ||
args = ["-DSTRICT_CONF=ON"] | ||
shared_args = ["-DBUILD_PROG=ON", "-DBUILD_SHARED_LIBS=ON", "-DCMAKE_INSTALL_RPATH=#{rpath}"] | ||
|
||
system "cmake", "-S", ".", "-B", "build_shared", *args, *shared_args, *std_cmake_args | ||
system "cmake", "--build", "build_shared" | ||
system "cmake", "--install", "build_shared" | ||
|
||
system "cmake", "-S", ".", "-B", "build_static", *args, *std_cmake_args | ||
system "cmake", "--build", "build_static" | ||
lib.install "build_static/src/libleptonica.a" | ||
|
||
# Add lept.pc to align with autotools build | ||
odie "lept.pc already exists!" if (lib/"pkgconfig/lept.pc").exist? | ||
odie "lept_Release.pc does not exist!" unless (lib/"pkgconfig/lept_Release.pc").exist? | ||
(lib/"pkgconfig").install_symlink "lept_Release.pc" => "lept.pc" | ||
end | ||
|
||
test do | ||
(testpath/"test.cpp").write <<~EOS | ||
#include <iostream> | ||
(testpath/"test.c").write <<~C | ||
#include <stdio.h> | ||
#include <leptonica/allheaders.h> | ||
int main(int argc, char **argv) { | ||
fprintf(stdout, "%d.%d.%d", LIBLEPT_MAJOR_VERSION, LIBLEPT_MINOR_VERSION, LIBLEPT_PATCH_VERSION); | ||
return 0; | ||
int main() { | ||
printf("%d.%d.%d", LIBLEPT_MAJOR_VERSION, LIBLEPT_MINOR_VERSION, LIBLEPT_PATCH_VERSION); | ||
writeImageFileInfo("#{test_fixtures("test.png")}", stderr, 0); | ||
return 0; | ||
} | ||
EOS | ||
C | ||
|
||
flags = ["-I#{include}/leptonica"] + ENV.cflags.to_s.split | ||
system ENV.cxx, "test.cpp", *flags | ||
assert_equal version.to_s, `./a.out` | ||
system ENV.cc, "test.c", "-o", "test", "-L#{lib}", "-lleptonica" | ||
assert_equal version.to_s, shell_output("./test 2>#{testpath}/stderr.log") | ||
assert_match <<~TEXT, (testpath/"stderr.log").read | ||
Reading the header: | ||
input image format type: png | ||
w = 8, h = 8, bps = 1, spp = 1, iscmap = 1 | ||
xres = 0, yres = 0 | ||
TEXT | ||
end | ||
end | ||
|
||
__END__ | ||
diff --git a/prog/CMakeLists.txt b/prog/CMakeLists.txt | ||
index 73fd28b5..6626ba25 100644 | ||
--- a/prog/CMakeLists.txt | ||
+++ b/prog/CMakeLists.txt | ||
@@ -15,7 +15,7 @@ function(add_prog_target target) | ||
if (BUILD_SHARED_LIBS) | ||
target_compile_definitions (${target} PRIVATE -DLIBLEPT_IMPORTS) | ||
endif() | ||
- if(FREEBSD AND HAVE_LIBM AND ${target} MATCHES ${math_progs}) | ||
+ if((FREEBSD OR CMAKE_SYSTEM_NAME STREQUAL "Linux") AND HAVE_LIBM AND ${target} MATCHES ${math_progs}) | ||
target_link_libraries (${target} leptonica m) | ||
else() | ||
target_link_libraries (${target} leptonica) |