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") diff --git a/cmake/project-config.cmake.in b/cmake/project-config.cmake.in index 7d5579ae..0cf96252 100644 --- a/cmake/project-config.cmake.in +++ b/cmake/project-config.cmake.in @@ -15,6 +15,7 @@ if(@PROJECT_VARIANT_NAME@ STREQUAL "PROJ4") cmake_policy(PUSH) cmake_policy(SET CMP0012 NEW) +find_dependency(unofficial-sqlite3 CONFIG) if("@ENABLE_TIFF@") find_dependency(TIFF) endif()