[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#590180: Patches for Sigil to use system libs when available



Hi John,

Short self intro: I'm a Linux enthusiast / developer. One of the
things I do is package various software for Fedora. I also
recently got an ebook reader, and as such got interested in Sigil.

I've read: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=590180
So I know that you've already been contacted about packaging Sigil
for Linux, and how most Linux distributions have a policy against
using bundled libraries inside applications.

I was happy to read that you're willing to take patches to make
Sigil build in such a fashion, on the condition that this would
be configurable.

As such I've created a patch set building on top of the work
by Dan Horák (in the CC) which I believe builds on top of the
work of Kan-Ru Chen (in the CC). With this patch set Sigil
can be built using just src/tidyLib and src/Sigil, for all
other parts system libraries are used. cmake's auto detection
features are used to determine whether to use a system lib, or
the bundled copy.

These patches are on top of the just released 0.5.0. I hope
you are willing to integrate them into Sigil's next release.

Thanks & Regards,

Hans


p.s.

Note that these patches also add support for using a system wide
installed copy of FlightCrew (and the XercesExtensions), since
FlightCrew is a separate project this seemed to make sense. I'll
send you a separate patchset to make flightcrew use systemlibs
and to allow installing flightcrew as a shared library.
From 9400748ef712b7b46ffc0b7dc5869273204a091f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan[at]danny.cz>
Date: Mon, 23 Jan 2012 22:04:20 +0100
Subject: [PATCH 1/9] use system boost if available

---
 CMakeLists.txt                                     |   11 ++++++++++-
 src/FlightCrew/CMakeLists.txt                      |    6 +++---
 .../Validators/Opf/ReachabilityAnalysis.cpp        |    3 +++
 src/Sigil/CMakeLists.txt                           |    6 +++---
 src/XercesExtensions/CMakeLists.txt                |    2 +-
 src/utf8-cpp/utf8/core.h                           |    2 +-
 src/zipios/CMakeLists.txt                          |    4 ++--
 7 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index cd0b3b2..c645cf9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,9 +53,18 @@ set( CMAKE_OSX_ARCHITECTURES "x86_64" )
 # This disables the building of the test runner app for FlightCrew
 set( NO_TEST_EXE 1 )
 
+find_package( Boost COMPONENTS date_time filesystem program_options regex system thread )
+
 add_subdirectory( src/tidyLib )
 add_subdirectory( src/ZipArchive )
-add_subdirectory( src/BoostParts )
+if( Boost_FOUND )
+    set( BOOST_LIBS ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} )
+    set( BOOST_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} )
+else()
+    add_subdirectory( src/BoostParts )
+    set( BOOST_LIBS BoostParts )
+    set( BOOST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/BoostParts )
+endif()
 add_subdirectory( src/Xerces )
 add_subdirectory( src/XercesExtensions )
 add_subdirectory( src/zlib )
diff --git a/src/FlightCrew/CMakeLists.txt b/src/FlightCrew/CMakeLists.txt
index f93dc7b..1642a82 100644
--- a/src/FlightCrew/CMakeLists.txt
+++ b/src/FlightCrew/CMakeLists.txt
@@ -50,7 +50,7 @@ list( REMOVE_ITEM SOURCES ${to_remove} )
 
 # creating PCH's for MSVC and GCC on Linux
 include( ${CMAKE_SOURCE_DIR}/cmake_extras/CustomPCH.cmake )
-set( ALL_INCLUDES ${BoostParts_SOURCE_DIR}
+set( ALL_INCLUDES ${BOOST_INCLUDE_DIRS}
                   ${Xerces_SOURCE_DIR}
                   ${zipios_SOURCE_DIR} )
 set( GCC_PCH_TARGET gccPCH_fc )
@@ -65,7 +65,7 @@ precompiled_header( SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} )
 include_directories( ${CMAKE_CURRENT_BINARY_DIR}
                      ${CMAKE_CURRENT_SOURCE_DIR}
                      ../zipios 
-                     ../BoostParts 
+                     ${BOOST_INCLUDE_DIRS} 
                      ../Xerces
                      ../XercesExtensions
                      ../utf8-cpp
@@ -80,7 +80,7 @@ else()
     add_library( ${PROJECT_NAME} ${SOURCES} )
 endif()
 
-target_link_libraries( ${PROJECT_NAME} zipios BoostParts XercesExtensions )
+target_link_libraries( ${PROJECT_NAME} zipios ${BOOST_LIBS} XercesExtensions )
 
 #############################################################################
 
diff --git a/src/FlightCrew/Validators/Opf/ReachabilityAnalysis.cpp b/src/FlightCrew/Validators/Opf/ReachabilityAnalysis.cpp
index 24c0f28..4a83fc0 100644
--- a/src/FlightCrew/Validators/Opf/ReachabilityAnalysis.cpp
+++ b/src/FlightCrew/Validators/Opf/ReachabilityAnalysis.cpp
@@ -26,7 +26,9 @@
 #include <XmlUtils.h>
 #include "Misc/DetermineMimetype.h"
 #include "Misc/Utilities.h"
+#include <boost/version.hpp>
 
+#if BOOST_VERSION < 104800
 namespace boost
 {
 
@@ -48,6 +50,7 @@ namespace filesystem3
 } // namespace filesystem3
 
 } // namespace boost
