Use preinstalled CMake find module for SQLite3

CMake >= 3.14 comes with a preinstalled FindSQLite3 module, which now
replaces the self-written one.

Signed-off-by: Kai Buschulte <kai.buschulte@cedalo.com>
This commit is contained in:
Kai Buschulte 2022-05-09 18:20:57 +02:00
parent 4487b98dbb
commit 15208e55cc
4 changed files with 10 additions and 45 deletions

View file

@ -4,7 +4,7 @@
# To configure the build options either use the CMake gui, or run the command
# line utility including the "-i" option.
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.14)
set (VERSION 2.1.0)
project(mosquitto
@ -50,7 +50,7 @@ endif()
option(WITH_SQLITE "Include sqlite persistence support?" ON)
if (WITH_SQLITE)
find_package(sqlite3 REQUIRED)
find_package(SQLite3 REQUIRED)
add_definitions("-DWITH_SQLITE")
endif()

View file

@ -139,6 +139,9 @@ Clients:
- Add float printing option to mosquitto_sub.
- Fix `-f` and `-s` options in mosquitto_rr.
Build:
- Increased CMake minimal required version to 3.14, which is required for the
preinstalled SQLite3 find module.
2.0.14 - 2021-11-17
===================

View file

@ -1,38 +0,0 @@
INCLUDE( FindPackageHandleStandardArgs )
# Checks an environment variable; note that the first check
# does not require the usual CMake $-sign.
IF( DEFINED ENV{SQLITE3_DIR} )
SET( SQLITE3_DIR "$ENV{SQLITE3_DIR}" )
ENDIF()
FIND_PATH(
SQLITE3_INCLUDE_DIR
sqlite3.h
HINTS
SQLITE3_DIR
)
FIND_LIBRARY( SQLITE3_LIBRARY
NAMES sqlite3
HINTS ${SQLITE3_DIR}
)
FIND_PACKAGE_HANDLE_STANDARD_ARGS( sqlite3 DEFAULT_MSG
SQLITE3_INCLUDE_DIR SQLITE3_LIBRARY
)
IF( SQLITE3_FOUND )
SET( SQLITE3_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIR} )
SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY} )
MARK_AS_ADVANCED(
SQLITE3_LIBRARY
SQLITE3_INCLUDE_DIR
SQLITE3_DIR
)
ELSE()
SET( SQLITE3_DIR "" CACHE STRING
"An optional hint to a directory for finding `sqlite3`"
)
ENDIF()

View file

@ -1,7 +1,6 @@
if(SQLITE3_FOUND AND CJSON_FOUND)
add_definitions("-DWITH_CJSON")
set(CLIENT_INC
"${SQLITE3_INCLUDE_DIRS}"
"${STDBOOL_H_PATH}"
"${STDINT_H_PATH}"
"${mosquitto_SOURCE_DIR}"
@ -10,8 +9,6 @@ if(SQLITE3_FOUND AND CJSON_FOUND)
"${mosquitto_SOURCE_DIR}/src"
)
set(CLIENT_DIR "${mosquitto_BINARY_DIR}/lib" "${SQLITE3_DIR}")
add_library(mosquitto_persist_sqlite MODULE
base_msgs.c
clients.c
@ -25,7 +22,7 @@ if(SQLITE3_FOUND AND CJSON_FOUND)
)
target_include_directories(mosquitto_persist_sqlite PRIVATE
${CLIENT_INC} ${SQLITE3_INCLUDE_DIR}
${CLIENT_INC}
)
link_directories(${CLIENT_DIR} "${mosquitto_SOURCE_DIR}")
@ -34,7 +31,10 @@ if(SQLITE3_FOUND AND CJSON_FOUND)
POSITION_INDEPENDENT_CODE 1
)
target_link_libraries(mosquitto_persist_sqlite PRIVATE ${SQLITE3_LIBRARIES})
target_link_libraries(mosquitto_persist_sqlite
PRIVATE
SQLite::SQLite3
)
if(WIN32)
target_link_libraries(mosquitto_persist_sqlite PRIVATE mosquitto)
endif()