2021-06-13 23:38:48 +03:00
|
|
|
if ((CMAKE_MAJOR_VERSION LESS 3) OR (CMAKE_VERSION VERSION_LESS "3.0.2"))
|
|
|
|
message(FATAL_ERROR "CMake >= 3.0.2 is required")
|
|
|
|
endif()
|
2018-12-31 22:04:05 +03:00
|
|
|
|
2020-01-24 03:03:18 +03:00
|
|
|
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
|
|
|
set(CMAKE_INSTALL_LIBDIR "lib")
|
|
|
|
endif()
|
|
|
|
|
2018-12-31 22:04:05 +03:00
|
|
|
if (NOT OPENSSL_FOUND)
|
|
|
|
find_package(OpenSSL REQUIRED)
|
2018-02-18 00:24:34 +03:00
|
|
|
find_package(ZLIB REQUIRED)
|
2018-12-31 22:04:05 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(SQLITE_SOURCE
|
|
|
|
sqlite/sqlite3.c
|
|
|
|
|
|
|
|
sqlite/sqlite3.h
|
|
|
|
sqlite/sqlite3ext.h
|
|
|
|
sqlite/sqlite3session.h
|
|
|
|
)
|
|
|
|
|
2022-08-04 14:37:08 +03:00
|
|
|
# all SQLite functions are moved to namespace tdsqlite3 by `sed -Ebi 's/sqlite3([^.]|$)/td&/g' *`
|
|
|
|
|
2018-12-31 22:04:05 +03:00
|
|
|
add_library(tdsqlite STATIC ${SQLITE_SOURCE})
|
|
|
|
target_include_directories(tdsqlite PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
|
|
|
|
target_include_directories(tdsqlite SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})
|
2018-02-18 00:24:34 +03:00
|
|
|
target_link_libraries(tdsqlite PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES})
|
2020-07-28 01:34:35 +03:00
|
|
|
if (WIN32)
|
|
|
|
if (MINGW)
|
2020-10-11 23:48:17 +03:00
|
|
|
target_link_libraries(tdsqlite PRIVATE ws2_32 mswsock crypt32)
|
2020-07-28 01:34:35 +03:00
|
|
|
else()
|
2020-10-11 23:48:17 +03:00
|
|
|
target_link_libraries(tdsqlite PRIVATE ws2_32 Mswsock Crypt32)
|
2020-07-28 01:34:35 +03:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2018-12-31 22:04:05 +03:00
|
|
|
target_compile_definitions(tdsqlite PRIVATE
|
2021-09-23 12:05:09 +03:00
|
|
|
-DOMIT_MEMLOCK
|
2018-01-21 16:44:17 +03:00
|
|
|
-DSQLITE_DEFAULT_MEMSTATUS=0
|
2021-09-23 11:20:42 +03:00
|
|
|
-DSQLITE_DEFAULT_RECURSIVE_TRIGGERS=1
|
2021-09-23 12:05:09 +03:00
|
|
|
-DSQLITE_DEFAULT_SYNCHRONOUS=1
|
|
|
|
-DSQLITE_DISABLE_LFS
|
|
|
|
-DSQLITE_ENABLE_FTS5
|
|
|
|
-DSQLITE_HAS_CODEC
|
2018-01-21 16:44:17 +03:00
|
|
|
-DSQLITE_OMIT_DECLTYPE
|
2020-12-15 01:20:56 +03:00
|
|
|
-DSQLITE_OMIT_DEPRECATED
|
2021-09-23 12:05:09 +03:00
|
|
|
-DSQLITE_OMIT_DESERIALIZE
|
|
|
|
-DSQLITE_OMIT_LOAD_EXTENSION
|
|
|
|
-DSQLITE_OMIT_PROGRESS_CALLBACK
|
2018-01-21 16:44:17 +03:00
|
|
|
#-DSQLITE_OMIT_SHARED_CACHE
|
2021-09-23 12:05:09 +03:00
|
|
|
-DSQLITE_TEMP_STORE=2
|
2018-12-31 22:04:05 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT WIN32)
|
|
|
|
target_compile_definitions(tdsqlite PRIVATE -DHAVE_USLEEP -DNDEBUG=1)
|
|
|
|
endif()
|
|
|
|
|
2019-04-04 22:23:06 +03:00
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
2018-02-28 03:03:03 +03:00
|
|
|
target_compile_definitions(tdsqlite PRIVATE -DSQLITE_OS_WINRT=1)
|
|
|
|
endif()
|
|
|
|
|
2018-12-31 22:04:05 +03:00
|
|
|
if (GCC OR CLANG)
|
2023-05-15 11:01:26 +03:00
|
|
|
target_compile_options(tdsqlite PRIVATE -Wno-deprecated-declarations -Wno-unused-variable -Wno-unused-const-variable -Wno-unused-function -Wno-maybe-uninitialized -Wno-return-local-addr)
|
2018-12-31 22:04:05 +03:00
|
|
|
if (CLANG)
|
2023-07-30 00:56:08 +03:00
|
|
|
target_compile_options(tdsqlite PRIVATE -Wno-parentheses-equality -Wno-unused-value -Wno-unknown-warning-option -Wno-unused-command-line-argument -Qunused-arguments)
|
2018-12-31 22:04:05 +03:00
|
|
|
endif()
|
2020-05-17 04:57:46 +03:00
|
|
|
if (GCC AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0))
|
|
|
|
target_compile_options(tdsqlite PRIVATE -Wno-return-local-addr -Wno-stringop-overflow)
|
|
|
|
endif()
|
2018-12-31 22:04:05 +03:00
|
|
|
elseif (MSVC)
|
2018-02-28 03:03:03 +03:00
|
|
|
target_compile_options(tdsqlite PRIVATE /wd4996)
|
2018-12-31 22:04:05 +03:00
|
|
|
endif()
|
|
|
|
|
2023-10-14 08:05:01 +08:00
|
|
|
install(TARGETS tdsqlite EXPORT TdStaticTargets
|
2020-01-24 02:01:07 +03:00
|
|
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
2018-12-31 22:04:05 +03:00
|
|
|
)
|