+#endif
 
 
 namespace FlightCrew
diff --git a/src/Sigil/CMakeLists.txt b/src/Sigil/CMakeLists.txt
index 72c25d9..4501bee 100644
--- a/src/Sigil/CMakeLists.txt
+++ b/src/Sigil/CMakeLists.txt
@@ -371,7 +371,7 @@ set_source_files_properties( Misc/Utility.cpp PROPERTIES COMPILE_DEFINITIONS SIG
 
 # creating PCH's for MSVC and GCC on Linux
 include( ${CMAKE_SOURCE_DIR}/cmake_extras/CustomPCH.cmake )
-set( ALL_INCLUDES ${BoostParts_SOURCE_DIR}
+set( ALL_INCLUDES ${BOOST_INCLUDE_DIRS}
                   ${Xerces_SOURCE_DIR} 
                   ${XercesExtensions_SOURCE_DIR} 
                   ${ZipArchive_SOURCE_DIR}
@@ -458,7 +458,7 @@ endif()
 # and the headers for the linked-to libraries
 include_directories( ${CMAKE_CURRENT_BINARY_DIR} 
                      ${CMAKE_CURRENT_SOURCE_DIR} 
-                     ${BoostParts_SOURCE_DIR}
+                     ${BOOST_INCLUDE_DIRS}
                      ${Xerces_SOURCE_DIR} 
                      ${XercesExtensions_SOURCE_DIR} 
                      ${ZipArchive_SOURCE_DIR}
@@ -478,7 +478,7 @@ else()
     add_executable( ${PROJECT_NAME} WIN32 ${ALL_SOURCES} )
 endif()
 
-target_link_libraries( ${PROJECT_NAME} hunspell pcre tidyLib ZipArchive BoostParts Xerces XercesExtensions FlightCrew ${QT_LIBRARIES} )
+target_link_libraries( ${PROJECT_NAME} hunspell pcre tidyLib ZipArchive ${BOOST_LIBS} Xerces XercesExtensions FlightCrew ${QT_LIBRARIES} )
 
 #############################################################################
 
diff --git a/src/XercesExtensions/CMakeLists.txt b/src/XercesExtensions/CMakeLists.txt
index 08196e0..5e89c32 100644
--- a/src/XercesExtensions/CMakeLists.txt
+++ b/src/XercesExtensions/CMakeLists.txt
@@ -17,7 +17,7 @@ file( GLOB SOURCES *.cpp *.h )
 # and the headers for the linked-to libraries
 include_directories( ${CMAKE_CURRENT_SOURCE_DIR}
                      ../Xerces
-                     ../BoostParts )
+                     ${BOOST_INCLUDE_DIRS} )
 
 link_directories ( ${PROJECT_BINARY_DIR}/lib ) 
 
diff --git a/src/utf8-cpp/utf8/core.h b/src/utf8-cpp/utf8/core.h
index 294aad0..5a6c2bc 100644
--- a/src/utf8-cpp/utf8/core.h
+++ b/src/utf8-cpp/utf8/core.h
@@ -29,7 +29,7 @@ DEALINGS IN THE SOFTWARE.
 #define UTF8_FOR_CPP_CORE_H_2675DCD0_9480_4c0c_B92A_CC14C027B731
 
 #include <iterator>
-#include "../../BoostParts/boost/cstdint.hpp"
+#include "boost/cstdint.hpp"
 
 namespace utf8
 {
diff --git a/src/zipios/CMakeLists.txt b/src/zipios/CMakeLists.txt
index 88fdb7d..431c9ec 100644
--- a/src/zipios/CMakeLists.txt
+++ b/src/zipios/CMakeLists.txt
@@ -16,7 +16,7 @@ file( GLOB_RECURSE SOURCES *.cpp *.h )
 # We need to pick up the stdafx.h file
 # and the headers for the linked-to libraries
 include_directories( ${CMAKE_CURRENT_SOURCE_DIR}
-                     ${BoostParts_SOURCE_DIR}
+                     ${BOOST_INCLUDE_DIRS}
                      ${zlib_SOURCE_DIR}
                      ${zlib_BINARY_DIR}
                      )
@@ -25,7 +25,7 @@ link_directories ( ${PROJECT_BINARY_DIR}/lib )
 
 add_library( ${PROJECT_NAME} ${SOURCES} )
 
-target_link_libraries( ${PROJECT_NAME} zlib BoostParts )
+target_link_libraries( ${PROJECT_NAME} zlib ${BOOST_LIBS} )
 
 #############################################################################
 
-- 
1.7.7.6

From 99c04bc6f6f0e694523f834553b0df15192e9078 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan[at]danny.cz>
Date: Mon, 23 Jan 2012 22:05:29 +0100
Subject: [PATCH 2/9] use system zlib if available

---
 CMakeLists.txt            |    5 ++++-
 src/zipios/CMakeLists.txt |   15 ++++++++++++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c645cf9..9ac1ba7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,6 +54,7 @@ set( CMAKE_OSX_ARCHITECTURES "x86_64" )
 set( NO_TEST_EXE 1 )
 
 find_package( Boost COMPONENTS date_time filesystem program_options regex system thread )
+find_package( ZLIB )
 
 add_subdirectory( src/tidyLib )
 add_subdirectory( src/ZipArchive )
@@ -67,7 +68,9 @@ else()
 endif()
 add_subdirectory( src/Xerces )
 add_subdirectory( src/XercesExtensions )
-add_subdirectory( src/zlib )
+if( NOT ZLIB_FOUND )
+    add_subdirectory( src/zlib )
+endif()
 add_subdirectory( src/zipios )
 add_subdirectory( src/pcre )
 add_subdirectory( src/hunspell )
diff --git a/src/zipios/CMakeLists.txt b/src/zipios/CMakeLists.txt
index 431c9ec..db4838e 100644
--- a/src/zipios/CMakeLists.txt
+++ b/src/zipios/CMakeLists.txt
@@ -17,15 +17,24 @@ file( GLOB_RECURSE SOURCES *.cpp *.h )
 # and the headers for the linked-to libraries
 include_directories( ${CMAKE_CURRENT_SOURCE_DIR}
                      ${BOOST_INCLUDE_DIRS}
-                     ${zlib_SOURCE_DIR}
-                     ${zlib_BINARY_DIR}
                      )
 
+if( ZLIB_FOUND )
+    include_directories( ${ZLIB_INCLUDE_DIRS} )
+else()
+    include_directories( ${zlib_SOURCE_DIR} ${zlib_BINARY_DIR} )
+endif()
+
 link_directories ( ${PROJECT_BINARY_DIR}/lib )
 
 add_library( ${PROJECT_NAME} ${SOURCES} )
 
-target_link_libraries( ${PROJECT_NAME} zlib ${BOOST_LIBS} )
+target_link_libraries( ${PROJECT_NAME} ${BOOST_LIBS} )
+if( ZLIB_FOUND )
+    target_link_libraries( ${PROJECT_NAME} ${ZLIB_LIBRARIES} )
+else()
+    target_link_libraries( ${PROJECT_NAME} zlib )
+endif()
 
 #############################################################################
 
-- 
1.7.7.6

From 4b4e5abae3cb01cf1b5d5b2a472b34add9875375 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan[at]danny.cz>
Date: Mon, 23 Jan 2012 22:08:13 +0100
Subject: [PATCH 3/9] use system ZipArchive if available

---
 CMakeLists.txt           |    8 +++++++-
 src/Sigil/CMakeLists.txt |    6 +++---
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9ac1ba7..e66992c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,9 +55,15 @@ set( NO_TEST_EXE 1 )
 
 find_package( Boost COMPONENTS date_time filesystem program_options regex system thread )
 find_package( ZLIB )
+find_package( PkgConfig )
+pkg_check_modules( ZIPARCHIVE ZipArchive>=4.1.1 )
 
 add_subdirectory( src/tidyLib )
-add_subdirectory( src/ZipArchive )
+if( NOT ZIPARCHIVE_FOUND )
+    add_subdirectory( src/ZipArchive )
+    set( ZIPARCHIVE_LIBRARIES ZipArchive )
+    set( ZIPARCHIVE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/ZipArchive )
+endif()
 if( Boost_FOUND )
     set( BOOST_LIBS ${Boost_DATE_TIME_LIBRARY} ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_REGEX_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} )
     set( BOOST_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} )
diff --git a/src/Sigil/CMakeLists.txt b/src/Sigil/CMakeLists.txt
index 4501bee..0c99db8 100644
--- a/src/Sigil/CMakeLists.txt
+++ b/src/Sigil/CMakeLists.txt
@@ -374,7 +374,7 @@ include( ${CMAKE_SOURCE_DIR}/cmake_extras/CustomPCH.cmake )
 set( ALL_INCLUDES ${BOOST_INCLUDE_DIRS}
                   ${Xerces_SOURCE_DIR} 
                   ${XercesExtensions_SOURCE_DIR} 
-                  ${ZipArchive_SOURCE_DIR}
+                  ${ZIPARCHIVE_INCLUDE_DIRS}
                   ${tidyLib_SOURCE_DIR}
                   ${pcre_SOURCE_DIR}
                   ${hunspell_SOURCE_DIR}
@@ -461,7 +461,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}
                      ${BOOST_INCLUDE_DIRS}
                      ${Xerces_SOURCE_DIR} 
                      ${XercesExtensions_SOURCE_DIR} 
-                     ${ZipArchive_SOURCE_DIR}
+                     ${ZIPARCHIVE_INCLUDE_DIRS}
                      ${tidyLib_SOURCE_DIR}
                      ${pcre_SOURCE_DIR}
                      ${hunspell_SOURCE_DIR}
@@ -478,7 +478,7 @@ else()
     add_executable( ${PROJECT_NAME} WIN32 ${ALL_SOURCES} )
 endif()
 
-target_link_libraries( ${PROJECT_NAME} hunspell pcre tidyLib ZipArchive ${BOOST_LIBS} Xerces XercesExtensions FlightCrew ${QT_LIBRARIES} )
+target_link_libraries( ${PROJECT_NAME} hunspell pcre tidyLib ${ZIPARCHIVE_LIBRARIES} ${BOOST_LIBS} Xerces XercesExtensions FlightCrew ${QT_LIBRARIES} )
 
 #############################################################################
 
-- 
1.7.7.6

From 288fe75d8bf40a78a474fd6ffcedea7b972f57b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan[at]danny.cz>
Date: Mon, 23 Jan 2012 22:10:49 +0100
Subject: [PATCH 4/9] fix for ZipArchive

---
 src/Sigil/Exporters/ExportEPUB.cpp  |    2 +-
 src/Sigil/Importers/ImportOEBPS.cpp |    4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Sigil/Exporters/ExportEPUB.cpp b/src/Sigil/Exporters/ExportEPUB.cpp
index 71deeff..3da4b56 100644
--- a/src/Sigil/Exporters/ExportEPUB.cpp
+++ b/src/Sigil/Exporters/ExportEPUB.cpp
@@ -157,7 +157,7 @@ void ExportEPUB::SaveFolderAsEpubToLocation( const QString &fullfolderpath, cons
 #ifdef Q_WS_WIN
         std::string error_description = QString::fromStdWString( exception.GetErrorDescription() ).toStdString();
 #else
-        std::string error_description = QString::fromAscii( exception.GetErrorDescription().c_str() ).toStdString();
+        std::string error_description = QString::fromAscii( exception.GetErrorDescription() ).toStdString();
 #endif
         boost_throw( CZipExceptionWrapper()
             << errinfo_zip_info_msg( error_description )
diff --git a/src/Sigil/Importers/ImportOEBPS.cpp b/src/Sigil/Importers/ImportOEBPS.cpp
index fc31cf6..152f7d7 100644
--- a/src/Sigil/Importers/ImportOEBPS.cpp
+++ b/src/Sigil/Importers/ImportOEBPS.cpp
@@ -81,7 +81,7 @@ void ImportOEBPS::ExtractContainer()
                 #ifdef Q_WS_WIN
                 std::string filename = QString::fromStdWString( file_header->GetFileName() ).toStdString();
                 #else
-                std::string filename = QString::fromAscii( file_header->GetFileName().c_str() ).toStdString();
+                std::string filename = QString::fromAscii( file_header->GetFileName() ).toStdString();
                 #endif
 
                 zip.Close(); 
@@ -105,7 +105,7 @@ void ImportOEBPS::ExtractContainer()
 #ifdef Q_WS_WIN
         std::string error_description = QString::fromStdWString( exception.GetErrorDescription() ).toStdString();
 #else
-        std::string error_description = QString::fromAscii( exception.GetErrorDescription().c_str() ).toStdString();
+        std::string error_description = QString::fromAscii( exception.GetErrorDescription() ).toStdString();
 #endif
         boost_throw( CZipExceptionWrapper()
             << errinfo_zip_info_msg( error_description )
-- 
1.7.7.6

From 0f8738be6b9ea0b5db51201ae18378b78c4e97cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan[at]danny.cz>
Date: Mon, 23 Jan 2012 22:16:17 +0100
Subject: [PATCH 5/9] use system xerces-c if available

---
 CMakeLists.txt                      |    7 ++++++-
 src/FlightCrew/CMakeLists.txt       |    8 +++++---
 src/Sigil/CMakeLists.txt            |   10 ++++++----
 src/XercesExtensions/CMakeLists.txt |    8 +++++---
 4 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e66992c..834122c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -57,6 +57,7 @@ find_package( Boost COMPONENTS date_time filesystem program_options regex system
 find_package( ZLIB )
 find_package( PkgConfig )
 pkg_check_modules( ZIPARCHIVE ZipArchive>=4.1.1 )
+pkg_check_modules( XERCES xerces-c>=3.1 )
 
 add_subdirectory( src/tidyLib )
 if( NOT ZIPARCHIVE_FOUND )
@@ -72,7 +73,11 @@ else()
     set( BOOST_LIBS BoostParts )
     set( BOOST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/BoostParts )
 endif()
-add_subdirectory( src/Xerces )
+if( NOT XERCES_FOUND )
+    add_subdirectory( src/Xerces )
+    set( XERCES_LIBRARIES Xerces )
+    set( XERCES_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/Xerces )
+endif()
 add_subdirectory( src/XercesExtensions )
 if( NOT ZLIB_FOUND )
     add_subdirectory( src/zlib )
diff --git a/src/FlightCrew/CMakeLists.txt b/src/FlightCrew/CMakeLists.txt
index 1642a82..4ee27ee 100644
--- a/src/FlightCrew/CMakeLists.txt
+++ b/src/FlightCrew/CMakeLists.txt
@@ -51,7 +51,7 @@ list( REMOVE_ITEM SOURCES ${to_remove} )
 # creating PCH's for MSVC and GCC on Linux
 include( ${CMAKE_SOURCE_DIR}/cmake_extras/CustomPCH.cmake )
 set( ALL_INCLUDES ${BOOST_INCLUDE_DIRS}
-                  ${Xerces_SOURCE_DIR}
+                  ${XERCES_INCLUDE_DIRS}
                   ${zipios_SOURCE_DIR} )
 set( GCC_PCH_TARGET gccPCH_fc )
 
@@ -66,7 +66,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}
                      ${CMAKE_CURRENT_SOURCE_DIR}
                      ../zipios 
                      ${BOOST_INCLUDE_DIRS} 
-                     ../Xerces
+                     ${XERCES_INCLUDE_DIRS}
                      ../XercesExtensions
                      ../utf8-cpp
                    )
@@ -114,7 +114,9 @@ elseif( CMAKE_COMPILER_IS_GNUCXX )
 endif()
 
 # needed for correct Xerces header inclusion
-add_definitions( -DXERCES_STATIC_LIBRARY )
+if( NOT XERCES_FOUND )
+    add_definitions( -DXERCES_STATIC_LIBRARY )
+endif()
 
 #############################################################################
 
diff --git a/src/Sigil/CMakeLists.txt b/src/Sigil/CMakeLists.txt
index 0c99db8..2f8969c 100644
--- a/src/Sigil/CMakeLists.txt
+++ b/src/Sigil/CMakeLists.txt
@@ -372,7 +372,7 @@ set_source_files_properties( Misc/Utility.cpp PROPERTIES COMPILE_DEFINITIONS SIG
 # creating PCH's for MSVC and GCC on Linux
 include( ${CMAKE_SOURCE_DIR}/cmake_extras/CustomPCH.cmake )
 set( ALL_INCLUDES ${BOOST_INCLUDE_DIRS}
-                  ${Xerces_SOURCE_DIR} 
+                  ${XERCES_INCLUDE_DIRS} 
                   ${XercesExtensions_SOURCE_DIR} 
                   ${ZIPARCHIVE_INCLUDE_DIRS}
                   ${tidyLib_SOURCE_DIR}
@@ -459,7 +459,7 @@ endif()
 include_directories( ${CMAKE_CURRENT_BINARY_DIR} 
                      ${CMAKE_CURRENT_SOURCE_DIR} 
                      ${BOOST_INCLUDE_DIRS}
-                     ${Xerces_SOURCE_DIR} 
+                     ${XERCES_INCLUDE_DIRS} 
                      ${XercesExtensions_SOURCE_DIR} 
                      ${ZIPARCHIVE_INCLUDE_DIRS}
                      ${tidyLib_SOURCE_DIR}
@@ -478,7 +478,7 @@ else()
     add_executable( ${PROJECT_NAME} WIN32 ${ALL_SOURCES} )
 endif()
 
-target_link_libraries( ${PROJECT_NAME} hunspell pcre tidyLib ${ZIPARCHIVE_LIBRARIES} ${BOOST_LIBS} Xerces XercesExtensions FlightCrew ${QT_LIBRARIES} )
+target_link_libraries( ${PROJECT_NAME} hunspell pcre tidyLib ${ZIPARCHIVE_LIBRARIES} ${BOOST_LIBS} ${XERCES_LIBRARIES} XercesExtensions FlightCrew ${QT_LIBRARIES} )
 
 #############################################################################
 
@@ -488,7 +488,9 @@ xcode_pch( ${PCH_NAME} )
 #############################################################################
 
 # needed for correct static header inclusion
-add_definitions( -DXERCES_STATIC_LIBRARY )
+if( NOT XERCES_FOUND )
+    add_definitions( -DXERCES_STATIC_LIBRARY )
+endif()
 add_definitions( -DPCRE_STATIC )
 add_definitions( -DHUNSPELL_STATIC )
 
diff --git a/src/XercesExtensions/CMakeLists.txt b/src/XercesExtensions/CMakeLists.txt
index 5e89c32..c8bba73 100644
--- a/src/XercesExtensions/CMakeLists.txt
+++ b/src/XercesExtensions/CMakeLists.txt
@@ -16,14 +16,14 @@ file( GLOB SOURCES *.cpp *.h )
 # We need to pick up the stdafx.h file
 # and the headers for the linked-to libraries
 include_directories( ${CMAKE_CURRENT_SOURCE_DIR}
-                     ../Xerces
+                     ${XERCES_INCLUDE_DIRS}
                      ${BOOST_INCLUDE_DIRS} )
 
 link_directories ( ${PROJECT_BINARY_DIR}/lib ) 
 
 add_library( ${PROJECT_NAME} ${SOURCES} )
 
-target_link_libraries( ${PROJECT_NAME} Xerces )
+target_link_libraries( ${PROJECT_NAME} ${XERCES_LIBRARIES} )
 
 #############################################################################
 
@@ -49,5 +49,7 @@ elseif( CMAKE_COMPILER_IS_GNUCXX )
 endif()
 
 # needed for correct Xerces header inclusion
-add_definitions( -DXERCES_STATIC_LIBRARY )
+if( NOT XERCES_FOUND)
+    add_definitions( -DXERCES_STATIC_LIBRARY )
+endif()
 
-- 
1.7.7.6

From acf2d133feed53a4fa653abd7292c84ef6586e9f Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 23 Jan 2012 22:19:32 +0100
Subject: [PATCH 6/9] use system FlightCrew lib if available

---
 CMakeLists.txt           |   10 ++++++++--
 src/Sigil/CMakeLists.txt |    6 +++---
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 834122c..079651a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,7 @@ set( CMAKE_DEBUG_POSTFIX "d" )
 set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin )
 set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib )
 set( PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR}/package )
+set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/lib${LIB_SUFFIX}/cmake/FlightCrew" )
 
 set( SIGIL_MAJOR_VERSION 0 )
 set( SIGIL_MINOR_VERSION 5 )
@@ -58,6 +59,7 @@ find_package( ZLIB )
 find_package( PkgConfig )
 pkg_check_modules( ZIPARCHIVE ZipArchive>=4.1.1 )
 pkg_check_modules( XERCES xerces-c>=3.1 )
+find_package( FlightCrew )
 
 add_subdirectory( src/tidyLib )
 if( NOT ZIPARCHIVE_FOUND )
@@ -82,8 +84,12 @@ add_subdirectory( src/XercesExtensions )
 if( NOT ZLIB_FOUND )
     add_subdirectory( src/zlib )
 endif()
-add_subdirectory( src/zipios )
 add_subdirectory( src/pcre )
 add_subdirectory( src/hunspell )
-add_subdirectory( src/FlightCrew )
+if( NOT FLIGHTCREW_FOUND )
+    add_subdirectory( src/zipios )
+    add_subdirectory( src/FlightCrew )
+    set( FLIGHTCREW_LIBRARIES FlightCrew )
+    set( FLIGHTCREW_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/FlightCrew )
+endif()
 add_subdirectory( src/Sigil )
diff --git a/src/Sigil/CMakeLists.txt b/src/Sigil/CMakeLists.txt
index 2f8969c..7f50a7c 100644
--- a/src/Sigil/CMakeLists.txt
+++ b/src/Sigil/CMakeLists.txt
@@ -378,7 +378,7 @@ set( ALL_INCLUDES ${BOOST_INCLUDE_DIRS}
                   ${tidyLib_SOURCE_DIR}
                   ${pcre_SOURCE_DIR}
                   ${hunspell_SOURCE_DIR}
-                  ${FlightCrew_SOURCE_DIR}
+                  ${FLIGHTCREW_INCLUDE_DIRS}
                   ${QT_INCLUDES} )
 
 set( PCH_NAME stdafx )
@@ -465,7 +465,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}
                      ${tidyLib_SOURCE_DIR}
                      ${pcre_SOURCE_DIR}
                      ${hunspell_SOURCE_DIR}
-                     ${FlightCrew_SOURCE_DIR} )
+                     ${FLIGHTCREW_INCLUDE_DIRS} )
 
 #############################################################################
 
@@ -478,7 +478,7 @@ else()
     add_executable( ${PROJECT_NAME} WIN32 ${ALL_SOURCES} )
 endif()
 
-target_link_libraries( ${PROJECT_NAME} hunspell pcre tidyLib ${ZIPARCHIVE_LIBRARIES} ${BOOST_LIBS} ${XERCES_LIBRARIES} XercesExtensions FlightCrew ${QT_LIBRARIES} )
+target_link_libraries( ${PROJECT_NAME} hunspell pcre tidyLib ${ZIPARCHIVE_LIBRARIES} ${BOOST_LIBS} ${XERCES_LIBRARIES} XercesExtensions ${FLIGHTCREW_LIBRARIES} ${QT_LIBRARIES} )
 
 #############################################################################
 
-- 
1.7.7.6

From 4eba075edcb9556ed09402c5b7a930691fe4549c Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Mon, 23 Jan 2012 22:24:34 +0100
Subject: [PATCH 7/9] use system XercesExtensions lib if available

---
 CMakeLists.txt                |    8 +++++++-
 src/FlightCrew/CMakeLists.txt |    4 ++--
 src/Sigil/CMakeLists.txt      |    6 +++---
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 079651a..58757ea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,6 +15,7 @@ set( CMAKE_DEBUG_POSTFIX "d" )
 set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin )
 set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib )
 set( PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR}/package )
