
#[=========================================================[
  SQLITE doesn't provide build files in the
  standard source-only distribution. So we wrote
  a simple cmake file and we copy it to the
  external project folder so that we can use
  this file to build the lib with ExternalProject
#]=========================================================]

add_library (sqlite3 STATIC sqlite3.c)
#[=========================================================[
   When compiled with SQLITE_THREADSAFE=1, SQLite operates
   in serialized mode. In this mode, SQLite can be safely
   used by multiple threads with no restriction.

   NOTE: This implies a global mutex!

   When compiled with SQLITE_THREADSAFE=2, SQLite can be
   used in a multithreaded program so long as no two
   threads attempt to use the same database connection at
   the same time.

   NOTE: This is the preferred threading model, but not
   currently enabled because we need to investigate our
   use-model and concurrency requirements.

   TODO: consider whether any other options should be
   used: https://www.sqlite.org/compile.html
#]=========================================================]

target_compile_definitions (sqlite3
  PRIVATE
    SQLITE_THREADSAFE=1
    HAVE_USLEEP=1)
target_compile_options (sqlite3
  PRIVATE
    $<$<BOOL:${MSVC}>:
      -wd4100
      -wd4127
      -wd4232
      -wd4244
      -wd4701
      -wd4706
      -wd4996
    >
    $<$<NOT:$<BOOL:${MSVC}>>:-Wno-array-bounds>)
install (
  TARGETS
    sqlite3
  LIBRARY DESTINATION lib
  ARCHIVE DESTINATION lib
  RUNTIME DESTINATION bin
  INCLUDES DESTINATION include)
install (
  FILES
    sqlite3.h
    sqlite3ext.h
  DESTINATION include)


