2018-12-31 20:04:05 +01:00
|
|
|
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
|
|
|
|
|
2020-01-24 01:03:18 +01:00
|
|
|
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
|
|
|
|
set(CMAKE_INSTALL_LIBDIR "lib")
|
|
|
|
endif()
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
if (NOT OPENSSL_FOUND)
|
|
|
|
find_package(OpenSSL REQUIRED)
|
2018-02-17 22:24:34 +01:00
|
|
|
find_package(ZLIB REQUIRED)
|
2018-12-31 20:04:05 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(SQLITE_SOURCE
|
|
|
|
sqlite/sqlite3.c
|
|
|
|
sqlite/sqlite3.h
|
|
|
|
sqlite/sqlite3ext.h
|
|
|
|
sqlite/sqlite3session.h
|
|
|
|
)
|
|
|
|
|
|
|
|
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-17 22:24:34 +01:00
|
|
|
target_link_libraries(tdsqlite PRIVATE ${OPENSSL_CRYPTO_LIBRARY} ${CMAKE_DL_LIBS} ${ZLIB_LIBRARIES})
|
2020-07-28 00:34:35 +02:00
|
|
|
if (WIN32)
|
|
|
|
if (MINGW)
|
|
|
|
target_link_libraries(tdsqlite PRIVATE ws2_32 mswsock)
|
|
|
|
else()
|
|
|
|
target_link_libraries(tdsqlite PRIVATE ws2_32 Mswsock)
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-05-23 21:27:24 +02:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
target_compile_definitions(tdsqlite PRIVATE
|
2020-05-23 21:27:24 +02:00
|
|
|
-DSQLITE_MAX_MMAP_SIZE=50331648
|
|
|
|
-DSQLITE_MAX_MEMORY=50331648
|
|
|
|
-DSQLITE_ENABLE_SORTER_REFERENCES
|
|
|
|
-DSQLITE_DIRECT_OVERFLOW_READ
|
|
|
|
-DSQLITE_ENABLE_MEMORY_MANAGEMENT
|
2018-12-31 20:04:05 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
if (NOT WIN32)
|
|
|
|
target_compile_definitions(tdsqlite PRIVATE -DHAVE_USLEEP -DNDEBUG=1)
|
|
|
|
endif()
|
|
|
|
|
2019-04-04 21:23:06 +02:00
|
|
|
if (CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
|
2018-02-28 01:03:03 +01:00
|
|
|
target_compile_definitions(tdsqlite PRIVATE -DSQLITE_OS_WINRT=1)
|
|
|
|
endif()
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
if (GCC OR CLANG)
|
2018-03-06 14:28:43 +01:00
|
|
|
target_compile_options(tdsqlite PRIVATE -Wno-deprecated-declarations -Wno-unused-variable -Wno-unused-const-variable -Wno-unused-function)
|
2018-12-31 20:04:05 +01:00
|
|
|
if (CLANG)
|
2018-03-06 14:28:43 +01:00
|
|
|
target_compile_options(tdsqlite PRIVATE -Wno-parentheses-equality -Wno-unused-value)
|
2018-12-31 20:04:05 +01:00
|
|
|
endif()
|
2020-05-17 03:57:46 +02: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 20:04:05 +01:00
|
|
|
elseif (MSVC)
|
2018-02-28 01:03:03 +01:00
|
|
|
target_compile_options(tdsqlite PRIVATE /wd4996)
|
2018-12-31 20:04:05 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
install(TARGETS tdsqlite EXPORT TdTargets
|
2020-01-24 00:01:07 +01:00
|
|
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
|
|
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
2018-12-31 20:04:05 +01:00
|
|
|
)
|