+set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/lib${LIB_SUFFIX}/cmake/XercesExtensions" )
 set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "/usr/lib${LIB_SUFFIX}/cmake/FlightCrew" )
 
 set( SIGIL_MAJOR_VERSION 0 )
@@ -59,6 +60,7 @@ find_package( ZLIB )
 find_package( PkgConfig )
 pkg_check_modules( ZIPARCHIVE ZipArchive>=4.1.1 )
 pkg_check_modules( XERCES xerces-c>=3.1 )
+find_package( XercesExtensions )
 find_package( FlightCrew )
 
 add_subdirectory( src/tidyLib )
@@ -80,7 +82,11 @@ if( NOT XERCES_FOUND )
     set( XERCES_LIBRARIES Xerces )
     set( XERCES_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/Xerces )
 endif()
-add_subdirectory( src/XercesExtensions )
+if( NOT XERCESEXTENSIONS_FOUND )
+    add_subdirectory( src/XercesExtensions )
+    set( XERCESEXTENSIONS_LIBRARIES XercesExtensions )
+    set( XERCESEXTENSIONS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/XercesExtensions )
+endif()
 if( NOT ZLIB_FOUND )
     add_subdirectory( src/zlib )
 endif()
diff --git a/src/FlightCrew/CMakeLists.txt b/src/FlightCrew/CMakeLists.txt
index 4ee27ee..9cde258 100644
--- a/src/FlightCrew/CMakeLists.txt
+++ b/src/FlightCrew/CMakeLists.txt
@@ -67,7 +67,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}
                      ../zipios 
                      ${BOOST_INCLUDE_DIRS} 
                      ${XERCES_INCLUDE_DIRS}
