### Meson Build Setup for Ubuntu Source: https://github.com/srombauts/sqlitecpp/blob/master/README.md Instructions for setting up the build environment on Ubuntu to build SQLiteCpp using Meson. Includes installing necessary tools like gcc, ninja, python, and pip. ```sh # install gcc(compiler toolchain) and ninja (recommended build system) sudo apt install build-essential ninja-build # install python and pip (required for meson) sudo apt install python3 python3-pip # install meson pip install meson ``` -------------------------------- ### Meson Build Setup for Arch Linux Source: https://github.com/srombauts/sqlitecpp/blob/master/README.md Instructions for setting up the build environment on Arch Linux to build SQLiteCpp using Meson. Includes installing necessary tools like clang, ninja, python, and pip. ```sh # install clang (compiler toolchain) and ninja (recommended build system) sudo pacman -Syu clang ninja # install python and pip (required for meson) sudo pacman -Syu python python-pip # install meson pip install meson ``` -------------------------------- ### Install SQLiteCpp using vcpkg Source: https://github.com/srombauts/sqlitecpp/blob/master/docs/README.md Instructions for installing SQLiteCpp via the vcpkg dependency manager. This includes bootstrapping vcpkg, integrating it, and then installing the library. ```bash git clone https://github.com/Microsoft/vcpkg.git cd vcpkg ./bootstrap-vcpkg.sh ./vcpkg integrate install ./vcpkg install sqlitecpp ``` -------------------------------- ### Build SQLiteCpp with Tests and Examples using Meson Source: https://github.com/srombauts/sqlitecpp/blob/master/README.md Builds SQLiteCpp with tests and examples enabled using Meson. This is useful for development and verification. ```sh # setup the build directory with tests and examples enabled meson setup builddir -DSQLITECPP_BUILD_TESTS=true -DSQLITECPP_BUILD_EXAMPLES=true # build sqlitecpp meson compile -C builddir ``` -------------------------------- ### Build SQLiteCpp with Examples and Tests (Visual Studio) Source: https://github.com/srombauts/sqlitecpp/blob/master/docs/README.md Batch script commands to configure and build SQLiteCpp with example and test targets using CMake for Visual Studio. Includes generating the solution and building the project. ```Batchfile mkdir build cd build cmake .. # cmake .. -G "Visual Studio 16 2019" # for Visual Studio 2019 @REM Generate a Visual Studio solution for latest version found cmake -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON .. @REM Build default configuration (ie 'Debug') cmake --build . @REM Build and run tests ctest --output-on-failure ``` -------------------------------- ### Link SQLiteCpp using find_package in CMake Source: https://github.com/srombauts/sqlitecpp/blob/master/docs/README.md Example CMakeLists.txt snippet for finding and linking the SQLiteCpp library when it's installed system-wide. This assumes a 'SQLiteCppConfig.cmake' file is available. ```cmake # You can optionally define a minimum version in this call find_package(SQLiteCpp REQUIRED) # For this example, lets say you created an target with add_executable (or add_library) called "my_target" # You can optionally declare PUBLIC or PRIVATE linkage here, depending on your needs. target_link_libraries(my_target PRIVATE SQLiteCpp) ``` -------------------------------- ### Install SQLite3 Library and Headers Source: https://github.com/srombauts/sqlitecpp/blob/master/sqlite3/CMakeLists.txt Installs the sqlite3 library (shared or static) and its header file to standard locations using CMake's GNUInstallDirs. ```cmake # Allow the library to be installed via "make install" and found with "find_package" include(GNUInstallDirs) install(TARGETS sqlite3 EXPORT ${PROJECT_NAME}Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) install(FILES sqlite3.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT headers) ``` -------------------------------- ### Build SQLiteCpp with Examples and Tests (Linux Makefile) Source: https://github.com/srombauts/sqlitecpp/blob/master/docs/README.md Shell commands to configure and build SQLiteCpp with example and test targets using CMake for Linux. This generates a Makefile and then builds and runs the tests. ```Shell mkdir Debug cd Debug # Generate a Makefile for GCC (or Clang, depanding on CC/CXX envvar) cmake -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON .. # Build (ie 'make') cmake --build . # Build and run unit-tests (ie 'make test') ctest --output-on-failure ``` -------------------------------- ### Basic Meson Build Command Source: https://github.com/srombauts/sqlitecpp/blob/master/README.md A basic command to build the library using Meson with default options. Assumes Meson and its dependencies are already installed. ```sh meson setup build meson compile -C build ``` -------------------------------- ### Build SQLiteCpp with Meson Source: https://github.com/srombauts/sqlitecpp/blob/master/README.md Basic build command for SQLiteCpp using Meson. Ensure you have Meson installed. ```sh # setup the build directory meson setup builddir # build sqlitecpp meson compile -C builddir ``` -------------------------------- ### Conditional Installation of SQLiteCpp Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Enables or disables the 'install' target based on the SQLITECPP_INSTALL option. If enabled, it installs the library, headers, export files, and package configuration files. ```cmake option(SQLITECPP_INSTALL "Enables the install target." ON) if (SQLITECPP_INSTALL) include(GNUInstallDirs) install(TARGETS SQLiteCpp EXPORT ${PROJECT_NAME}Targets LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT headers FILES_MATCHING REGEX ".*\\.(hpp|h)$") install(EXPORT ${PROJECT_NAME}Targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) install(FILES ${PROJECT_SOURCE_DIR}/package.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}) include(CMakePackageConfigHelpers) write_basic_package_version_file( cmake/${PROJECT_NAME}ConfigVersion.cmake VERSION ${PROJECT_VERSION} COMPATIBILITY AnyNewerVersion) configure_package_config_file( cmake/${PROJECT_NAME}Config.cmake.in cmake/${PROJECT_NAME}Config.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}) endif (SQLITECPP_INSTALL) ``` -------------------------------- ### Configure CMake to Build Doxygen Documentation Source: https://github.com/srombauts/sqlitecpp/blob/master/README.md Enables Doxygen documentation generation during the CMake build process. Ensure Doxygen is installed. ```sh cmake -DSQLITECPP_RUN_DOXYGEN=ON ``` -------------------------------- ### Link SQLiteCpp with CMake on Linux Source: https://github.com/srombauts/sqlitecpp/blob/master/docs/README.md Example CMakeLists.txt configuration for linking the SQLiteCpp static library and the sqlite3 library on Linux systems. Ensure the SQLiteCpp source is added as a subdirectory. ```cmake add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/thirdparty/SQLiteCpp) add_executable(main src/main.cpp) target_link_libraries(main SQLiteCpp sqlite3 pthread dl ) ``` -------------------------------- ### Set Public Include Directories for SQLiteCpp Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Configures include directories for the SQLiteCpp target. PUBLIC ensures these are available to the target and its dependents. $ specifies paths relative to the build directory, while $ specifies paths relative to the installation prefix. ```cmake target_include_directories(SQLiteCpp PUBLIC $ $) ``` -------------------------------- ### SQLiteCpp Repository Structure Source: https://github.com/srombauts/sqlitecpp/blob/master/AGENTS.md Overview of the directory structure for the SQLiteCpp project, indicating the location of public headers, source files, tests, bundled SQLite3, and examples. ```text include/SQLiteCpp/ # Public headers src/ # Implementation files tests/ # Unit tests (*_test.cpp) sqlite3/ # Bundled SQLite3 source examples/ # Example applications ``` -------------------------------- ### Find External SQLite3 System Library Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Attempts to find and link against an installed SQLite3 system library. This option is used when `SQLITECPP_INTERNAL_SQLITE` is OFF. It also handles linking against sqlcipher if `SQLITE_HAS_CODEC` is enabled. ```cmake elseif (SQLITECPP_FIND_SQLITE) # When using the SQLite codec, we need to link against the sqlcipher lib & include # So this gets the lib & header, and links/includes everything if(SQLITE_HAS_CODEC) # Make PkgConfig optional since Windows doesn't usually have it installed. find_package(PkgConfig QUIET) if(PKG_CONFIG_FOUND) # IMPORTED_TARGET was added in 3.6.3 if(CMAKE_VERSION VERSION_LESS 3.6.3) pkg_check_modules(sqlcipher REQUIRED sqlcipher) # Only used in Database.cpp so PRIVATE to hide from end-user # Since we can't use IMPORTED_TARGET on this older Cmake version, manually link libs & includes target_link_libraries(SQLiteCpp PRIVATE ${sqlcipher_LIBRARIES}) target_include_directories(SQLiteCpp PRIVATE ${sqlcipher_INCLUDE_DIRS}) else() pkg_check_modules(sqlcipher REQUIRED IMPORTED_TARGET sqlcipher) # Only used in Database.cpp so PRIVATE to hide from end-user target_link_libraries(SQLiteCpp PRIVATE PkgConfig::sqlcipher) endif() else() # Since we aren't using pkgconf here, find it manually find_library(sqlcipher_LIBRARY "sqlcipher") find_path(sqlcipher_INCLUDE_DIR "sqlcipher/sqlite3.h" PATH_SUFFIXES "include" "includes" ) # Hides it from the GUI mark_as_advanced(sqlcipher_LIBRARY sqlcipher_INCLUDE_DIR) if(NOT sqlcipher_INCLUDE_DIR) message(FATAL_ERROR "${PROJECT_NAME} requires the \"\" header to use the codec functionality but it wasn't found.") elseif(NOT sqlcipher_LIBRARY) message(FATAL_ERROR "${PROJECT_NAME} requires the sqlcipher library to use the codec functionality but it wasn't found.") endif() # Only used in Database.cpp so PRIVATE to hide from end-user target_include_directories(SQLiteCpp PRIVATE "${sqlcipher_INCLUDE_DIR}/sqlcipher") target_link_libraries(SQLiteCpp PRIVATE ${sqlcipher_LIBRARY}) endif() else() find_package (SQLite3 REQUIRED) message(STATUS "Link to sqlite3 system library ${SQLite3_VERSION}") target_link_libraries(SQLiteCpp PUBLIC SQLite::SQLite3) if(SQLite3_VERSION VERSION_LESS "3.19") set_target_properties(SQLiteCpp PROPERTIES COMPILE_FLAGS "-DSQLITECPP_HAS_MEM_STRUCT") endif() endif() endif () ``` -------------------------------- ### Querying a Database and Retrieving Results Source: https://github.com/srombauts/sqlitecpp/blob/master/docs/README.md Demonstrates how to open a database, compile a SQL query with a parameter, bind a value to the parameter, and iterate through the results. Ensure the database file and table exist. ```C++ try { // Open a database file SQLite::Database db("example.db3"); // Compile a SQL query, containing one parameter (index 1) SQLite::Statement query(db, "SELECT * FROM test WHERE size > ?"); // Bind the integer value 6 to the first parameter of the SQL query query.bind(1, 6); // Loop to execute the query step by step, to get rows of result while (query.executeStep()) { // Demonstrate how to get some typed column value int id = query.getColumn(0); const char* value = query.getColumn(1); int size = query.getColumn(2); std::cout << "row: " << id << ", " << value << ", " << size << std::endl; } } catch (std::exception& e) { std::cout << "exception: " << e.what() << std::endl; } ``` -------------------------------- ### Adding Example1Run Target Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Defines a test named 'Example1Run' that runs the SQLiteCpp_example1 executable, conditional on SQLITECPP_BUILD_EXAMPLES being true. ```cmake add_test(Example1Run bin/SQLiteCpp_example1) ``` -------------------------------- ### Clone SQLiteCpp and Initialize Submodules Source: https://github.com/srombauts/sqlitecpp/blob/master/docs/README.md Commands to clone the SQLiteCpp repository and initialize its submodules, including googletest for unit tests. ```Shell git clone https://github.com/SRombauts/SQLiteCpp.git cd SQLiteCpp git submodule init git submodule update ``` -------------------------------- ### Query Database and Retrieve Results Source: https://github.com/srombauts/sqlitecpp/blob/master/README.md Demonstrates how to open a database, compile a SQL query with a parameter, bind a value, and iterate through the results. Use this for reading data from your SQLite database. ```C++ try { // Open a database file SQLite::Database db("example.db3"); // Compile a SQL query, containing one parameter (index 1) SQLite::Statement query(db, "SELECT * FROM test WHERE size > ?"); // Bind the integer value 6 to the first parameter of the SQL query query.bind(1, 6); // Loop to execute the query step by step, to get rows of result while (query.executeStep()) { // Demonstrate how to get some typed column value int id = query.getColumn(0); const char* value = query.getColumn(1); int size = query.getColumn(2); std::cout << "row: " << id << ", " << value << ", " << size << std::endl; } } catch (std::exception& e) { std::cout << "exception: " << e.what() << std::endl; } ``` -------------------------------- ### Managing Database Transactions Source: https://github.com/srombauts/sqlitecpp/blob/master/docs/README.md Shows how to manage a database transaction, including opening a database in read-write mode with create permissions, dropping a table if it exists, creating a new table, inserting data, and committing the transaction. Errors will be caught and reported. ```C++ try { SQLite::Database db("transaction.db3", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE); db.exec("DROP TABLE IF EXISTS test"); // Begin transaction SQLite::Transaction transaction(db); db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT)"); int nb = db.exec("INSERT INTO test VALUES (NULL, \"test\")"); std::cout << "INSERT INTO test VALUES (NULL, \"test\")", returned " << nb << std::endl; // Commit transaction transaction.commit(); } catch (std::exception& e) { std::cout << "exception: " << e.what() << std::endl; } ``` -------------------------------- ### Configure Include Directories for SQLite3 Source: https://github.com/srombauts/sqlitecpp/blob/master/sqlite3/CMakeLists.txt Sets public include directories for the sqlite3 library, including build-time and install-time paths. ```cmake target_include_directories(sqlite3 PUBLIC $ $) ``` -------------------------------- ### Basic CMakeLists.txt for SQLiteCpp Project Source: https://github.com/srombauts/sqlitecpp/blob/master/examples/example2/CMakeLists.txt This snippet shows a minimal CMakeLists.txt file to compile and link a C++ project using the SQLiteCpp library. It sets the C++ standard, includes the SQLiteCpp library, and defines the main executable. ```cmake cmake_minimum_required(VERSION 3.5...4.0) project(SQLiteCpp_Example VERSION 2.0) # SQLiteC++ 3.x now requires C++11 compiler set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) # Add SQLite3 C++ wrapper around sqlite3 library (and sqlite3 itself provided for ease of use) # Here you can set CMake variables to avoid building Example, as well as cpplint, cppcheck... # or set them in the cmake command line (see for instance provided build.bat/build.sh scripts) set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "" FORCE) set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "" FORCE) set(SQLITECPP_USE_STATIC_RUNTIME OFF CACHE BOOL "" FORCE) add_subdirectory(../.. SQLiteCpp) # out-of-source build requires explicit subdir name for compilation artifacts # Add main.cpp example source code to the executable add_executable(SQLiteCpp_Example src/main.cpp) # Link SQLiteCpp_example1 with SQLiteCpp target_link_libraries(SQLiteCpp_Example SQLiteCpp) ``` -------------------------------- ### Enabling Testing Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Enables the testing framework for the project. ```cmake enable_testing() ``` -------------------------------- ### Add SQLite3 Library Sources Source: https://github.com/srombauts/sqlitecpp/blob/master/sqlite3/CMakeLists.txt Defines the sqlite3 static library and lists its source and header files. ```cmake add_library(sqlite3 sqlite3.c sqlite3.h ) ``` -------------------------------- ### Adding UnitTests Target Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Defines a test named 'UnitTests' that runs the SQLiteCpp_tests executable. ```cmake add_test(UnitTests bin/SQLiteCpp_tests) ``` -------------------------------- ### Use Pre-existing SQLite3 CMake Target Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Links against a SQLite3 CMake target that is assumed to exist already. This is the fallback option when neither internal building nor finding an external library is desired or possible. ```cmake else () if (NOT TARGET SQLite::SQLite3) message(FATAL_ERROR "SQLITECPP_FIND_SQLITE=OFF requires a pre-existing SQLite::SQLite3 cmake target") endif() message(STATUS "Using pre-existing SQLite::SQLite3 cmake target") target_link_libraries(SQLiteCpp PUBLIC SQLite::SQLite3) endif () ``` -------------------------------- ### Link Pthread and DL Libraries on Unix Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Links the SQLiteCpp target with the `pthread` and `dl` libraries, which are typically required on Unix-like systems for threading and dynamic loading functionalities. ```cmake if (UNIX) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) target_link_libraries(SQLiteCpp PUBLIC Threads::Threads ${CMAKE_DL_LIBS}) endif (UNIX) ``` -------------------------------- ### Manage Prepared Statement within a Transaction Source: https://github.com/srombauts/sqlitecpp/blob/master/README.md Illustrates how to use a prepared statement within a transaction to insert multiple values into a table. This is an efficient way to perform bulk inserts while maintaining transactional integrity. ```C++ try { SQLite::Database db("test.db3", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE); db.exec("DROP TABLE IF EXISTS test"); db.exec("CREATE TABLE test (value INTEGER)"); // Begin transaction SQLite::Transaction transaction(db); // Prepare query SQLite::Statement query {db, "INSERT INTO test (value) VALUES (?)"}; // Collection to save in database std::vector values{1, 2, 3}; for (const auto& v: values) { query.bind(1, v); query.exec(); query.reset(); } // Commit transaction transaction.commit(); } catch (std::exception& e) { std::cout << "exception: " << e.what() << std::endl; } ``` -------------------------------- ### Set GCC/Clang Specific Compile Options Source: https://github.com/srombauts/sqlitecpp/blob/master/sqlite3/CMakeLists.txt Configures specific warning flags for GCC and Clang compilers based on their version. ```cmake if (UNIX AND CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0) target_compile_options(sqlite3 PRIVATE "-Wimplicit-fallthrough=0") endif() if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) target_compile_options(sqlite3 PRIVATE "-Wno-cast-function-type") endif() endif() ``` -------------------------------- ### Troubleshooting Valgrind Memory Leaks Source: https://github.com/srombauts/sqlitecpp/blob/master/docs/README.md Run Valgrind to detect memory leaks in your application, the SQLiteCpp wrapper, or the sqlite3 library. This command is for Unix-like systems. ```Shell valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose build/SQLiteCpp_example1 ``` -------------------------------- ### Create an Alias Target for SQLite3 Source: https://github.com/srombauts/sqlitecpp/blob/master/sqlite3/CMakeLists.txt Creates an alias target 'SQLite::SQLite3' for the 'sqlite3' library, useful for modern CMake usage. ```cmake add_library(SQLite::SQLite3 ALIAS sqlite3) ``` -------------------------------- ### Configure Internal SQLite3 Build Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Enables building the SQLite3 C library directly from its source within the project. This is useful for ensuring compatibility and ease of use. It disables the RTree and DBSTAT extensions by default. ```cmake option(SQLITECPP_INTERNAL_SQLITE "Add the internal SQLite3 source to the project." ON) if (SQLITECPP_INTERNAL_SQLITE) if (SQLITE_HAS_CODEC) message(FATAL_ERROR "Internal sqlite3 source does not support SQLITE_HAS_CODEC") endif() message(STATUS "Compile sqlite3 from source in subdirectory") option(SQLITE_ENABLE_RTREE "Enable RTree extension when building internal sqlite3 library." OFF) option(SQLITE_ENABLE_DBSTAT_VTAB "Enable DBSTAT read-only eponymous virtual table extension when building internal sqlite3 library." OFF) # build the SQLite3 C library (for ease of use/compatibility) versus Linux sqlite3-dev package add_subdirectory(sqlite3) target_link_libraries(SQLiteCpp PUBLIC SQLite::SQLite3) endif () ``` -------------------------------- ### Conditional Build of Tests Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Controls the building of tests based on the SQLITECPP_BUILD_TESTS variable. If off, a status message is printed. ```cmake else (SQLITECPP_BUILD_TESTS) message(STATUS "SQLITECPP_BUILD_TESTS OFF") endif (SQLITECPP_BUILD_TESTS) ``` -------------------------------- ### Linking Tests with gtest_main Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Links the SQLiteCpp_tests target with the gtest_main library, assuming gtest is found. ```cmake target_link_libraries(SQLiteCpp_tests gtest_main) ``` -------------------------------- ### Define SQLite API for Windows Shared Libraries Source: https://github.com/srombauts/sqlitecpp/blob/master/sqlite3/CMakeLists.txt Sets the SQLITE_API macro to __declspec(dllexport) when building shared libraries on Windows. ```cmake if (WIN32) if (BUILD_SHARED_LIBS) add_definitions("-DSQLITE_API=__declspec(dllexport)") endif() endif() ``` -------------------------------- ### Enable DBSTAT Virtual Table Compilation Flag Source: https://github.com/srombauts/sqlitecpp/blob/master/sqlite3/CMakeLists.txt Adds the SQLITE_ENABLE_DBSTAT_VTAB compile definition if the corresponding CMake variable is set, and prints a status message. ```cmake if (SQLITE_ENABLE_DBSTAT_VTAB) # Enable DBSTAT extension when building sqlite3 # See more here: https://www.sqlite.org/dbstat.html target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_DBSTAT_VTAB) message(STATUS "Compile sqlite3 with SQLITE_ENABLE_DBSTAT_VTAB") endif (SQLITE_ENABLE_DBSTAT_VTAB) ``` -------------------------------- ### Enable RTree Extension Compilation Flag Source: https://github.com/srombauts/sqlitecpp/blob/master/sqlite3/CMakeLists.txt Adds the SQLITE_ENABLE_RTREE compile definition if the corresponding CMake variable is set, and prints a status message. ```cmake if (SQLITE_ENABLE_RTREE) # Enable RTree extension when building sqlite3 # See more here: https://sqlite.org/rtree.html target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_RTREE) message(STATUS "Compile sqlite3 with SQLITE_ENABLE_RTREE") endif (SQLITE_ENABLE_RTREE) ``` -------------------------------- ### Set PIC Flag for Unix Compilers Source: https://github.com/srombauts/sqlitecpp/blob/master/sqlite3/CMakeLists.txt Sets the -fPIC compile flag for the sqlite3 target when using GCC or Clang on Unix-like systems. ```cmake if (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) set_target_properties(sqlite3 PROPERTIES COMPILE_FLAGS "-fPIC") # Put each function in its own section to allow the linker garbage # collection to remove unused section and produced a smaller # statically-lined executables. target_compile_options(sqlite3 PRIVATE "-ffunction-sections") endif (UNIX AND (CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")) ``` -------------------------------- ### Enable Column Metadata Compilation Flag Source: https://github.com/srombauts/sqlitecpp/blob/master/sqlite3/CMakeLists.txt Adds the SQLITE_ENABLE_COLUMN_METADATA compile definition if the corresponding CMake variable is set. ```cmake if (SQLITE_ENABLE_COLUMN_METADATA) # Enable the use of SQLite column metadata method # Require that the sqlite3 library is also compiled with this flag: target_compile_definitions(sqlite3 PUBLIC SQLITE_ENABLE_COLUMN_METADATA) endif (SQLITE_ENABLE_COLUMN_METADATA) ``` -------------------------------- ### Define Custom Assertion Handler Source: https://github.com/srombauts/sqlitecpp/blob/master/docs/README.md Defines a custom assertion handler for SQLiteC++ when SQLITECPP_ENABLE_ASSERT_HANDLER is defined. This handler prints error details to stderr and aborts the program. ```C++ #ifdef SQLITECPP_ENABLE_ASSERT_HANDLER namespace SQLite { /// definition of the assertion handler enabled when SQLITECPP_ENABLE_ASSERT_HANDLER is defined in the project (CMakeList.txt) void assertion_failed(const char* apFile, const long apLine, const char* apFunc, const char* apExpr, const char* apMsg) { // Print a message to the standard error output stream, and abort the program. std::cerr << apFile << ":" << apLine << ":" << " error: assertion failed (" << apExpr << ") in " << apFunc << "() with message \"" << apMsg << "\"\n"; std::abort(); } } #endif ``` -------------------------------- ### Disable std::filesystem Support Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Option to disable the use of `std::filesystem` (C++17) within SQLiteCpp. This is useful for projects that do not use C++17 or have specific compatibility requirements. ```cmake option(SQLITECPP_DISABLE_STD_FILESYSTEM "Disable the use of std::filesystem in SQLiteCpp." OFF) if (SQLITECPP_DISABLE_STD_FILESYSTEM) message (STATUS "Disabling std::filesystem support") target_compile_definitions(SQLiteCpp PUBLIC SQLITECPP_DISABLE_STD_FILESYSTEM) endif (SQLITECPP_DISABLE_STD_FILESYSTEM) ``` -------------------------------- ### Omit Load Extension Compilation Flag Source: https://github.com/srombauts/sqlitecpp/blob/master/sqlite3/CMakeLists.txt Adds the SQLITE_OMIT_LOAD_EXTENSION compile definition if the corresponding CMake variable is set, and prints a status message. ```cmake if (SQLITE_OMIT_LOAD_EXTENSION) target_compile_definitions(sqlite3 PUBLIC SQLITE_OMIT_LOAD_EXTENSION) message(STATUS "Compile sqlite3 with SQLITE_OMIT_LOAD_EXTENSION") endif (SQLITE_OMIT_LOAD_EXTENSION) ``` -------------------------------- ### Conditional Compilation for MSVC Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Adds compile definitions for gmock and gmock_main targets when using specific MSVC versions to silence deprecation warnings. ```cmake target_compile_definitions(gmock PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) target_compile_definitions(gmock_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) endif (MSVC_VERSION GREATER_EQUAL 1910 AND MSVC_VERSION LESS_EQUAL 1919) endif (MSVC) ``` -------------------------------- ### Disable sqlite3_expanded_sql Support Source: https://github.com/srombauts/sqlitecpp/blob/master/CMakeLists.txt Option to disable the use of the `sqlite3_expanded_sql` function (available from SQLite 3.14.0). This can be used for compatibility with older SQLite versions or specific build configurations. ```cmake option(SQLITECPP_DISABLE_EXPANDED_SQL "Disable the use of sqlite3_expanded_sql in SQLiteCpp." OFF) if (SQLITECPP_DISABLE_EXPANDED_SQL) message (STATUS "Disabling sqlite3_expanded_sql support") target_compile_definitions(SQLiteCpp PUBLIC SQLITECPP_DISABLE_EXPANDED_SQL) endif (SQLITECPP_DISABLE_EXPANDED_SQL) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.