]> git.mxchange.org Git - flightgear.git/commitdiff
Allow use of the system's SQLite3 library.
authorJames Turner <zakalawe@mac.com>
Wed, 19 Sep 2012 13:28:25 +0000 (14:28 +0100)
committerJames Turner <zakalawe@mac.com>
Wed, 19 Sep 2012 13:28:25 +0000 (14:28 +0100)
Keep distro packagers happy by having the option to use the system's sqlite library instead of our bundled version. Set SYSTEM_SQLITE=1 when running cmake to use the system one.

CMakeLists.txt
CMakeModules/FindSQLite3.cmake [new file with mode: 0644]
src/Include/config_cmake.h.in
src/Main/CMakeLists.txt
src/Navaids/CMakeLists.txt

index 5f014f230c20d0fb66d84141f6a422b0f4d18db2..617d93d36a71304092c3b03d4a72f3e0f95e906b 100644 (file)
@@ -105,6 +105,7 @@ option(EVENT_INPUT       "Set to ON to build FlightGear with event-based Input s
 option(ENABLE_LIBSVN     "Set to ON to build FlightGear/terrasync with libsvnclient support (default)" ON)
 option(ENABLE_RTI        "Set to ON to build FlightGear with RTI support" OFF)
 option(JPEG_FACTORY      "Set to ON to build FlightGear with JPEG-factory support" OFF)
+option(SYSTEM_SQLITE     "Set to ON to build FlightGear with the system's SQLite3 library" OFF)
 
 # additional utilities
 option(ENABLE_FGADMIN    "Set to ON to build the FGADMIN application (default)" ON)
@@ -182,6 +183,12 @@ if(ENABLE_LIBSVN)
     endif(LIBSVN_FOUND)
 endif(ENABLE_LIBSVN)
 
+if (SYSTEM_SQLITE)
+    find_package(SQLite3 REQUIRED)
+    set(CMAKE_REQUIRED_INCLUDES ${SQLITE3_INCLUDED_DIR})
+    message(STATUS "Using system SQLite3 library")
+endif (SYSTEM_SQLITE)
+
 find_package(PLIB REQUIRED puaux pu js fnt)
 
 # FlightGear and SimGear versions need to match
diff --git a/CMakeModules/FindSQLite3.cmake b/CMakeModules/FindSQLite3.cmake
new file mode 100644 (file)
index 0000000..225ecd1
--- /dev/null
@@ -0,0 +1,41 @@
+# Find Sqlite3
+# ~~~~~~~~~~~~
+# Copyright (c) 2007, Martin Dobias <wonder.sk at gmail.com>
+# Redistribution and use is allowed according to the terms of the BSD license.
+# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+#
+# CMake module to search for Sqlite3 library
+#
+# If it's found it sets SQLITE3_FOUND to TRUE
+# and following variables are set:
+#    SQLITE3_INCLUDE_DIR
+#    SQLITE3_LIBRARY
+
+
+# FIND_PATH and FIND_LIBRARY normally search standard locations
+# before the specified paths. To search non-standard paths first,
+# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
+# and then again with no specified paths to search the default
+# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
+# searching for the same item do nothing. 
+
+FIND_PATH(SQLITE3_INCLUDE_DIR sqlite3.h
+    PATH_SUFFIXES include 
+    HINTS $ENV{SQLITE3DIR}
+    PATHS
+    /usr/local
+    /usr
+    /opt/local
+  )
+
+FIND_LIBRARY(SQLITE3_LIBRARY NAMES sqlite3 sqlite3
+    HINTS $ENV{SQLITE3DIR}
+    PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
+    PATHS
+    /usr/local
+    /usr
+    /opt/local
+  )
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(SQLITE3 DEFAULT_MSG SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR)
index 230b3d7b2800e9c758c23986a2b4fde7c8f3f959..181beffa56a3fd69e8242a58a344ed1c20f1eff6 100644 (file)
@@ -37,3 +37,5 @@
 
 #cmakedefine FG_HAVE_HLA
 #cmakedefine FG_JPEG_SERVER
+
+#cmakedefine SYSTEM_SQLITE
index 760c4d1395565a5160900ddfff7a015b13ae175d..d3fc203ae0064dfcd80d3de7a8db43b385f13163 100644 (file)
@@ -98,6 +98,7 @@ target_link_libraries(fgfs
        ${PLIB_LIBRARIES}
        ${JPEG_LIBRARY}
        ${HLA_LIBRARIES}
+    ${SQLITE3_LIBRARY}
        ${EVENT_INPUT_LIBRARIES}
        ${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
        ${SIMGEAR_SCENE_LIBRARY_DEPENDENCIES}
index 0dbc542c6527698c56d56f445648ef8b17cfa42e..5d15dd3d40d3204e473473a764d9f8fb64e10e55 100644 (file)
@@ -15,7 +15,6 @@ set(SOURCES
     LevelDXML.cxx
     FlightPlan.cxx
     NavDataCache.cxx
-    sqlite3.c
     PositionedOctree.cxx
        )
 
@@ -34,8 +33,12 @@ set(HEADERS
     LevelDXML.hxx
     FlightPlan.hxx
     NavDataCache.hxx
-    sqlite3.h
     PositionedOctree.hxx
     )
 
+if (NOT SYSTEM_SQLITE)
+    list(APPEND SOURCES sqlite3.c)
+    list(APPEND HEADERS sqlite3.h)
+endif()
+
 flightgear_component(Navaids "${SOURCES}" "${HEADERS}")
\ No newline at end of file