-                     ../XercesExtensions
+                     ${XERCESEXTENSIONS_INCLUDE_DIRS}
                      ../utf8-cpp
                    )
 
@@ -80,7 +80,7 @@ else()
     add_library( ${PROJECT_NAME} ${SOURCES} )
 endif()
 
-target_link_libraries( ${PROJECT_NAME} zipios ${BOOST_LIBS} XercesExtensions )
+target_link_libraries( ${PROJECT_NAME} zipios ${BOOST_LIBS} ${XERCESEXTENSIONS_LIBRARIES} )
 
 #############################################################################
 
diff --git a/src/Sigil/CMakeLists.txt b/src/Sigil/CMakeLists.txt
index 7f50a7c..37b5c45 100644
--- a/src/Sigil/CMakeLists.txt
+++ b/src/Sigil/CMakeLists.txt
@@ -373,7 +373,7 @@ set_source_files_properties( Misc/Utility.cpp PROPERTIES COMPILE_DEFINITIONS SIG
 include( ${CMAKE_SOURCE_DIR}/cmake_extras/CustomPCH.cmake )
 set( ALL_INCLUDES ${BOOST_INCLUDE_DIRS}
                   ${XERCES_INCLUDE_DIRS} 
-                  ${XercesExtensions_SOURCE_DIR} 
+                  ${XERCESEXTENSIONS_INCLUDE_DIRS} 
                   ${ZIPARCHIVE_INCLUDE_DIRS}
                   ${tidyLib_SOURCE_DIR}
                   ${pcre_SOURCE_DIR}
@@ -460,7 +460,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}
                      ${CMAKE_CURRENT_SOURCE_DIR} 
                      ${BOOST_INCLUDE_DIRS}
                      ${XERCES_INCLUDE_DIRS} 
-                     ${XercesExtensions_SOURCE_DIR} 
+                     ${XERCESEXTENSIONS_INCLUDE_DIRS} 
                      ${ZIPARCHIVE_INCLUDE_DIRS}
                      ${tidyLib_SOURCE_DIR}
                      ${pcre_SOURCE_DIR}
@@ -478,7 +478,7 @@ else()
     add_executable( ${PROJECT_NAME} WIN32 ${ALL_SOURCES} )
 endif()
 
-target_link_libraries( ${PROJECT_NAME} hunspell pcre tidyLib ${ZIPARCHIVE_LIBRARIES} ${BOOST_LIBS} ${XERCES_LIBRARIES} XercesExtensions ${FLIGHTCREW_LIBRARIES} ${QT_LIBRARIES} )
+target_link_libraries( ${PROJECT_NAME} hunspell pcre tidyLib ${ZIPARCHIVE_LIBRARIES} ${BOOST_LIBS} ${XERCES_LIBRARIES} ${XERCESEXTENSIONS_LIBRARIES} ${FLIGHTCREW_LIBRARIES} ${QT_LIBRARIES} )
 
 #############################################################################
 
-- 
1.7.7.6

From eec759f495d0dca945af9729605aaedf7836545f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan[at]danny.cz>
Date: Mon, 23 Jan 2012 22:27:00 +0100
Subject: [PATCH 8/9] use system hunspell library if available

---
 CMakeLists.txt           |    7 ++++++-
 src/Sigil/CMakeLists.txt |   10 ++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 58757ea..669d1cf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,6 +60,7 @@ find_package( ZLIB )
 find_package( PkgConfig )
 pkg_check_modules( ZIPARCHIVE ZipArchive>=4.1.1 )
 pkg_check_modules( XERCES xerces-c>=3.1 )
+pkg_check_modules( HUNSPELL hunspell )
 find_package( XercesExtensions )
 find_package( FlightCrew )
 
@@ -91,7 +92,11 @@ if( NOT ZLIB_FOUND )
     add_subdirectory( src/zlib )
 endif()
 add_subdirectory( src/pcre )
-add_subdirectory( src/hunspell )
+if( NOT HUNSPELL_FOUND )
+    add_subdirectory( src/hunspell )
+    set( HUNSPELL_LIBRARIES hunspell )
+    set( HUNSPELL_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/hunspell )
+endif()
 if( NOT FLIGHTCREW_FOUND )
     add_subdirectory( src/zipios )
     add_subdirectory( src/FlightCrew )
diff --git a/src/Sigil/CMakeLists.txt b/src/Sigil/CMakeLists.txt
index 37b5c45..5602415 100644
--- a/src/Sigil/CMakeLists.txt
+++ b/src/Sigil/CMakeLists.txt
@@ -377,7 +377,7 @@ set( ALL_INCLUDES ${BOOST_INCLUDE_DIRS}
                   ${ZIPARCHIVE_INCLUDE_DIRS}
                   ${tidyLib_SOURCE_DIR}
                   ${pcre_SOURCE_DIR}
-                  ${hunspell_SOURCE_DIR}
+                  ${HUNSPELL_INCLUDE_DIRS}
                   ${FLIGHTCREW_INCLUDE_DIRS}
                   ${QT_INCLUDES} )
 
@@ -464,7 +464,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}
                      ${ZIPARCHIVE_INCLUDE_DIRS}
                      ${tidyLib_SOURCE_DIR}
                      ${pcre_SOURCE_DIR}
