]> git.mxchange.org Git - simgear.git/commitdiff
Option to use system, instead of built-in, expat
authorJames Turner <zakalawe@mac.com>
Sun, 16 Sep 2012 16:07:35 +0000 (17:07 +0100)
committerJames Turner <zakalawe@mac.com>
Sun, 16 Sep 2012 16:07:35 +0000 (17:07 +0100)
At least one Linux distribution packager of FG has complained that we're bundling expat in our binaries. To keep them happy, add the option (-DSYSTEM_EXPAT=1 at cmake time) to use the system expat instead.

For the moment (and simplicity), this requires building SIMGEAR_SHARED (which is fired to on by selecting the option).

CMakeLists.txt
simgear/CMakeLists.txt
simgear/simgear_config_cmake.h.in
simgear/xml/CMakeLists.txt
simgear/xml/easyxml.cxx

index ccde5449c0ee6cf793e83d78c282354d179cf7f1..328dfdd0b791b4fd2e09a6bb5400956c840e1051 100644 (file)
@@ -74,6 +74,7 @@ option(JPEG_FACTORY     "Enable JPEG-factory support" OFF)
 option(ENABLE_LIBSVN    "Set to ON to build SimGear with libsvnclient support" ON)
 option(ENABLE_RTI       "Set to ON to build SimGear with RTI support" OFF)
 option(ENABLE_TESTS     "Set to OFF to disable building SimGear's test applications" ON)
+option(SYSTEM_EXPAT     "Set to ON to build SimGear using the system libExpat" OFF)
 
 if (MSVC)
   GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH)
@@ -168,6 +169,16 @@ endif(ENABLE_LIBSVN)
 find_package(ZLIB REQUIRED)
 find_package(Threads REQUIRED)
 
+if (SYSTEM_EXPAT)
+    message(STATUS "Requested to use system Expat library, forcing SIMGEAR_SHARED to true")
+    set(SIMGEAR_SHARED ON)
+    find_package(EXPAT REQUIRED)
+    include_directories(${EXPAT_INCLUDE_DIRS})
+else()
+    message(STATUS "Using built-in expat code")
+    add_definitions(-DHAVE_EXPAT_CONFIG_H)
+endif(SYSTEM_EXPAT)
+
 check_include_file(sys/time.h HAVE_SYS_TIME_H)
 check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H)
 check_include_file(unistd.h HAVE_UNISTD_H)
@@ -272,7 +283,6 @@ include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS}
     ${OPENAL_INCLUDE_DIR} )
 
 add_definitions(-DHAVE_CONFIG_H)
-add_definitions(-DHAVE_EXPAT_CONFIG_H)
 
 # configure a header file to pass some of the CMake settings
 # to the source code
index 2ec11752178ea36b861275ac362bb1b5c23bbab4..872be32a7cd94401fbce6b7d129abd021e356094 100644 (file)
@@ -60,7 +60,9 @@ if(SIMGEAR_SHARED)
     set_property(TARGET SimGearCore PROPERTY VERSION   ${SIMGEAR_VERSION})
     set_property(TARGET SimGearCore PROPERTY SOVERSION ${SIMGEAR_SOVERSION})
 
-    target_link_libraries(SimGearCore ${ZLIB_LIBRARY} ${RT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
+    target_link_libraries(SimGearCore ${ZLIB_LIBRARY} ${RT_LIBRARY} 
+        ${EXPAT_LIBRARIES}
+        ${CMAKE_THREAD_LIBS_INIT})
 
     if(LIBSVN_FOUND)
         target_link_libraries(SimGearCore ${LIBSVN_LIBRARIES})
index 563f9f7355416c0387883bbd6a6a3734a0c55e5b..a9d12392603150b601eece889341626e9f30cd63 100644 (file)
@@ -17,3 +17,5 @@
 #cmakedefine HAVE_LIBSVN_CLIENT_1
 
 #cmakedefine GCC_ATOMIC_BUILTINS_FOUND
+
+#cmakedefine SYSTEM_EXPAT
index 0cb8d2c47345d366bf4ee947bd68a78afc1bf884..8a96949d5116e2a82f93e357c5dcabccc5da4c8b 100644 (file)
@@ -7,26 +7,31 @@ set(HEADERS
     )
     
 set(SOURCES 
-    asciitab.h
-    hashtable.h
-    iasciitab.h
-    latin1tab.h
-    nametab.h
-    utf8tab.h
-    xmldef.h
-    xmlparse.h
-    xmlrole.h
-    xmltok.h
-    xmltok_impl.h
-    hashtable.c
-    xmlparse.c
-    xmlrole.c
-    xmltok.c
     easyxml.cxx
-    internal.h
-    ascii.h
-    expat.h
-    expat_external.h
     )
 
+if (NOT SYSTEM_EXPAT)
+    list(APPEND SOURCES
+        asciitab.h
+        hashtable.h
+        iasciitab.h
+        latin1tab.h
+        nametab.h
+        utf8tab.h
+        xmldef.h
+        xmlparse.h
+        xmlrole.h
+        xmltok.h
+        xmltok_impl.h
+        hashtable.c
+        xmlparse.c
+        xmlrole.c
+        xmltok.c
+        internal.h
+        ascii.h
+        expat.h
+        expat_external.h 
+    )
+endif()
+    
 simgear_component(xml xml "${SOURCES}" "${HEADERS}")
index 65a35513201a2de40a24b11b9b7cb01a63d28593..5cccdc481cc6b513bfa5310fccc5fb3f8221ca77 100644 (file)
@@ -4,13 +4,22 @@
  * This file is in the Public Domain, and comes with NO WARRANTY of any kind.
  */
 
+#ifdef HAVE_CONFIG_H
+#  include <simgear_config.h>
+#endif
+     
 #include <simgear/compiler.h>
 
 #include <string.h>            // strcmp()
 
 #include "easyxml.hxx"
-#include "xmlparse.h"
-
+     
+#ifdef SYSTEM_EXPAT
+#  include <expat.h>
+#else
+#  include "xmlparse.h"     
+#endif
+     
 #include <fstream>
 #include <iostream>