diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt new file mode 100644 index 00000000..fb525003 --- /dev/null +++ b/3rdparty/CMakeLists.txt @@ -0,0 +1,4 @@ +if (NOT SYSTEM_EXPAT) + add_subdirectory(expat) +endif() + diff --git a/3rdparty/expat/CMakeLists.txt b/3rdparty/expat/CMakeLists.txt new file mode 100644 index 00000000..ed5bebee --- /dev/null +++ b/3rdparty/expat/CMakeLists.txt @@ -0,0 +1,42 @@ + + +configure_file ( + "${PROJECT_SOURCE_DIR}/3rdparty/expat/expat_config_cmake.in" + "${PROJECT_BINARY_DIR}/3rdparty/expat/expat_config.h" +) + + +set(expat_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 + sg_expat.h + sg_expat_external.h + ) + + +# this code will be linked into SimGearCore shared object, so it +# must be compiled with -fPIC too + + +if(SIMGEAR_SHARED AND UNIX) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") +endif() + +add_library(local_expat STATIC ${expat_sources}) + diff --git a/simgear/xml/Expat.COPYING b/3rdparty/expat/Expat.COPYING similarity index 100% rename from simgear/xml/Expat.COPYING rename to 3rdparty/expat/Expat.COPYING diff --git a/simgear/xml/ascii.h b/3rdparty/expat/ascii.h similarity index 100% rename from simgear/xml/ascii.h rename to 3rdparty/expat/ascii.h diff --git a/simgear/xml/asciitab.h b/3rdparty/expat/asciitab.h similarity index 100% rename from simgear/xml/asciitab.h rename to 3rdparty/expat/asciitab.h diff --git a/simgear/xml/expat_config_cmake.in b/3rdparty/expat/expat_config_cmake.in similarity index 100% rename from simgear/xml/expat_config_cmake.in rename to 3rdparty/expat/expat_config_cmake.in diff --git a/simgear/xml/hashtable.c b/3rdparty/expat/hashtable.c similarity index 100% rename from simgear/xml/hashtable.c rename to 3rdparty/expat/hashtable.c diff --git a/simgear/xml/hashtable.h b/3rdparty/expat/hashtable.h similarity index 100% rename from simgear/xml/hashtable.h rename to 3rdparty/expat/hashtable.h diff --git a/simgear/xml/iasciitab.h b/3rdparty/expat/iasciitab.h similarity index 100% rename from simgear/xml/iasciitab.h rename to 3rdparty/expat/iasciitab.h diff --git a/simgear/xml/internal.h b/3rdparty/expat/internal.h similarity index 100% rename from simgear/xml/internal.h rename to 3rdparty/expat/internal.h diff --git a/simgear/xml/latin1tab.h b/3rdparty/expat/latin1tab.h similarity index 100% rename from simgear/xml/latin1tab.h rename to 3rdparty/expat/latin1tab.h diff --git a/simgear/xml/nametab.h b/3rdparty/expat/nametab.h similarity index 100% rename from simgear/xml/nametab.h rename to 3rdparty/expat/nametab.h diff --git a/simgear/xml/expat.h b/3rdparty/expat/sg_expat.h similarity index 100% rename from simgear/xml/expat.h rename to 3rdparty/expat/sg_expat.h diff --git a/simgear/xml/expat_external.h b/3rdparty/expat/sg_expat_external.h similarity index 100% rename from simgear/xml/expat_external.h rename to 3rdparty/expat/sg_expat_external.h diff --git a/simgear/xml/utf8tab.h b/3rdparty/expat/utf8tab.h similarity index 100% rename from simgear/xml/utf8tab.h rename to 3rdparty/expat/utf8tab.h diff --git a/simgear/xml/xmldef.h b/3rdparty/expat/xmldef.h similarity index 100% rename from simgear/xml/xmldef.h rename to 3rdparty/expat/xmldef.h diff --git a/simgear/xml/xmlparse.c b/3rdparty/expat/xmlparse.c similarity index 100% rename from simgear/xml/xmlparse.c rename to 3rdparty/expat/xmlparse.c diff --git a/simgear/xml/xmlparse.h b/3rdparty/expat/xmlparse.h similarity index 100% rename from simgear/xml/xmlparse.h rename to 3rdparty/expat/xmlparse.h diff --git a/simgear/xml/xmlrole.c b/3rdparty/expat/xmlrole.c similarity index 100% rename from simgear/xml/xmlrole.c rename to 3rdparty/expat/xmlrole.c diff --git a/simgear/xml/xmlrole.h b/3rdparty/expat/xmlrole.h similarity index 100% rename from simgear/xml/xmlrole.h rename to 3rdparty/expat/xmlrole.h diff --git a/simgear/xml/xmltok.c b/3rdparty/expat/xmltok.c similarity index 100% rename from simgear/xml/xmltok.c rename to 3rdparty/expat/xmltok.c diff --git a/simgear/xml/xmltok.h b/3rdparty/expat/xmltok.h similarity index 100% rename from simgear/xml/xmltok.h rename to 3rdparty/expat/xmltok.h diff --git a/simgear/xml/xmltok_impl.c b/3rdparty/expat/xmltok_impl.c similarity index 100% rename from simgear/xml/xmltok_impl.c rename to 3rdparty/expat/xmltok_impl.c diff --git a/simgear/xml/xmltok_impl.h b/3rdparty/expat/xmltok_impl.h similarity index 100% rename from simgear/xml/xmltok_impl.h rename to 3rdparty/expat/xmltok_impl.h diff --git a/simgear/xml/xmltok_ns.c b/3rdparty/expat/xmltok_ns.c similarity index 100% rename from simgear/xml/xmltok_ns.c rename to 3rdparty/expat/xmltok_ns.c diff --git a/CMakeLists.txt b/CMakeLists.txt index d9c6f61b..a0112491 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,12 +227,18 @@ 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) + set(EXPAT_INCLUDE_DIRS + ${PROJECT_SOURCE_DIR}/3rdparty/expat + ${PROJECT_BINARY_DIR}/3rdparty/expat) + set(EXPAT_LIBRARIES local_expat) endif(SYSTEM_EXPAT) +include_directories(${EXPAT_INCLUDE_DIRS}) + check_include_file(inttypes.h HAVE_INTTYPES_H) check_include_file(sys/time.h HAVE_SYS_TIME_H) check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H) @@ -346,7 +352,6 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}") include_directories(${PROJECT_SOURCE_DIR}) include_directories(${PROJECT_SOURCE_DIR}/simgear/canvas/ShivaVG/include) include_directories(${PROJECT_BINARY_DIR}/simgear) -include_directories(${PROJECT_BINARY_DIR}/simgear/xml) include_directories(${OPENSCENEGRAPH_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} @@ -364,11 +369,6 @@ configure_file ( "${PROJECT_BINARY_DIR}/simgear/simgear_config.h" ) -configure_file ( - "${PROJECT_SOURCE_DIR}/simgear/xml/expat_config_cmake.in" - "${PROJECT_BINARY_DIR}/simgear/xml/expat_config.h" -) - if(ENABLE_TESTS) # enable CTest / make test target message(STATUS "Tests: ENABLED") @@ -402,6 +402,8 @@ if(NOT SIMGEAR_HEADLESS) endif() install (FILES ${PROJECT_BINARY_DIR}/simgear/simgear_config.h DESTINATION include/simgear/) + +add_subdirectory(3rdparty) add_subdirectory(simgear) if (NOT EMBEDDED_SIMGEAR) diff --git a/simgear/io/DAVMultiStatus.cxx b/simgear/io/DAVMultiStatus.cxx index 6e1425dc..53b34b67 100644 --- a/simgear/io/DAVMultiStatus.cxx +++ b/simgear/io/DAVMultiStatus.cxx @@ -16,6 +16,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#ifdef HAVE_CONFIG_H +# include +#endif + #include "DAVMultiStatus.hxx" #include @@ -27,10 +31,15 @@ #include #include "simgear/debug/logstream.hxx" -#include "simgear/xml/xmlparse.h" #include "simgear/misc/strutils.hxx" #include "simgear/structure/exception.hxx" +#ifdef SYSTEM_EXPAT +# include +#else +# include "sg_expat.h" +#endif + using std::string; using namespace simgear; diff --git a/simgear/io/SVNReportParser.cxx b/simgear/io/SVNReportParser.cxx index a6f80224..93695f16 100644 --- a/simgear/io/SVNReportParser.cxx +++ b/simgear/io/SVNReportParser.cxx @@ -16,6 +16,10 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#ifdef HAVE_CONFIG_H +# include +#endif + #include "SVNReportParser.hxx" #include @@ -30,11 +34,16 @@ #include "simgear/misc/sg_path.hxx" #include "simgear/misc/sg_dir.hxx" #include "simgear/debug/logstream.hxx" -#include "simgear/xml/xmlparse.h" #include "simgear/xml/easyxml.hxx" #include "simgear/misc/strutils.hxx" #include "simgear/package/md5.h" +#ifdef SYSTEM_EXPAT +# include +#else +# include "sg_expat.h" +#endif + #include "SVNDirectory.hxx" #include "SVNRepository.hxx" #include "DAVMultiStatus.hxx" diff --git a/simgear/xml/CMakeLists.txt b/simgear/xml/CMakeLists.txt index 8a96949d..e2dae9e9 100644 --- a/simgear/xml/CMakeLists.txt +++ b/simgear/xml/CMakeLists.txt @@ -10,28 +10,4 @@ set(SOURCES easyxml.cxx ) -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}") diff --git a/simgear/xml/easyxml.cxx b/simgear/xml/easyxml.cxx index c2fc1213..08a39fa4 100644 --- a/simgear/xml/easyxml.cxx +++ b/simgear/xml/easyxml.cxx @@ -17,7 +17,7 @@ #ifdef SYSTEM_EXPAT # include #else -# include "xmlparse.h" +# include "sg_expat.h" #endif #include @@ -136,7 +136,6 @@ XMLAttributesDefault::setValue (const char * name, const char * value) } - //////////////////////////////////////////////////////////////////////// // Attribute list wrapper for Expat. ////////////////////////////////////////////////////////////////////////