-                     ${hunspell_SOURCE_DIR}
+                     ${HUNSPELL_INCLUDE_DIRS}
                      ${FLIGHTCREW_INCLUDE_DIRS} )
 
 #############################################################################
@@ -478,7 +478,7 @@ else()
     add_executable( ${PROJECT_NAME} WIN32 ${ALL_SOURCES} )
 endif()
 
-target_link_libraries( ${PROJECT_NAME} hunspell pcre tidyLib ${ZIPARCHIVE_LIBRARIES} ${BOOST_LIBS} ${XERCES_LIBRARIES} ${XERCESEXTENSIONS_LIBRARIES} ${FLIGHTCREW_LIBRARIES} ${QT_LIBRARIES} )
+target_link_libraries( ${PROJECT_NAME} ${HUNSPELL_LIBRARIES} pcre tidyLib ${ZIPARCHIVE_LIBRARIES} ${BOOST_LIBS} ${XERCES_LIBRARIES} ${XERCESEXTENSIONS_LIBRARIES} ${FLIGHTCREW_LIBRARIES} ${QT_LIBRARIES} )
 
 #############################################################################
 
@@ -492,7 +492,9 @@ if( NOT XERCES_FOUND )
     add_definitions( -DXERCES_STATIC_LIBRARY )
 endif()
 add_definitions( -DPCRE_STATIC )
