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() @@ -151,6 +165,7 @@ if(ENABLE_TIFF) find_package(TIFF REQUIRED) if(TIFF_FOUND) set(TIFF_ENABLED TRUE) + set(TIFF_LIBRARY TIFF::TIFF) else() message(SEND_ERROR "libtiff dependency not found! Use ENABLE_TIFF=OFF to force it off") @@ -171,6 +188,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/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 @@ -9,6 +9,13 @@ # @PROJECT_VARIANT_NAME@_VERSION = 4.9.1 (for example) include(CMakeFindDependencyMacro) +cmake_policy(PUSH) +cmake_policy(SET CMP0012 NEW) +find_dependency(unofficial-sqlite3 CONFIG) +if("@ENABLE_TIFF@") + find_dependency(TIFF) +endif() +cmake_policy(POP) if("@CURL_ENABLED@" STREQUAL "TRUE") # Chainload CURL usage requirements find_dependency(CURL)