From 50c61b42116d6bc3b21c90c8193a80d7ab1058e3 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 19 Sep 2012 14:28:25 +0100 Subject: [PATCH] Allow use of the system's SQLite3 library. 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 | 7 ++++++ CMakeModules/FindSQLite3.cmake | 41 ++++++++++++++++++++++++++++++++++ src/Include/config_cmake.h.in | 2 ++ src/Main/CMakeLists.txt | 1 + src/Navaids/CMakeLists.txt | 7 ++++-- 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 CMakeModules/FindSQLite3.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f014f230..617d93d36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 index 000000000..225ecd1bb --- /dev/null +++ b/CMakeModules/FindSQLite3.cmake @@ -0,0 +1,41 @@ +# Find Sqlite3 +# ~~~~~~~~~~~~ +# Copyright (c) 2007, Martin Dobias +# 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) diff --git a/src/Include/config_cmake.h.in b/src/Include/config_cmake.h.in index 230b3d7b2..181beffa5 100644 --- a/src/Include/config_cmake.h.in +++ b/src/Include/config_cmake.h.in @@ -37,3 +37,5 @@ #cmakedefine FG_HAVE_HLA #cmakedefine FG_JPEG_SERVER + +#cmakedefine SYSTEM_SQLITE diff --git a/src/Main/CMakeLists.txt b/src/Main/CMakeLists.txt index 760c4d139..d3fc203ae 100644 --- a/src/Main/CMakeLists.txt +++ b/src/Main/CMakeLists.txt @@ -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} diff --git a/src/Navaids/CMakeLists.txt b/src/Navaids/CMakeLists.txt index 0dbc542c6..5d15dd3d4 100644 --- a/src/Navaids/CMakeLists.txt +++ b/src/Navaids/CMakeLists.txt @@ -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 -- 2.39.5