-add_definitions( -DHUNSPELL_STATIC )
+if( NOT HUNSPELL_FOUND )
+    add_definitions( -DHUNSPELL_STATIC )
+endif()
 
 # Speed up stirng building
 add_definitions( -DQT_USE_FAST_CONCATENATION )
-- 
1.7.7.6

From c4cec87d423fb81dc3883dafc783d698f1ee7ea8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan[at]danny.cz>
Date: Mon, 23 Jan 2012 22:29:24 +0100
Subject: [PATCH 9/9] use system pcre library if available

---
 CMakeLists.txt           |    7 ++++++-
 src/Sigil/CMakeLists.txt |   10 ++++++----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 669d1cf..f94d62d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,6 +61,7 @@ find_package( PkgConfig )
 pkg_check_modules( ZIPARCHIVE ZipArchive>=4.1.1 )
 pkg_check_modules( XERCES xerces-c>=3.1 )
 pkg_check_modules( HUNSPELL hunspell )
+pkg_check_modules( PCRE libpcre )
 find_package( XercesExtensions )
 find_package( FlightCrew )
 
@@ -91,7 +92,11 @@ endif()
 if( NOT ZLIB_FOUND )
     add_subdirectory( src/zlib )
 endif()
-add_subdirectory( src/pcre )
+if( NOT PCRE_FOUND )
+    add_subdirectory( src/pcre )
+    set( PCRE_LIBRARIES pcre )
+    set( PCRE_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src/pcre )
+endif()
 if( NOT HUNSPELL_FOUND )
     add_subdirectory( src/hunspell )
     set( HUNSPELL_LIBRARIES hunspell )
