Blob Blame History Raw
From d3dfe80d0a9892236cbbe14b68fe301b93e90a6f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan@danny.cz>
Date: Tue, 1 Jun 2010 10:54:50 +0200
Subject: [PATCH] use system hyphen library

---
 Scribus/CMakeLists.txt                 |   10 ++++++++++
 Scribus/cmake/modules/FindHYPHEN.cmake |   28 ++++++++++++++++++++++++++++
 Scribus/scribus/CMakeLists.txt         |   16 ++++++++++++++--
 Scribus/scribus/hyphenator.h           |    2 +-
 4 files changed, 53 insertions(+), 3 deletions(-)
 create mode 100644 Scribus/cmake/modules/FindHYPHEN.cmake

diff --git a/Scribus/CMakeLists.txt b/Scribus/CMakeLists.txt
index 6f37f5f..09396f3 100644
--- a/Scribus/CMakeLists.txt
+++ b/Scribus/CMakeLists.txt
@@ -678,6 +678,16 @@ IF (WITH_PODOFO)
 ENDIF (WITH_PODOFO)
 #>>PoDoFo for AI PDF import
 
+#<<HYPHEN for system hyphenation library
+FIND_PACKAGE(HYPHEN)
+IF(HYPHEN_FOUND)
+  MESSAGE("system hyphenation library found OK")
+  SET(HAVE_HYPHEN 1)
+ELSE(HYPHEN_FOUND)
+  MESSAGE("system hyphenation library NOT found - will use internal one")
+ENDIF(HYPHEN_FOUND)
+#>>HYPHEN for system hyphenation library
+
 ##############################################################################################################
 ########## Include Setup                                                                            ##########
 
diff --git a/Scribus/cmake/modules/FindHYPHEN.cmake b/Scribus/cmake/modules/FindHYPHEN.cmake
new file mode 100644
index 0000000..d67bd59
--- /dev/null
+++ b/Scribus/cmake/modules/FindHYPHEN.cmake
@@ -0,0 +1,28 @@
+# - Find HYPHEN library
+# Find the native HYPHEN includes and library
+# This module defines
+#  HYPHEN_INCLUDE_DIR, where to find hyphen.h, etc.
+#  HYPHEN_LIBRARIES, libraries to link against to use HYPHEN.
+#  HYPHEN_FOUND, If false, do not try to use HYPHEN.
+# also defined, but not for general use are
+#  HYPHEN_LIBRARY, where to find the HYPHEN library.
+
+FIND_PATH(HYPHEN_INCLUDE_DIR hyphen.h)
+
+SET(HYPHEN_NAMES_RELEASE ${HYPHEN_NAMES_RELEASE} ${HYPHEN_NAMES} hyphen libhyphen)
+SET(HYPHEN_NAMES_DEBUG ${HYPHEN_NAMES_DEBUG} hyphend libhyphend)
+
+FIND_LIBRARY(HYPHEN_LIBRARY_RELEASE NAMES ${HYPHEN_NAMES_RELEASE} )
+FIND_LIBRARY(HYPHEN_LIBRARY_DEBUG NAMES ${HYPHEN_NAMES_DEBUG} )
+
+INCLUDE(LibraryDebugAndRelease)
+SET_LIBRARY_FROM_DEBUG_AND_RELEASE(HYPHEN)
+
+# handle the QUIETLY and REQUIRED arguments and set HYPHEN_FOUND to TRUE if 
+# all listed variables are TRUE
+INCLUDE(ScribusFindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(HYPHEN DEFAULT_MSG HYPHEN_LIBRARY HYPHEN_INCLUDE_DIR)
+
+IF(HYPHEN_FOUND)
+  SET( HYPHEN_LIBRARIES ${HYPHEN_LIBRARY} )
+ENDIF(HYPHEN_FOUND)
diff --git a/Scribus/scribus/CMakeLists.txt b/Scribus/scribus/CMakeLists.txt
index 8663f39..5ab1762 100644
--- a/Scribus/scribus/CMakeLists.txt
+++ b/Scribus/scribus/CMakeLists.txt
@@ -397,10 +397,8 @@ SET(SCRIBUS_SOURCES
   guidesdelegate.cpp
   guidesmodel.cpp
   helpbrowser.cpp
-  hnjalloc.c
   hruler.cpp
   hyask.cpp
-  hyphen.c
   hyphenator.cpp
   hysettings.cpp
   imageinfodialog.cpp
@@ -635,6 +633,14 @@ SET(SCRIBUS_SOURCES
   vruler.cpp
 )
 
+IF(NOT HAVE_HYPHEN)
+  SET(SCRIBUS_SOURCES
+    ${SCRIBUS_SOURCES}
+    hnjalloc.c
+    hyphen.c
+  )
+ENDIF(NOT HAVE_HYPHEN)
+
 IF(WIN32)
   SET(SCRIBUS_MOC_WIN32_ONLY_CLASSES scprintengine_gdi.h)
   SET(SCRIBUS_WIN32_ONLY_SOURCES
@@ -800,6 +806,12 @@ IF(HAVE_PODOFO)
   )
 ENDIF(HAVE_PODOFO)
 
+IF(HAVE_HYPHEN)
+  TARGET_LINK_LIBRARIES(${EXE_NAME}
+    ${HYPHEN_LIBRARY}
+  )
+ENDIF(HAVE_HYPHEN)
+
 # Now build plugins
 SET(PLUGIN_LIBRARIES
   ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTXML_LIBRARY}
diff --git a/Scribus/scribus/hyphenator.h b/Scribus/scribus/hyphenator.h
index 7712c37..1312950 100644
--- a/Scribus/scribus/hyphenator.h
+++ b/Scribus/scribus/hyphenator.h
@@ -13,7 +13,7 @@ for which a new license (GPL+exception) is in place.
 #include <QSet>
 
 #include "scribusapi.h"
-#include "hyphen.h"
+#include <hyphen.h>
 class ScribusDoc;
 class ScribusMainWindow;
 class PageItem;
-- 
1.7.3.2