46 lines
1.3 KiB
CMake
46 lines
1.3 KiB
CMake
if(${CMAKE_VERSION} VERSION_GREATER "3.13.99")
|
|
return()
|
|
endif()
|
|
|
|
# Compatibility mode
|
|
set(SQLite3_PREFIX "" CACHE PATH "The path to the prefix of SQLite3 installation")
|
|
|
|
find_path(SQLite3_INCLUDE_DIR NAMES sqlite3.h
|
|
PATHS
|
|
${SQLite3_PREFIX}/include
|
|
/opt/local/include
|
|
/usr/include
|
|
/usr/local/include
|
|
)
|
|
|
|
find_library(SQLite3_LIBRARIES NAMES sqlite3
|
|
PATHS
|
|
${SQLite3_PREFIX}/lib
|
|
/opt/local/lib
|
|
/usr/lib
|
|
/usr/local/lib
|
|
)
|
|
|
|
if(SQLite3_INCLUDE_DIR AND SQLite3_LIBRARIES AND NOT TARGET SQLite::SQlite3)
|
|
get_filename_component(SQlite3_LIBRARY_DIR ${SQLite3_LIBRARIES} PATH)
|
|
set(SQLite3_FOUND TRUE)
|
|
set(SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR})
|
|
add_library(SQLite::SQLite3 UNKNOWN IMPORTED)
|
|
set_target_properties(SQLite::SQLite3 PROPERTIES
|
|
INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIR}"
|
|
INTERFACE_LINK_LIBRARIES "${SQLite3_LIBRARIES}"
|
|
IMPORTED_LOCATION "${SQLite3_LIBRARY}"
|
|
)
|
|
endif()
|
|
|
|
# Extract version information from the header file
|
|
if(SQLite3_FOUND)
|
|
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()
|
|
|