diff --git a/src/Sigil/CMakeLists.txt b/src/Sigil/CMakeLists.txt
index 5602415..c42afc7 100644
--- a/src/Sigil/CMakeLists.txt
+++ b/src/Sigil/CMakeLists.txt
@@ -376,7 +376,7 @@ set( ALL_INCLUDES ${BOOST_INCLUDE_DIRS}
                   ${XERCESEXTENSIONS_INCLUDE_DIRS} 
                   ${ZIPARCHIVE_INCLUDE_DIRS}
                   ${tidyLib_SOURCE_DIR}
-                  ${pcre_SOURCE_DIR}
+                  ${PCRE_INCLUDE_DIRS}
                   ${HUNSPELL_INCLUDE_DIRS}
                   ${FLIGHTCREW_INCLUDE_DIRS}
                   ${QT_INCLUDES} )
@@ -463,7 +463,7 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR}
                      ${XERCESEXTENSIONS_INCLUDE_DIRS} 
                      ${ZIPARCHIVE_INCLUDE_DIRS}
                      ${tidyLib_SOURCE_DIR}
-                     ${pcre_SOURCE_DIR}
+                     ${PCRE_INCLUDE_DIRS}
                      ${HUNSPELL_INCLUDE_DIRS}
                      ${FLIGHTCREW_INCLUDE_DIRS} )
 
