1b815c7f3Sopenharmony_ci# - Find SQLite3
2b815c7f3Sopenharmony_ci# Find the native SQLite3 includes and libraries
3b815c7f3Sopenharmony_ci#
4b815c7f3Sopenharmony_ci#  SQLite3_INCLUDE_DIRS - where to find sqlite3.h, etc.
5b815c7f3Sopenharmony_ci#  SQLite3_LIBRARIES    - List of libraries when using SQLite3.
6b815c7f3Sopenharmony_ci#  SQLite3_FOUND        - True if SQLite3 found.
7b815c7f3Sopenharmony_ci
8b815c7f3Sopenharmony_ciif (SQLite3_INCLUDE_DIR)
9b815c7f3Sopenharmony_ci	# Already in cache, be silent
10b815c7f3Sopenharmony_ci	set (SQLite3_FIND_QUIETLY TRUE)
11b815c7f3Sopenharmony_ciendif ()
12b815c7f3Sopenharmony_ci
13b815c7f3Sopenharmony_cifind_package (PkgConfig QUIET)
14b815c7f3Sopenharmony_cipkg_check_modules (PC_SQLite3 QUIET sqlite3)
15b815c7f3Sopenharmony_ci
16b815c7f3Sopenharmony_ciset (SQLite3_VERSION ${PC_SQLite3_VERSION})
17b815c7f3Sopenharmony_ci
18b815c7f3Sopenharmony_cifind_path (SQLite3_INCLUDE_DIR sqlite3.h
19b815c7f3Sopenharmony_ci	HINTS
20b815c7f3Sopenharmony_ci		${PC_SQLite3_INCLUDEDIR}
21b815c7f3Sopenharmony_ci		${PC_SQLite3_INCLUDE_DIRS}
22b815c7f3Sopenharmony_ci		${SQLite3_ROOT}
23b815c7f3Sopenharmony_ci	)
24b815c7f3Sopenharmony_ci
25b815c7f3Sopenharmony_cifind_library (SQLite3_LIBRARY
26b815c7f3Sopenharmony_ci	NAMES
27b815c7f3Sopenharmony_ci		sqlite3
28b815c7f3Sopenharmony_ci	HINTS
29b815c7f3Sopenharmony_ci		${PC_SQLite3_LIBDIR}
30b815c7f3Sopenharmony_ci		${PC_SQLite3_LIBRARY_DIRS}
31b815c7f3Sopenharmony_ci		${SQLite3_ROOT}
32b815c7f3Sopenharmony_ci	)
33b815c7f3Sopenharmony_ci
34b815c7f3Sopenharmony_ciinclude (FindPackageHandleStandardArgs)
35b815c7f3Sopenharmony_ci
36b815c7f3Sopenharmony_cifind_package_handle_standard_args (SQLite3
37b815c7f3Sopenharmony_ci	REQUIRED_VARS
38b815c7f3Sopenharmony_ci		SQLite3_LIBRARY
39b815c7f3Sopenharmony_ci		SQLite3_INCLUDE_DIR
40b815c7f3Sopenharmony_ci	VERSION_VAR
41b815c7f3Sopenharmony_ci		SQLite3_VERSION
42b815c7f3Sopenharmony_ci	)
43b815c7f3Sopenharmony_ci
44b815c7f3Sopenharmony_ciif (SQLite3_FOUND)
45b815c7f3Sopenharmony_ci	set (SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR})
46b815c7f3Sopenharmony_ci	set (SQLite3_LIBRARIES ${SQLite3_LIBRARY})
47b815c7f3Sopenharmony_ci	if (NOT TARGET SQLite::SQLite3)
48b815c7f3Sopenharmony_ci		add_library (SQLite::SQLite3 UNKNOWN IMPORTED)
49b815c7f3Sopenharmony_ci		set_target_properties (SQLite::SQLite3 PROPERTIES
50b815c7f3Sopenharmony_ci			INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIRS}"
51b815c7f3Sopenharmony_ci			IMPORTED_LOCATION "${SQLite3_LIBRARIES}"
52b815c7f3Sopenharmony_ci		)
53b815c7f3Sopenharmony_ci	endif ()
54b815c7f3Sopenharmony_ciendif ()
55b815c7f3Sopenharmony_ci
56b815c7f3Sopenharmony_cimark_as_advanced (SQLite3_INCLUDE_DIR SQLite3_LIBRARY)
57