diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d736d129..2be8f8be9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,7 +129,22 @@ if(NOT EXE_SQLITE3) message(SEND_ERROR "sqlite3 binary not found!") endif() -find_package(Sqlite3 REQUIRED) +find_package(unofficial-sqlite3 CONFIG REQUIRED) +if(unofficial-sqlite3_FOUND) + set(SQLITE3_FOUND true) + get_target_property(SQLITE3_INCLUDE_DIR unofficial::sqlite3::sqlite3 INTERFACE_INCLUDE_DIRECTORIES) + set(SQLITE3_LIBRARY unofficial::sqlite3::sqlite3) + # Extract version information from the header file + if(SQLITE3_INCLUDE_DIR) + file(STRINGS ${SQLITE3_INCLUDE_DIR}/sqlite3.h _ver_line + REGEX "^#define SQLITE_VERSION *\"[0-9]+\\.[0-9]+\\.[0-9]+\"" + LIMIT_COUNT 1) + string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" + SQLITE3_VERSION "${_ver_line}") + unset(_ver_line) + endif() +endif() + if(NOT SQLITE3_FOUND) message(SEND_ERROR "sqlite3 dependency not found!") endif() @@ -171,6 +186,7 @@ if(ENABLE_CURL) find_package(CURL REQUIRED) if(CURL_FOUND) set(CURL_ENABLED TRUE) + set(CURL_LIBRARY CURL::libcurl) else() message(SEND_ERROR "curl dependency not found!") endif() diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index c790fa4a8..6653a28b9 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -95,6 +95,10 @@ endif () foreach (PROJECT_VARIANT_NAME ${PROJECT_NAME} ${PROJECT_LEGACY_NAME}) string (TOLOWER "${PROJECT_VARIANT_NAME}" PROJECT_VARIANT_LOWER) + set(FIND_DEPENDENCY_SQLITE3 "find_dependency(unofficial-sqlite3 CONFIG)") + if(CURL_ENABLED) + set(FIND_DEPENDENCY_CURL "find_dependency(CURL CONFIG)") + endif() set (CMAKECONFIGSUBDIR "${CMAKECONFIGDIR}/${PROJECT_VARIANT_LOWER}") # proj-config.cmake for the install tree. It's installed in # ${CMAKECONFIGSUBDIR} and @PROJECT_ROOT_DIR@ is the relative diff --git a/cmake/project-config.cmake.in b/cmake/project-config.cmake.in index 23f997abd..8baef00f0 100644 --- a/cmake/project-config.cmake.in +++ b/cmake/project-config.cmake.in @@ -7,6 +7,10 @@ # @PROJECT_VARIANT_NAME@_LIBRARY_DIRS = /usr/local/lib # @PROJECT_VARIANT_NAME@_BINARY_DIRS = /usr/local/bin # @PROJECT_VARIANT_NAME@_VERSION = 4.9.1 (for example) +include(CMakeFindDependencyMacro) + +@FIND_DEPENDENCY_SQLITE3@ +@FIND_DEPENDENCY_CURL@ # Tell the user project where to find our headers and libraries get_filename_component (_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)