@@ -478,7 +478,7 @@ else()
     add_executable( ${PROJECT_NAME} WIN32 ${ALL_SOURCES} )
 endif()
 
-target_link_libraries( ${PROJECT_NAME} ${HUNSPELL_LIBRARIES} pcre tidyLib ${ZIPARCHIVE_LIBRARIES} ${BOOST_LIBS} ${XERCES_LIBRARIES} ${XERCESEXTENSIONS_LIBRARIES} ${FLIGHTCREW_LIBRARIES} ${QT_LIBRARIES} )
+target_link_libraries( ${PROJECT_NAME} ${HUNSPELL_LIBRARIES} ${PCRE_LIBRARIES} tidyLib ${ZIPARCHIVE_LIBRARIES} ${BOOST_LIBS} ${XERCES_LIBRARIES} ${XERCESEXTENSIONS_LIBRARIES} ${FLIGHTCREW_LIBRARIES} ${QT_LIBRARIES} )
 
 #############################################################################
 
@@ -491,7 +491,9 @@ xcode_pch( ${PCH_NAME} )
 if( NOT XERCES_FOUND )
     add_definitions( -DXERCES_STATIC_LIBRARY )
 endif()
-add_definitions( -DPCRE_STATIC )
+if( NOT PCRE_FOUND )
+    add_definitions( -DPCRE_STATIC )
+endif()
 if( NOT HUNSPELL_FOUND )
     add_definitions( -DHUNSPELL_STATIC )
 endif()
-- 
1.7.7.6


Reply to: