@@ -34,14 +34,31 @@ endif()
3434#
3535# Options
3636#
37- option (ENABLE_MAINTAINER_CFLAGS "Enable maintainer CFlags" OFF )
38- option (DRIVER_SQLITE "Enable Sqlite Driver" ON )
39- if (DRIVER_SQLITE)
40- enable_language (C )
37+ option (ASQL_ENABLE_MAINTAINER_CFLAGS "Enable maintainer CFlags" OFF )
38+ option (ASQL_DRIVER_SQLITE "Enable Sqlite Driver" ON )
39+ if (ASQL_DRIVER_SQLITE)
40+ find_package (SQLite3 )
41+ if (NOT SQLite3_FOUND)
42+ set (ASQL_SQLITE3_SUBMODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR } /3rdparty/sqlite" )
43+ if (EXISTS "${ASQL_SQLITE3_SUBMODULE_DIR} /sqlite3.c" )
44+ message (STATUS "SQLite3 not found via find_package, using bundled submodule" )
45+ enable_language (C )
46+ add_library (SQLite3_bundled STATIC "${ASQL_SQLITE3_SUBMODULE_DIR} /sqlite3.c" )
47+ target_include_directories (SQLite3_bundled PUBLIC "${ASQL_SQLITE3_SUBMODULE_DIR} " )
48+ add_library (SQLite3::SQLite3 ALIAS SQLite3_bundled )
49+ else ()
50+ message (FATAL_ERROR
51+ "SQLite3 not found and 3rdparty/sqlite/sqlite3.c is not available.\n "
52+ "Either install the SQLite3 development package or provide the amalgamation:\n "
53+ " 1. Initialize the submodule: git submodule update --init 3rdparty/sqlite\n "
54+ " 2. Generate the amalgamation (requires tclsh): cd 3rdparty/sqlite && make sqlite3.c\n "
55+ " See https://www.sqlite.org/howtocompile.html for details." )
56+ endif ()
57+ endif ()
4158endif ()
4259
43- option (DRIVER_POSTGRES "Enable PostgreSql Driver" ON )
44- if (DRIVER_POSTGRES )
60+ option (ASQL_DRIVER_POSTGRES "Enable PostgreSql Driver" ON )
61+ if (ASQL_DRIVER_POSTGRES )
4562 find_package (PostgreSQL REQUIRED )
4663endif ()
4764
@@ -55,12 +72,13 @@ endif()
5572set (CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX } /lib/${CMAKE_LIBRARY_ARCHITECTURE } " CACHE PATH "Output directory for libraries" )
5673
5774option (BUILD_SHARED_LIBS "Build in shared lib mode" ON )
58- option (BUILD_DEMOS "Build the demos" ON )
75+ option (ASQL_BUILD_DEMOS "Build the demos" ON )
76+ option (ASQL_MIGRATION_TOOL "Build the migration tool executable" ON )
5977
6078#
6179# Custom C flags
6280#
63- if (ENABLE_MAINTAINER_CFLAGS )
81+ if (ASQL_ENABLE_MAINTAINER_CFLAGS )
6482 set (MAINTAINER_CFLAGS "-Werror -Wall -Wcast-align -Wno-uninitialized -Wempty-body -Wformat-security -Wformat -Winit-self" )
6583 add_definitions (${MAINTAINER_CFLAGS}
6684 -DQT_DEPRECATED_WARNINGS
@@ -107,7 +125,7 @@ install(EXPORT ASqlTargets
107125)
108126
109127add_subdirectory (src )
110- if (BUILD_DEMOS )
128+ if (ASQL_BUILD_DEMOS )
111129 add_subdirectory (demos )
112130endif ()
113131
0 commit comments