summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlouiz’ <louiz@louiz.org>2017-06-13 10:30:51 +0200
committerlouiz’ <louiz@louiz.org>2017-06-13 10:30:51 +0200
commit7ca95a09740297ae9c041c5f8ae4caa0a57a149a (patch)
tree8d31f0102832e362e87e354b9fb1194529f3a9e0
parentceb496369f834ffa055eb5b7ffc273b2a21f9b9a (diff)
downloadbiboumi-7ca95a09740297ae9c041c5f8ae4caa0a57a149a.tar.gz
biboumi-7ca95a09740297ae9c041c5f8ae4caa0a57a149a.tar.bz2
biboumi-7ca95a09740297ae9c041c5f8ae4caa0a57a149a.tar.xz
biboumi-7ca95a09740297ae9c041c5f8ae4caa0a57a149a.zip
Find sqlite3 instead of litesql
Simplifies the CMakeLists.txt a little bit
-rw-r--r--CMakeLists.txt31
-rw-r--r--cmake/Modules/FindLITESQL.cmake76
-rw-r--r--cmake/Modules/FindSQLITE3.cmake43
3 files changed, 54 insertions, 96 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b081bc..ed20870 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -124,10 +124,10 @@ elseif(NOT WITHOUT_UDNS)
find_package(UDNS)
endif()
-if(WITH_LITESQL)
- find_package(LITESQL REQUIRED)
-elseif(NOT WITHOUT_LITESQL)
- find_package(LITESQL)
+if(WITH_SQLITE3)
+ find_package(SQLITE3 REQUIRED)
+elseif(NOT WITHOUT_SQLITE3)
+ find_package(SQLITE3)
endif()
#
@@ -158,17 +158,14 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}/")
file(GLOB source_utils
src/utils/*.[hc]pp)
add_library(utils OBJECT ${source_utils})
-add_dependencies(utils litesql_generated_sources)
file(GLOB source_irc
src/irc/*.[hc]pp)
add_library(irc OBJECT ${source_irc})
-add_dependencies(irc litesql_generated_sources)
file(GLOB source_xmpp
src/xmpp/*.[hc]pp)
add_library(xmpp OBJECT ${source_xmpp})
-add_dependencies(xmpp litesql_generated_sources)
file(GLOB source_identd
src/identd/*.[hc]pp)
@@ -177,7 +174,6 @@ add_library(identd OBJECT ${source_identd})
file(GLOB source_bridge
src/bridge/*.[hc]pp)
add_library(bridge OBJECT ${source_bridge})
-add_dependencies(bridge litesql_generated_sources)
file(GLOB source_config
src/config/*.[hc]pp)
@@ -191,20 +187,15 @@ file(GLOB source_network
src/network/*.[hc]pp)
add_library(network OBJECT ${source_network})
-if(LITESQL_FOUND)
- LITESQL_GENERATE_CPP("database/database.xml"
- "biboudb"
- LITESQL_GENERATED_SOURCES)
- add_custom_target(litesql_generated_sources SOURCES ${LITESQL_GENERATED_SOURCES})
+if(SQLITE3_FOUND)
+ file(GLOB source_database
+ src/database/*.[hc]pp)
+ add_library(database OBJECT ${source_database})
- add_library(database OBJECT src/database/database.cpp ${LITESQL_GENERATED_SOURCES})
- add_dependencies(database litesql_generated_sources)
-
- include_directories(database ${LITESQL_INCLUDE_DIRS})
+ include_directories(database ${SQLITE3_INCLUDE_DIRS})
set(USE_DATABASE TRUE)
else()
add_library(database OBJECT "")
- add_custom_target(litesql_generated_sources)
endif()
#
@@ -269,8 +260,8 @@ if(LIBIDN_FOUND)
target_link_libraries(test_suite ${LIBIDN_LIBRARIES})
endif()
if(USE_DATABASE)
- target_link_libraries(${PROJECT_NAME} ${LITESQL_LIBRARIES})
- target_link_libraries(test_suite ${LITESQL_LIBRARIES})
+ target_link_libraries(${PROJECT_NAME} ${SQLITE3_LIBRARIES})
+ target_link_libraries(test_suite ${SQLITE3_LIBRARIES})
endif()
# Define a __FILENAME__ macro with the relative path (from the base project directory)
diff --git a/cmake/Modules/FindLITESQL.cmake b/cmake/Modules/FindLITESQL.cmake
deleted file mode 100644
index 2d3b073..0000000
--- a/cmake/Modules/FindLITESQL.cmake
+++ /dev/null
@@ -1,76 +0,0 @@
-# - Find LiteSQL
-#
-# Find the LiteSQL library, and defines a function to generate C++ files
-# from the database xml file using litesql-gen fro
-#
-# This module defines the following variables:
-# LITESQL_FOUND - True if library and include directory are found
-# If set to TRUE, the following are also defined:
-# LITESQL_INCLUDE_DIRS - The directory where to find the header file
-# LITESQL_LIBRARIES - Where to find the library file
-# LITESQL_GENERATE_CPP - A function, to be used like this:
-# LITESQL_GENERATE_CPP("db/database.xml" # The file defining the db schemas
-# "database" # The name of the C++ “module”
-# # that will be generated
-# LITESQL_GENERATED_SOURCES # Variable containing the
-# resulting C++ files to compile
-#
-# For conveniance, these variables are also set. They have the same values
-# than the variables above. The user can thus choose his/her prefered way
-# to write them.
-# LITESQL_INCLUDE_DIR
-# LITESQL_LIBRARY
-#
-# This file is in the public domain
-
-find_path(LITESQL_INCLUDE_DIRS NAMES litesql.hpp
- DOC "The LiteSQL include directory")
-
-find_library(LITESQL_LIBRARIES NAMES litesql
- DOC "The LiteSQL library")
-
-foreach(DB_TYPE sqlite postgresql mysql ocilib)
- string(TOUPPER ${DB_TYPE} DB_TYPE_UPPER)
- find_library(LITESQL_${DB_TYPE_UPPER}_LIB_PATH NAMES litesql_${DB_TYPE}
- DOC "The ${DB_TYPE} backend for LiteSQL")
- if(LITESQL_${DB_TYPE_UPPER}_LIB_PATH)
- list(APPEND LITESQL_LIBRARIES ${LITESQL_${DB_TYPE_UPPER}_LIB_PATH})
- endif()
- mark_as_advanced(LITESQL_${DB_TYPE_UPPER}_LIB_PATH)
-endforeach()
-
-find_program(LITESQLGEN_EXECUTABLE NAMES litesql-gen
- DOC "The utility that creates .h and .cpp files from a xml database description")
-
-# Use some standard module to handle the QUIETLY and REQUIRED arguments, and
-# set LITESQL_FOUND to TRUE if these two variables are set.
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(LITESQL REQUIRED_VARS LITESQL_LIBRARIES LITESQL_INCLUDE_DIRS
- LITESQLGEN_EXECUTABLE)
-
-# Compatibility for all the ways of writing these variables
-if(LITESQL_FOUND)
- set(LITESQL_INCLUDE_DIR ${LITESQL_INCLUDE_DIRS})
- set(LITESQL_LIBRARY ${LITESQL_LIBRARIES})
-endif()
-
-mark_as_advanced(LITESQL_INCLUDE_DIRS LITESQL_LIBRARIES LITESQLGEN_EXECUTABLE)
-
-
-# LITESQL_GENERATE_CPP function
-
-function(LITESQL_GENERATE_CPP
- SOURCE_FILE OUTPUT_NAME OUTPUT_SOURCES)
- set(${OUTPUT_SOURCES})
- add_custom_command(
- OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.cpp"
- "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.hpp"
- COMMAND ${LITESQLGEN_EXECUTABLE}
- ARGS -t c++ --output-dir=${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE}
- DEPENDS ${SOURCE_FILE}
- COMMENT "Running litesql-gen on ${SOURCE_FILE}"
- VERBATIM)
- list(APPEND ${OUTPUT_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.cpp")
- set_source_files_properties(${${OUTPUT_SOURCES}} PROPERTIES GENERATED TRUE)
- set(${OUTPUT_SOURCES} ${${OUTPUT_SOURCES}} PARENT_SCOPE)
-endfunction()
diff --git a/cmake/Modules/FindSQLITE3.cmake b/cmake/Modules/FindSQLITE3.cmake
new file mode 100644
index 0000000..2861b37
--- /dev/null
+++ b/cmake/Modules/FindSQLITE3.cmake
@@ -0,0 +1,43 @@
+# - Find sqlite3
+# Find the sqlite3 cryptographic library
+#
+# This module defines the following variables:
+# SQLITE3_FOUND - True if library and include directory are found
+# If set to TRUE, the following are also defined:
+# SQLITE3_INCLUDE_DIRS - The directory where to find the header file
+# SQLITE3_LIBRARIES - Where to find the library file
+#
+# For conveniance, these variables are also set. They have the same values
+# than the variables above. The user can thus choose his/her prefered way
+# to write them.
+# SQLITE3_LIBRARY
+# SQLITE3_INCLUDE_DIR
+#
+# This file is in the public domain
+
+include(FindPkgConfig)
+
+if(NOT SQLITE3_FOUND)
+ pkg_check_modules(SQLITE3 sqlite3)
+endif()
+
+if(NOT SQLITE3_FOUND)
+ find_path(SQLITE3_INCLUDE_DIRS NAMES sqlite3.h
+ DOC "The sqlite3 include directory")
+
+ find_library(SQLITE3_LIBRARIES NAMES sqlite3
+ DOC "The sqlite3 library")
+
+ # Use some standard module to handle the QUIETLY and REQUIRED arguments, and
+ # set SQLITE3_FOUND to TRUE if these two variables are set.
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(SQLITE3 REQUIRED_VARS SQLITE3_LIBRARIES SQLITE3_INCLUDE_DIRS)
+
+ if(SQLITE3_FOUND)
+ set(SQLITE3_LIBRARY ${SQLITE3_LIBRARIES} CACHE INTERNAL "")
+ set(SQLITE3_INCLUDE_DIR ${SQLITE3_INCLUDE_DIRS} CACHE INTERNAL "")
+ set(SQLITE3_FOUND ${SQLITE3_FOUND} CACHE INTERNAL "")
+ endif()
+endif()
+
+mark_as_advanced(SQLITE3_INCLUDE_DIRS SQLITE3_LIBRARIES) \ No newline at end of file