FindSQLite3.cmake 1.3 KB

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