kdelibs/cmake/modules/FindSqlite.cmake
Ivailo Monev 3eb17fdf2b cmake: review modules rewritten so far by me
using pkg-config search as primary method with fallback to path lookup,
this may result in overlinking however if libraries require additional
include paths (as is the case with PulseAudio) with this change that will
not be a problem.

it will also reduce the lookups done during configuration/build since path
lookups will not be done, unless pkg-config lookup does not set the
required variables.

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
2020-02-10 20:52:45 +00:00

44 lines
1.1 KiB
CMake

# - Try to find Sqlite
#
# Once done this will define
#
# SQLITE_FOUND - system has Sqlite
# SQLITE_INCLUDE_DIR - the Sqlite include directory
# SQLITE_LIBRARIES - The libraries needed to use Sqlite
#
# Copyright (c) 2020, Ivailo Monev, <xakepa10@gmail.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
if(SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES)
set(SQLITE_FIND_QUIETLY TRUE)
endif()
if(NOT WIN32)
include(FindPkgConfig)
pkg_check_modules(PC_SQLITE QUIET sqlite3)
set(SQLITE_INCLUDE_DIR ${PC_SQLITE_INCLUDE_DIRS})
set(SQLITE_LIBRARIES ${PC_SQLITE_LIBRARIES})
endif()
if(NOT SQLITE_INCLUDE_DIR OR NOT SQLITE_LIBRARIES)
find_path(SQLITE_INCLUDE_DIR
NAMES sqlite3.h
HINTS $ENV{SQLITEDIR}/include
)
find_library(SQLITE_LIBRARIES
NAMES sqlite3
HINTS $ENV{SQLITEDIR}/lib
)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Sqlite
VERSION_VAR PC_SQLITE_VERSION
REQUIRED_VARS SQLITE_LIBRARIES SQLITE_INCLUDE_DIR
)
mark_as_advanced(SQLITE_INCLUDE_DIR SQLITE_LIBRARIES)