Sophie

Sophie

distrib > Mageia > 5 > i586 > by-pkgid > afbf95650f3b06a30139c74063748025 > files > 6

flightcrew-0.7.2-14.mga5.src.rpm

From cc366be2341b14a23321d93e50ccedd9a5a49282 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dan=20Hor=C3=A1k?= <dan[at]danny.cz>
Date: Wed, 18 Jan 2012 20:41:05 +0100
Subject: [PATCH 06/11] use system xerces-c if available

---
 CMakeLists.txt                      |    8 +++++++-
 src/FlightCrew/CMakeLists.txt       |    8 +++++---
 src/XercesExtensions/CMakeLists.txt |    8 +++++---
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 21f5cc7..335f004 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,6 +44,8 @@ set( CMAKE_OSX_ARCHITECTURES "i386;x86_64" )
 
 find_package( Boost COMPONENTS date_time filesystem program_options regex system thread )
 find_package( ZLIB )
+find_package( PkgConfig )
+pkg_check_modules( XERCES xerces-c>=3.1 )
 
 # The parsing order is significant!
 if( Boost_FOUND )
@@ -54,7 +56,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 72c7a0b..e86fc19 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
                    )
@@ -121,7 +121,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/XercesExtensions/CMakeLists.txt b/src/XercesExtensions/CMakeLists.txt
index d7ac6a8..98de34b 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} )
 
 #############################################################################
 
@@ -53,5 +53,7 @@ if( UNIX AND BUILD_SHARED_FC )
 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.4